get(); $user = (new Auth)->guard("user")->user()->toArray(); $param['uid'] = $user['uid']; $list = $this->service->getLst($param,'id,task_id,uid,status,created_at',$param['page']??0,$param['limit']??0); return successTrans("success.data",$list,200); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[Route(path: "create",methods: "post")] public function create(Request $request): Response { try { $id = $request->post('id',0); $user = (new Auth)->guard("user")->user()->toArray(); $state = $this->service->createOrder($id,$user); if (!$state) return errorTrans("error.data"); return successTrans("任务领取成功",['id'=>$state->id]); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 提交 * @param Request $request * @return Response */ #[Route(path: "submit",methods: "post")] public function submit(Request $request): Response { try { $user = (new Auth)->guard("user")->user()->toArray(); $param = $request->post(); $state = $this->service->submit($param,$user); if (!$state) return errorTrans("error.data"); return successTrans("提交成功"); } catch (\Throwable $throwable) { echo $throwable->getMessage()."\n"; echo $throwable->getFile()."\n"; echo $throwable->getLine()."\n"; return error($throwable->getMessage()); } } /** * 删除 * @param Request $request * @return Response */ #[Route(path: "del/{id}",methods: "delete")] public function delUser($id): Response { try { $state = $this->service->saveData(['id'=>$id,'is_del'=>1]); if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 设置状态 * @param Request $request * @return Response */ #[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("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }