SyncTitleController.class.php
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 2017/9/1
* Time: 16:33
*/
namespace Rpc\Controller\AppNotice;
use Think\Log;
use Com\PackageValidate;
use Common\Service\CustomtaskContentService;
class SyncTitleController extends \Rpc\Controller\AbstractController
{
/**
* SyncTitle
* @author zhonglei
* @desc 同步标题
* @param String app:true 应用
* @param Int app_data_id:true 应用数据ID
* @param String title:true 标题
* @return bool
*/
public function Index()
{
Log::record('params: ' . var_export($this->_params, true), Log::INFO);
$post_data = $this->_params;
// 验证规则
$rules = [
'app' => 'require',
'app_data_id' => 'require|integer',
'title' => 'require',
];
// 验证请求数据
$validate = new PackageValidate();
$validate->postData = $post_data;
$validate->validateParams($rules);
$conds = array_intersect_key_reserved($post_data, ['app', 'app_data_id'], true);
$contentServ = new CustomtaskContentService();
$count = $contentServ->count_by_conds($conds);
// 更新标题
if ($count > 0) {
$result = $contentServ->update_by_conds($conds, ['title' => $post_data['title']]);
Log::record("update customtask content title success {$result}", Log::INFO);
return true;
}
return false;
}
}