LoginController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller;
  15. use app\adminapi\logic\LoginLogic;
  16. use app\adminapi\validate\LoginValidate;
  17. /**
  18. * 管理员登录控制器
  19. * Class LoginController
  20. * @package app\adminapi\controller
  21. */
  22. class LoginController extends BaseAdminController
  23. {
  24. public array $notNeedLogin = ['account'];
  25. /**
  26. * @notes 账号登录
  27. * @date 2021/6/30 17:01
  28. * @return \think\response\Json
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @author 令狐冲
  33. */
  34. public function account()
  35. {
  36. $params = (new LoginValidate())->post()->goCheck();
  37. return $this->data((new LoginLogic())->login($params));
  38. }
  39. /**
  40. * @notes 退出登录
  41. * @return \think\response\Json
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @author 令狐冲
  46. * @date 2021/7/8 00:36
  47. */
  48. public function logout()
  49. {
  50. //退出登录情况特殊,只有成功的情况,也不需要token验证
  51. (new LoginLogic())->logout($this->adminInfo);
  52. return $this->success();
  53. }
  54. }