CheckUsingController.class.php
1.17 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
<?php
/**
* Created by PhpStorm.
* 检测培训对象是否被培训占用
* User: xtong
* Date: 2017年09月06日01:19:47
*/
namespace Rpc\Controller\Plan;
use Common\Common\Constant;
use Common\Service\PlanService;
class CheckUsingController extends AbstractController
{
public function index($objIds, $app)
{
// 获取应用对应的类型
$type = Constant::PLAN_TYPES[strtolower($app)];
// 不存在的应用
if (empty($type)) {
\Think\Log::record('应用名称不合法:' . $app);
return true;
}
$objIds = is_array($objIds) ? array_values($objIds) : $objIds;
// 查询条件
$condition = [
'plan_obj_id' => $objIds,
'plan_type' => $type
];
\Think\Log::record('搜索条件:' . var_export($condition, true));
$plan_service = new PlanService();
// 查询使用列表
$list = $plan_service->list_by_conds($condition);
$result = [];
if (!empty($list)) {
$result = array_unique(array_filter(array_column($list, 'plan_obj_id')));
sort($result);
}
return $result;
}
}