Index.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\model\Ry;
  5. use app\service\NszyService;
  6. use app\service\QyBasicService;
  7. use app\service\RyService;
  8. use think\db\exception\DataNotFoundException;
  9. use think\db\exception\DbException;
  10. use think\db\exception\ModelNotFoundException;
  11. use think\response\Json;
  12. use think\annotation\Route;
  13. use think\annotation\route\Middleware;
  14. use thans\jwt\facade\JWTAuth;
  15. class Index extends BaseController
  16. {
  17. protected $middleware = [
  18. 'jwt' => ['except' => ['login'] ],
  19. ];
  20. use ResponseJson;
  21. public function index()
  22. {
  23. 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>';
  24. }
  25. public function hello($name = 'ThinkPHP6')
  26. {
  27. return 'hello,' . $name;
  28. }
  29. /**
  30. * @throws ModelNotFoundException
  31. * @throws DataNotFoundException
  32. * @throws DbException
  33. * @Route("login")
  34. * @Middleware({})
  35. */
  36. public function login():Json{
  37. $loginInfo = $this->request->get();
  38. $userInfo=RyService::selectLoginInfo($loginInfo);
  39. if ($userInfo){
  40. $token = JWTAuth::builder(['qydm' => $userInfo["qydm"]]);//参数为用户认证的信息,请自行添加
  41. return $this->JsonSucess(["token"=>$token,"userInfo"=>$userInfo],1001);
  42. }else{
  43. return $this->JsonError(1002);
  44. }
  45. }
  46. /**
  47. * @throws ModelNotFoundException
  48. * @throws DataNotFoundException
  49. * @throws DbException
  50. * @Route("/getQyBasicList")
  51. * @Middleware({"jwt"})
  52. */
  53. public function getQyBasicList(): Json
  54. {
  55. getQydm();
  56. return $this->JsonSucess(QyBasicService::selectQyBasic());
  57. }
  58. /**
  59. * @throws ModelNotFoundException
  60. * @throws DataNotFoundException
  61. * @throws DbException
  62. * @Route("getNszyByQydm")
  63. * @Middleware({"jwt"})
  64. */
  65. public function getNszyByQydm():Json{
  66. return $this->JsonSucess(NszyService::selectNszyByQydm(getQydm()));
  67. }
  68. }