['except' => ['login'] ], ]; use ResponseJson; /** * @Apidoc\Title("基础的接口演示") * @Apidoc\Tag("基础,示例") * @Apidoc\Method ("GET") * @Route("/") * @Middleware({}) */ public function index() { return $this->JsonSucess(["info"=>"这是后端接口"]); } public function hello($name = 'ThinkPHP6') { return 'hello,' . $name; } /** * @Apidoc\Title("登录接口") * @Apidoc\Tag("用户登录") * @Apidoc\Method ("GET") * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Route("login") * @Middleware({}) */ public function login():Json{ $loginInfo = $this->request->get(); try { validate(UserLogin::class)->check($loginInfo); }catch (ValidateException $e){ return $this->JsonError($e->getError(),0); } $userInfo=RyService::selectLoginInfo($loginInfo); if ($userInfo){ $token = JWTAuth::builder(['qydm' => $userInfo["qydm"]]);//参数为用户认证的信息,请自行添加 return $this->JsonSucess(["token"=>$token,"userInfo"=>$userInfo],1001); }else{ return $this->JsonError(1002); } } /** * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Route("/getQyBasicList") * @Middleware({"jwt"}) */ public function getQyBasicList(): Json { getQydm(); return $this->JsonSucess(QyBasicService::selectQyBasic()); } /** * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Route("getNszyByQydm") * @Middleware({"jwt"}) */ public function getNszyByQydm():Json{ return $this->JsonSucess(NszyService::selectNszyByQydm(getQydm())); } /** * @throws ModelNotFoundException * @throws DataNotFoundException * @throws DbException * @Route("getJiangdou") * */ public function getJiangdou(){ return json(ZdCpmcService::getQydmBycpmc()); } }