<?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; } }