DeleteController.class.php
2.78 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 17/4/11
* Time: 18:24
*/
namespace Apicp\Controller\News;
use Com\PackageValidate;
use Common\Common\AttachOperation;
use Common\Common\DataCenter;
use Common\Common\Constant;
use Common\Common\RpcFavoriteHelper;
use Common\Service\ArticleService;
use Common\Service\TaskService;
use Common\Service\AttachService;
use VcySDK\Service;
use VcySDK\Cron;
class DeleteController extends \Apicp\Controller\AbstractController
{
/**
* Delete
* @author zhonglei
* @desc 删除新闻
* @param Array article_ids:true 新闻ID数组
* @return mixed
*/
public function Index_post()
{
// 验证规则
$rules = [
'article_ids' => 'require|array',
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$postData = $validate->postData;
$article_ids = $postData['article_ids'];
$artServ = new ArticleService();
$list = $artServ->list_by_conds(['article_id' => $article_ids]);
if (empty($list)) {
return true;
}
// 删除首页推送
foreach ($article_ids as $article_id) {
$artServ->delNewsRpc($article_id);
}
// 删除新闻
$artServ->delete_by_conds(['article_id' => $article_ids]);
// 删除新闻附件
$attachServ = new AttachService();
// 从UC附件服务器删除
$attach_serv = new AttachOperation();
$attach_serv->delete_attach(
APP_DIR,
'article',
$article_ids
);
// 删除业务数据库附件
$attachServ->delete_by_conds(['article_id' => $article_ids]);
// 删除应用数据时,RPC同步收藏状态
$rpcFavorite = &RpcFavoriteHelper::instance();
$rpcFavorite->updateStatus($postData['article_ids']);
// 数据中心删除点赞埋点
$dataCenter = &DataCenter::instance();
$dataCenter->delLike($article_ids);
// 数据中心删除点赞埋点
// 数据中心删除评论埋点
$dataCenter->delComment($article_ids);
// 数据中心删除评论埋点
// 数据中心删除点击量埋点
$dataCenter->delClick($article_ids);
// 数据中心删除点击量埋点
$taskServ = new TaskService();
$task_list = $taskServ->list_by_conds(['article_id' => $article_ids]);
if (empty($task_list)) {
return true;
}
$cron_ids = array_filter(array_column($task_list, 'cron_id'));
$cronSdk = new Cron(Service::instance());
// 删除计划任务
foreach ($cron_ids as $cron_id) {
$cronSdk->delete($cron_id);
}
return true;
}
}