DeleteController.class.php
1006 Bytes
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
<?php
/**
* 【后台】删除分类接口
* DeleteController.class.php
* @author:daijun
* @date:2017-08-31
*/
namespace Apicp\Controller\Category;
use Common\Service\CategoryService;
use Common\Service\EducationService;
class DeleteController extends \Apicp\Controller\AbstractController
{
/**
* 删除分类接口
* @author daijun
*/
public function Index_post()
{
// 获取参数
$ca_id = I('post.ca_id', 0, 'intval');
if (empty($ca_id)) {
E('_EMPTY_CATEGORY_ID');
}
$education_service = new EducationService();
// 查询分类下是否有培训
$edu_num = $education_service->count_by_conds(['ca_id' => $ca_id]);
if ($edu_num > 0) {
// 如果分类下存在培训,则不能删
E('_ERR_CATEGORY_DELETE');
}
$cate_service = new CategoryService();
// 删除分类
$cate_service->delete($ca_id);
return true;
}
}