sysDictDataModel = $sysDictDataModel; } /** * 列表 * @time 2020年12月18日 16:20 * @param Request $request */ public function index(Request $request) : \think\Response { return CatchResponse::paginate($this->sysDictDataModel->getList()); } /** * 保存信息 * @time 2020年12月18日 16:20 * @param Request $request */ public function save(Request $request) : \think\Response { $params=$request->post(); if ($this->sysDictDataModel->where('code', $params['code'])->where('type_id', $params['type_id'])->find()) { throw new FailedException('唯一编码已存在'); } return CatchResponse::success($this->sysDictDataModel->storeBy($params)); } /** * 读取 * @time 2020年12月18日 16:20 * @param $id */ public function read($id) : \think\Response { return CatchResponse::success($this->sysDictDataModel->findBy($id)); } /** * 更新 * @time 2020年12月18日 16:20 * @param Request $request * @param $id */ public function update(Request $request, $id) : \think\Response { $params=$request->post(); if ($this->sysDictDataModel->where('code', $params['code'])->where('type_id', $params['type_id'])->where('id', '<>',$id)->find()) { throw new FailedException('唯一编码已存在'); } return CatchResponse::success($this->sysDictDataModel->updateBy($id, $params)); } /** * 删除 * @time 2020年12月18日 16:20 * @param $id */ public function delete($id) : \think\Response { return CatchResponse::success($this->sysDictDataModel->deleteBy($id,true)); } /** * 根据Code获取下拉选项 */ public function getOptionsByCode(Request $request) { $params=$request->post(); return CatchResponse::success($this->sysDictDataModel->getTypesByCode($params['type'])); } }