Index.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\model\Ry;
  5. use app\model\ZdCpmc;
  6. use app\service\NszyService;
  7. use app\service\QyBasicService;
  8. use app\service\RyService;
  9. use app\service\ZdCpmcService;
  10. use think\db\exception\DataNotFoundException;
  11. use think\db\exception\DbException;
  12. use think\db\exception\ModelNotFoundException;
  13. use think\response\Json;
  14. use think\annotation\Route;
  15. use think\annotation\route\Middleware;
  16. use thans\jwt\facade\JWTAuth;
  17. class Index extends BaseController
  18. {
  19. protected $middleware = [
  20. 'jwt' => ['except' => ['login'] ],
  21. ];
  22. use ResponseJson;
  23. public function index()
  24. {
  25. return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">16载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
  26. }
  27. public function hello($name = 'ThinkPHP6')
  28. {
  29. return 'hello,' . $name;
  30. }
  31. /**
  32. * @throws ModelNotFoundException
  33. * @throws DataNotFoundException
  34. * @throws DbException
  35. * @Route("login")
  36. * @Middleware({})
  37. */
  38. public function login():Json{
  39. $loginInfo = $this->request->get();
  40. $userInfo=RyService::selectLoginInfo($loginInfo);
  41. if ($userInfo){
  42. $token = JWTAuth::builder(['qydm' => $userInfo["qydm"]]);//参数为用户认证的信息,请自行添加
  43. return $this->JsonSucess(["token"=>$token,"userInfo"=>$userInfo],1001);
  44. }else{
  45. return $this->JsonError(1002);
  46. }
  47. }
  48. /**
  49. * @throws ModelNotFoundException
  50. * @throws DataNotFoundException
  51. * @throws DbException
  52. * @Route("/getQyBasicList")
  53. * @Middleware({"jwt"})
  54. */
  55. public function getQyBasicList(): Json
  56. {
  57. getQydm();
  58. return $this->JsonSucess(QyBasicService::selectQyBasic());
  59. }
  60. /**
  61. * @throws ModelNotFoundException
  62. * @throws DataNotFoundException
  63. * @throws DbException
  64. * @Route("getNszyByQydm")
  65. * @Middleware({"jwt"})
  66. */
  67. public function getNszyByQydm():Json{
  68. return $this->JsonSucess(NszyService::selectNszyByQydm(getQydm()));
  69. }
  70. /**
  71. * @throws ModelNotFoundException
  72. * @throws DataNotFoundException
  73. * @throws DbException
  74. * @Route("getJiangdou")
  75. *
  76. */
  77. public function getJiangdou(){
  78. return json(ZdCpmcService::getQydmBycpmc());
  79. }
  80. }