get(); $param['is_del'] = 0; $list = $this->service->getList($param,'*',$param['page']??0,$param['limit']??0); return successTrans("success.data",$list); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[Route(path: "info/{id}",methods: "get")] public function info($id): Response { try { $info = $this->service->getOne(['id'=>$id]); if ($info->isEmpty()) return errorTrans("empty.error"); return successTrans("success.data",$info->toArray()); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[Route(path: "save",methods: "post")] public function save(Request $request): Response { try { $param = $request->post(); if (!$this->validate->check($param)) return error($this->validate->getError()); $param = $this->validate->checked($param); if(!empty($param['id'])){ $id = $param['id']; unset($param['id']); $state = $this->service->update($id,$param); }else{ $state = $this->service->save($param); } if (!$state) return errorTrans("empty.error"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[Route(path: "set_status/{id}/{status}",methods: "get")] public function set_status($id,$status): Response { try { $state = $this->service->update($id,['status'=>$status]); if (!$state) return errorTrans("empty.error"); return successTrans($status?'显示成功':'关闭成功'); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[Route(path: "del/{id}",methods: "delete")] public function delete($id): Response { try { $state = $this->service->update($id,['is_del'=>1]); if (!$state) return errorTrans("empty.error"); return successTrans('删除成功'); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }