| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 | 
							- <?php
 
- namespace app\controller;
 
- use app\BaseController;
 
- use app\service\InputService;
 
- use app\validate\getListByqydm;
 
- use app\validate\Id;
 
- use app\validate\InputAdd;
 
- use app\validate\Page;
 
- use app\validate\Qydm;
 
- 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("企业")
 
-  * @Apidoc\Sort (3)
 
-  */
 
- class Input extends BaseController
 
- {
 
-     protected $middleware = [
 
-         'jwt',
 
-     ];
 
-     use ResponseJson;
 
-     /**
 
-      * @Apidoc\Title("投入品列表")
 
-      * @Apidoc\Tag("投入品")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("yang")
 
-      * @Route("getInputList",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getInputList():Json{
 
-         $page = $this->request->get();
 
-         try {
 
-             validate(Page::class)->check($page);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError());
 
-         }
 
-         return $this->JsonSucess(InputService::getInputList($page,getQydm()));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("投入品信息by ID")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("yang")
 
-      * @Route("getInputInfo",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getInputInfoById(): json
 
-     {
 
-         $id = $this->request->get();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError());
 
-         }
 
-         return $this->JsonSucess(InputService::getInputById($id["id"]));
 
-     }
 
-     
 
-     /**
 
-      * @Apidoc\Title("删除投入品信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("wangzhen")
 
-      * @Route("delInputById",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function delInputById():json{
 
-         $id= $this->request->POST();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(InputService::delInputById($id["id"]));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("更新投入品信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("yang")
 
-      * @Route("updateInputById",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function updataInputById():json{
 
-         $info= $this->request->POST();
 
-         try {
 
-             validate(Id::class)->check($info);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(InputService::eidtInputInfo($info,$info["id"]));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("添加投入品信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("yang")
 
-      * @Route("addInput",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function addInput():json{
 
-         $data =  $this->request->post();
 
-         try {
 
-             validate(InputAdd::class)->check($data);
 
-             $data['creation_time']   = date('Y-m-d h:i:s', time());
 
-             $result = InputService::addInput($data);
 
-             if (!$result){
 
-                 return $this->JsonError(1002);
 
-             }
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError(),0);
 
-         }
 
-         return  $this->JsonResponse(1,"success","");
 
-     }
 
- }
 
 
  |