EditController.class.php
1.31 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
<?php
/**
* 【后台】编辑照片接口
* EditConTroller.class.php
* User: caijianhua
* Date: 2017/8/29
* Time: 下午5:15
*/
namespace Apicp\Controller\Pic;
use Common\Service\PlanPicService;
class EditController extends \Apicp\Controller\AbstractController
{
/** @var PlanPicService 照片表 */
protected $plan_pic_service;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
$this->plan_pic_service = new PlanPicService();
return true;
}
/**
* 【后台】编辑照片接口
*
* @author 蔡建华
*/
public function Index_post()
{
$pic_id = I('post.pic_id');
$pic_name = I('post.pic_name');
if (empty($pic_id)) {
// 图片ID不能为空
E('_EMPTY_PIC_ID');
}
if (empty($pic_name)) {
// 图片名称不能为空
E('_EMPTY_PIC_NAME');
}
if (strlen($pic_name) > PlanPicService::PIC_NAME_MAX_LENGTH) {
// 图片名称过长
E('_ERR_PIC_LENGTH');
}
// 保存编辑
$this->plan_pic_service->update_by_conds(
['pic_id' => $pic_id],
['pic_name' => $pic_name]
);
return true;
}
}