AuditController.class.php
3.08 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* AuditController.class.php
* 同事圈话题 审核
* Date: 2018-06-28
*/
namespace Apicp\Controller\Topic;
use Common\Common\Constant;
use Common\Model\CountModel;
use Common\Service\CircleService;
use Common\Service\CountService;
class AuditController extends AbstractController
{
/**
* @var CircleService 帖子信息表
*/
protected $_circle_serv;
/**
* @var CountService 统计表
*/
protected $_count_serv;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化信息同事圈 话题信息表
$this->_circle_serv = new CircleService();
// 实例化信息同事圈帖子信息表
$this->_count_serv = new CountService();
return true;
}
public function Index_post()
{
// 接收参数
$params = I('post.');
// 获取详情
$c_data = $this->verification($params);
// 验证参数
if (!$c_data) {
return false;
}
// 获取登录用户信息
$user = $this->_login->user;
// 组装更新数据
$data = array(
'audit_state' => $params['audit_state'],
'audit_type' => self::AUDIT_ADMIN,
'audit_uid' => $user['eaId'],
'audit_uname' => $user['eaRealname'],
'audit_time' => MILLI_TIME
);
// 执行数据更新
if (!$this->_circle_serv->update($params['id'], $data)) {
$this->_set_error('_ERR_DATA_SAVE');
return false;
}
// 查询条件
$condition = array('uid' => $c_data['uid']);
// 统计话题数
$total = $this->_count_serv->count_by_conds($condition);
if (empty($total)) {
$this->_count_serv->insert($condition);
}
// 更新话题数
$this->_count_serv->update_by_total($c_data['uid'], CountModel::CIRCLE_TOTAL);
// 此处推送消息给话题发布人
$this->_circle_serv->send_msg_topic_admin($c_data, $params, $user);
return true;
}
/**
* 参数有效性检查
* @param array $params POST 参数
* @return array|bool
*/
public function verification($params = [])
{
// 参数验证
if (empty($params['id'])) {
$this->_set_error('_EMPTY_ID');
return false;
}
if (!is_numeric($params['audit_state'])) {
$this->_set_error('_EMPTY_AUDITSTATE');
return false;
}
// 参数有效性检查
$c_data = $this->_circle_serv->get_by_conds([
'id' => $params['id'],
'type' => Constant::CIRCLE_TOPIC_TYPE
]);
if (empty($c_data)) {
$this->_set_error('_ERR_DATA_EXIST');
return false;
}
// 判断数据原始审核状态
if ($c_data['audit_state'] != self::AUDIT_ING) {
$this->_set_error('_ERR_STATUS_EXIST');
return false;
}
return $c_data;
}
}