| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 | 
							- <?php
 
- namespace app\controller;
 
- use app\BaseController;
 
- use app\service\EnterprisesService;
 
- use app\service\UserService;
 
- use app\validate\Id;
 
- use app\validate\Page;
 
- use app\validate\Qydm;
 
- use app\validate\EnterprisesLogin;
 
- use app\validate\UserLogin;
 
- use thans\jwt\facade\JWTAuth;
 
- 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 Enterprises extends BaseController
 
- {
 
-     protected $middleware = [
 
-         'jwt',
 
-     ];
 
-     use ResponseJson;
 
-     /**
 
-      * @Apidoc\Title("企业列表")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("getEnterPrisesList",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getEnterPrisesList(): Json
 
-     {
 
-         $page = $this->request->get();
 
-         try {
 
-             validate(Page::class)->check($page);
 
-         }catch (ValidateException $e){
 
-             $page["page"]=1;
 
-             $page["size"] = 15;
 
-         }
 
-         try {
 
-          return $this->JsonSucess(EnterprisesService::getEnterPrisesList($page, getXzqdmSub()));
 
-         } catch (DataNotFoundException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         } catch (ModelNotFoundException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         } catch (DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("企业信息by ID")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("getEnterPrisesInfo",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getEnterPrisesInfo(): Json
 
-     {
 
-         $id= $this->request->get();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(EnterprisesService::getEnterprisesInfoById($id["id"]));
 
-         } catch (DataNotFoundException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         } catch (ModelNotFoundException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         } catch (DbException $dbE) {
 
-             return $this->JsonError($dbE);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("企业信息by Qydm")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("getEnterPrisesByQydm",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getEnterPrisesByQydm(): Json
 
-     {
 
-         $qydm= $this->request->get();
 
-         try {
 
-             validate(Qydm::class)->check($qydm);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(EnterprisesService::getEnterprisesInfoByQydm(getQydm()));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("监管企业信息by Qydm")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("GET")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("getEnterPrisesByQydmGOV",method="GET")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function getEnterPrisesByQydmGOV(): Json
 
-     {
 
-         $qydm= $this->request->get();
 
-         try {
 
-             validate(Qydm::class)->check($qydm);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(EnterprisesService::getEnterprisesInfoByQydm($qydm["qydm"]));
 
-         } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
 
-             return $this->JsonError($dbE->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("删除企业信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("delEnterPrisesById",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function delEnterPrisesById(): Json
 
-     {
 
-         $id= $this->request->POST();
 
-         try {
 
-             validate(Id::class)->check($id);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(EnterprisesService::delEnterprises($id["id"]));
 
-         } catch (DataNotFoundException $dbE) {
 
-              return $this->JsonError($dbE->getMessage());
 
-         } catch (ModelNotFoundException $dbE) {
 
-            return $this->JsonError($dbE->getMessage());
 
-         } catch (DbException $dbE) {
 
-             return $this->JsonError($dbE->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("更新企业信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("updateEnterPrisesById",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function updateEnterPrisesById(): Json
 
-     {
 
-         $info= $this->request->post();
 
-         try {
 
-             validate(Qydm::class)->check($info);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         try {
 
-             return $this->JsonSucess(EnterprisesService::editEnterprisesInfo($info,$info["id"]));
 
-         } catch (DataNotFoundException $dbE) {
 
-            
 
-             return $this->JsonError($dbE->getMessage());
 
-         } catch (ModelNotFoundException $dbE) {
 
-            
 
-            return $this->JsonError($dbE->getMessage());
 
-         } catch (DbException $dbE) {
 
-              
 
-             return $this->JsonError($dbE->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("添加企业信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("ihavoc")
 
-      * @Route("addEnterPrises",method="POST")
 
-      * @Middleware({"jwt"})
 
-      */
 
-     public function addEnterPrises(): Json
 
-     {
 
-         $info= $this->request->post();
 
-       try {
 
-             validate(\app\validate\Enterprises::class)->check($info);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         if ($info["entity_type"]=="个人"){
 
-             $info["qydm"]=$info["towns"].".".$info["fzr_id_number"];
 
-         }else{
 
-             $info["qydm"]=$info["towns"].".".$info["xydm"];
 
-         }
 
-         return $this->JsonSucess(EnterprisesService::addEnterprises($info));
 
-     }
 
-     /**
 
-      * @Apidoc\Title("企业用户登录接口")
 
-      * @Apidoc\Tag("企业用户登录")
 
-      * @Apidoc\Author("yang")
 
-      * @Apidoc\Method ("POST")
 
-      * @throws ModelNotFoundException
 
-      * @throws DataNotFoundException
 
-      * @throws DbException
 
-      * @Route("enterpriseslogin",method="POST")
 
-      * @Middleware({})
 
-      */
 
-     public function enterpriseslogin():Json{
 
-         $loginInfo =  $this->request->post();
 
-         // dump($loginInfo);die;
 
-         try {
 
-             validate(EnterprisesLogin::class)->check($loginInfo);
 
-         }catch (ValidateException $e){
 
-             return $this->JsonError($e->getError(),0);
 
-         }
 
-         $userInfo=EnterprisesService::selectLoginInfo($loginInfo);
 
-         if ($userInfo){
 
-             $token = JWTAuth::builder(['qydm' => $userInfo["qydm"]]);//参数为用户认证的信息,请自行添加
 
-             return $this->JsonSucess(["token"=>$token,"userInfo"=>$userInfo],1);
 
-         }else{
 
-             return $this->JsonError(1002);
 
-         }
 
-     }
 
-     /**
 
-      * @Apidoc\Title("注册企业信息")
 
-      * @Apidoc\Tag("企业")
 
-      * @Apidoc\Method ("POST")
 
-      * @Apidoc\Author ("yang")
 
-      * @Route("registerEnterPrises",method="POST")
 
-      * @Middleware({})
 
-      */
 
-     public function registerEnterPrises(): Json
 
-     {
 
-         $info= $this->request->post();
 
-         try {
 
-             validate(\app\validate\Enterprises::class)->check($info);
 
-         }catch (ValidateException $e){
 
-             $this->JsonError($e->getError());
 
-         }
 
-         if ($info["entity_type"]=="个人"){
 
-             $info["qydm"]=$info["towns"].".".$info["fzr_id_number"];
 
-         }else{
 
-             $info["qydm"]=$info["towns"].".".$info["xydm"];
 
-         }
 
-         $info['creation_time']   = date('Y-m-d h:i:s', time());
 
-         return $this->JsonSucess(EnterprisesService::addEnterprises($info));
 
-     }
 
- }
 
 
  |