request->post(); try { validate(Statistic::class)->check($info); $info['creation_time'] = date('Y-m-d h:i:s', time()); $result = StatsticsService::addStatistic($info); if (!$result){ return $this->JsonError(1002); } }catch (ValidateException $e){ return $this->JsonError($e->getError(),0); } return $this->JsonResponse(200,"success",""); } /** * @Apidoc\Author("ruicu") * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Apidoc\Title("删除基地统计信息") * @Apidoc\Tag("基地统计信息") * @Apidoc\Method ("Post") * @Route("/delstatic",method="Post") * @Middleware({"jwt"}) */ //删除 public function del(): Json{ $id=$this->request->post(); try { validate(Id::class)->check($id); $result = StatsticsService::delStatistic($id); if (!$result){ return $this->JsonError(1002); } }catch (ValidateException $e){ return $this->JsonError($e->getError(),0); } return $this->JsonResponse(200,"success",""); } /** * @Apidoc\Author("ruicu") * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Apidoc\Title("修改基地统计信息") * @Apidoc\Tag("修改基地统计信息") * @Apidoc\Method ("Get") * @Route("/editstatic",method="Get") * @Middleware({"jwt"}) */ //修改 public function updateStaticById(): Json { $info= $this->request->get(); try { validate(Id::class)->check($info); }catch (ValidateException $e){ $this->JsonError($e->getError()); } try { return $this->JsonSucess(StatsticsService::editStatisticInfo($info,$info["id"])); } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) { return $this->JsonError($dbE); } } }