DeleteController.class.php
1.29 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
/**
* 【手机端】16-删除照片墙接口
* Created by PhpStorm.
* @author:houyingcai
* @date:2017-09-25
*/
namespace Api\Controller\Pic;
use Common\Common\AttachOperation;
use Common\Model\CommonModel;
use Common\Service\PlanPicService;
class DeleteController extends \Api\Controller\AbstractController
{
public function Index_get()
{
$pic_id = I('pic_id', 0, 'rintval');
// 照片ID不能为空
if (!$pic_id) {
E('_EMPTY_PIC_ID');
}
// 实例化照片表
$pic_service = new PlanPicService();
// 获取照片信息
$plan_pic = $pic_service->get($pic_id);
// 照片不存在
if (empty($plan_pic)) {
E('_EMPTY_PIC');
}
// 不能删除别人的照片
if ($plan_pic['pic_uid'] != $this->uid) {
E('_ERR_PIC_NOT_SELF');
}
// 删除照片
$pic_service->delete($pic_id);
// 删除附件使用表的数据
$model = new CommonModel('AttachUselog', 'oa_common_');
$model->delete_by_conds(['at_id' => $plan_pic['pic_at_id']]);
// 删除UC服务器附件操作
$attach_serv = new AttachOperation();
$attach_serv->deleteFile([$plan_pic['pic_at_id']]);
return true;
}
}