service = DepartmentService::getInstance(); // insertField / updateField 既是必填校验清单,也是入库字段白名单,漏写的字段不会被收进 params $this->insertField = ['name']; $this->updateField = ['id', 'name']; // 这几个允许缺省:pid 缺省为顶级,status 缺省为正常 $this->notRequest = ['pid', 'desc', 'status', 'color']; } /** * 部门树下拉(表单选上级部门用) * @Method GET */ public function treeOption(): JsonResponse { $isSelect = filter_var(request()->get('is_select', false), FILTER_VALIDATE_BOOLEAN); return jok($this->service->getTreeOption($isSelect), '列表获取成功'); } /** * 停用 / 启用部门 * @Method POST * @throws Exception */ public function status(): JsonResponse { $id = request()->post('id'); $status = request()->post('status'); if (empty($id) || !in_array((string) $status, ['0', '1'], true)) { return jerr('参数错误'); } return jok($this->service->status($id, $status), '操作成功'); } }