| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 | 
							- <?php
 
- namespace app\controller;
 
- use app\BaseController;
 
- use app\validate\EditProduct;
 
- use app\validate\Id;
 
- use app\validate\Page;
 
- use app\service\ProductService;
 
- 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 (6)
 
-  */
 
- class Product extends BaseController
 
- {
 
-     protected $middleware = [
 
-         'jwt',
 
-     ];
 
-     use ResponseJson;
 
-     /**
 
-      * @Apidoc\Title("产品列表")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("getProductList",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getProductList(): Json
 
-     {
 
-         $page = $this->request->get();
 
-         try {
 
-             validate(Page::class)->check($page);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError());
 
-         }
 
-         return $this->JsonSucess(ProductService::getProductList($page,getQydm()));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("产品列表")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("getProductListGOV",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getProductListGOV(): Json
 
-     {
 
-         $page = $this->request->get();
 
-         try {
 
-             validate(Page::class)->check($page);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError());
 
-         }
 
-         return $this->JsonSucess(ProductService::getProductList($page,$page["qydm"]));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("产品信息ByID")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("getProductInfo",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getProductInfo(): Json
 
-     {
 
-         $id = $this->request->get();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError());
 
-         }
 
-         return $this->JsonSucess(ProductService::getProductInfoById($id["id"]));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("添加产品信息")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("addProduct",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function addProduct(): Json
 
-     {
 
-         $info = $this->request->post();
 
-         try {
 
-             validate(\app\validate\Product::class)->check($info);
 
-         } catch (ValidateException $e) {
 
-             $this->JsonError($e->getError());
 
-         }
 
-             return $this->JsonSucess(ProductService::addProduct($info));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("更新产品信息")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("editProduct",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function editProduct(): Json
 
-     {
 
-         $info = $this->request->post();
 
-         try {
 
-             validate(EditProduct::class)->check($info);
 
-         } catch (ValidateException $e) {
 
-             $this->JsonError($e->getError());
 
-         }
 
-        return $this->JsonSucess(ProductService::editProduct($info,$info["id"]));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("删除产品信息")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("刘庆")
 
-      * @Route("delProduct",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function delProduct(): Json
 
-     {
 
-         $id = $this->request->post();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         } catch (ValidateException $e) {
 
-             $this->JsonError($e->getError());
 
-         }
 
-        return $this->JsonSucess(ProductService::delProduct($id["id"]));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("获取产品列表包含批次号")
 
-      * @Apidoc\Tag("产品")
 
-      * @Apidoc\Method ("get")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("getProductListIsPch",method="get")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getProductListIsPch(): Json
 
-     {
 
-         return $this->JsonSucess(ProductService::getProductListIsPch(getQydm()));
 
-     }
 
- }
 
 
  |