DeleteController.class.php
1.24 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
/**
* 【积分抽奖-后台】删除活动接口
* User: yingcai
* Date: 2018/3/23
* Time: 下午3:40
*/
namespace Apicp\Controller\Activity;
use Common\Common\AttachOperation;
use Common\Service\ActivityService;
use Common\Service\RightService;
use Think\Exception;
class DeleteController extends \Apicp\Controller\AbstractController
{
public function Index_post()
{
$activity_service = new ActivityService();
$ids = I('post.ac_ids');
if (empty($ids) || !is_array($ids)) {
E('_EMPTY_ACTIVITY_ID');
}
$right_service = new RightService();
$conds = array('ac_id' => $ids);
try {
// 删除开始
$activity_service->start_trans();
// 删除活动
$activity_service->delete($ids);
// 删除权限
$right_service->delete_by_conds($conds);
// 提交修改
$activity_service->commit();
} catch (Exception $e) {
$activity_service->rollback();
E('_ERR_DELETE_FAILED');
}
// 删除附件操作
$attach_serv = new AttachOperation();
$attach_serv->delete_attach(APP_DIR, 'activity', $ids);
return true;
}
}