| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 | 
							- <?php
 
- namespace app\controller;
 
- use app\BaseController;
 
- use app\service\GridService;
 
- use app\validate\GridAdd;
 
- use app\validate\Id;
 
- use app\validate\Page;
 
- use think\db\exception\DataNotFoundException;
 
- use think\db\exception\DbException;
 
- use think\db\exception\ModelNotFoundException;
 
- use think\exception\ValidateException;
 
- use think\response\Json;
 
- use think\annotation\Route;
 
- use think\annotation\route\Middleware;
 
- use hg\apidoc\annotation as Apidoc;
 
- /**
 
-  * @Apidoc\Title("网格点信息")
 
-  * @Apidoc\Group("grid")
 
-  * @Apidoc\Sort(6)
 
-  */
 
- class Grid extends BaseController
 
- {
 
-     use ResponseJson;
 
-     //新增方法
 
-     /**
 
-      * @Apidoc\Author("ruicu")
 
-      * @throws ModelNotFoundException
 
-      * @throws DataNotFoundException
 
-      * @throws DbException
 
-      * @Apidoc\Title("添加网格点")
 
-      * @Apidoc\Tag("添加网格点")
 
-      * @Apidoc\Method ("POST")
 
-      * @Route("/addgrid",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function addGrid(): Json
 
-     {
 
-         $gridInfo =  $this->request->post();
 
-         try {
 
-             validate(GridAdd::class)->check($gridInfo);
 
-             $gridInfo['creation_time']   = date('Y-m-d h:i:s', time());
 
-             $result = GridService::addGrid($gridInfo);
 
-             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("/delgrid",method="Post")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     //删除
 
-     public function del(): Json{
 
-         $id=$this->request->post();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-             $result = GridService::delGrid($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("/editgrid",method="Get")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     //修改
 
-     public function updateGridById(): Json
 
-     {
 
-         $info= $this->request->get();
 
-         try {
 
-             validate(Id::class)->check($info);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(GridService::editGridInfo($info,$info["id"]));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Author("ruicu")
 
-      * @throws ModelNotFoundException
 
-      * @throws DataNotFoundException
 
-      * @throws DbException
 
-      * @Apidoc\Title("查询网格点信息")
 
-      * @Apidoc\Tag("查询网格点信息")
 
-      * @Apidoc\Method ("Get")
 
-      * @Route("/infogrid",method="Get")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     //查询
 
-     public function getGridList(): Json
 
-     {
 
-         $page = $this->request->get();
 
-         try {
 
-             validate(Page::class)->check($page);
 
-         }catch (ValidateException $e){
 
-             $page["page"]=1;
 
-             $page["size"] = 15;
 
-         }
 
-         try {
 
-             return $this->JsonSucess(GridService::getGridList($page, getXzqdmSub()));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
- }
 
 
  |