LoginController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller\login;
  3. use app\api\controller\ZskkDefaultController;
  4. use app\api\validate\login\LoginValidate;
  5. use app\api\servies\login\LoginService;
  6. use think\Exception;
  7. //use app\api\validate\test\LoginValidate;
  8. class LoginController extends ZskkDefaultController
  9. {
  10. protected $needToken = false;
  11. protected $logName = "LoginController";
  12. /**
  13. * 用户登录接口
  14. * @author liuguiyan LoginService $service
  15. */
  16. public function login(LoginService $service)
  17. {
  18. $params = $this->getParams();
  19. LoginValidate::check($params);
  20. $user = $service->login($params);
  21. return $this->success($user);
  22. }
  23. public function send_message_again(LoginService $service)
  24. {
  25. $params = $this->getParams();
  26. LoginValidate::checkPhone($params);
  27. $user = $service->send_message_again($params);
  28. return $this->success($user);
  29. }
  30. public function check_code(LoginService $service)
  31. {
  32. $params = $this->getParams();
  33. LoginValidate::checkCode($params);
  34. $user = $service->check_code($params);
  35. return $this->success($user);
  36. }
  37. public function loginOut(LoginService $service)
  38. {
  39. try{
  40. $user = $service->logout($this->getToken());
  41. return $this->success($user);
  42. } catch (Exception $exception){
  43. $this->throwError('系统异常',0001);
  44. }
  45. }
  46. public function out(LoginService $service)
  47. {
  48. try{
  49. $params = $this->getParams();
  50. $data = $service->out($params['session']);
  51. return $this->success($data);
  52. } catch (Exception $exception){
  53. $this->throwError('系统异常',0001);
  54. }
  55. }
  56. }