'integer', 'parent_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'rank' => 'integer', 'status' => 'integer', 'del_flag' => 'integer']; /** * 部门列表 * @param array $account * @param $param * @return array */ static function depts(array $account, $param): array { return self::where('del_flag', 0) ->where('belong_id', $account['belong_id']) ->where('account_type', $account['account_type']) ->when(isset($param['dept_name']) && $param['dept_name'] != "", function ($query) use ($param) { $query->where('dept_name', "like", "%{$param['dept_name']}%"); })->orderByDesc("rank") ->select(["dept_id", "parent_id", "dept_name", "rank", "status", "remark", "create_time"]) ->get()->toArray(); } /** * 添加 * @param array $data * @return bool */ public static function add(array $account, array $data) { $data['account_type'] = $account['account_type']; $data['belong_id'] = $account['belong_id']; $data['create_time'] = date("Y-m-d H:i:s"); $data['del_flag'] = 0; return self::insert($data); } /** * 修改 * Author: cfn * @param array $account * @param array $data * @return int */ public static function edit(array $account, array $data) { $data['update_time'] = date("Y-m-d H:i:s"); return self::where("dept_id", $data['dept_id']) ->where('belong_id', $account['belong_id']) ->where('account_type', $account['account_type']) ->where('del_flag', 0) ->update($data); } /** * 删除 * @param array $account * @param string $ids * @return int */ public static function del(array $account, string $ids) { return self::whereIn('dept_id', explode(",", $ids)) ->where('belong_id', $account['belong_id']) ->where('account_type', $account['account_type']) ->where('del_flag', 0) ->update([ 'update_time' => date('Y-m-d H:i:s'), 'del_flag' => 1 ]); } /** * 选项 * @param array $account * @return array */ public static function options(array $account): array { return self::where('del_flag', 0) ->where('belong_id', $account['belong_id']) ->where('account_type', $account['account_type']) ->orderByDesc("rank") ->select(["dept_id", "parent_id", "dept_name"]) ->get()->toArray(); } }