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