UserController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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\api\controller;
  15. use app\api\logic\UserAddressLogic;
  16. use app\api\logic\UserLogic;
  17. use app\api\validate\PasswordValidate;
  18. use app\api\validate\SetUserInfoValidate;
  19. use app\api\validate\UserValidate;
  20. /**
  21. * 用户控制器
  22. * Class UserController
  23. * @package app\api\controller
  24. */
  25. class UserController extends BaseApiController
  26. {
  27. public array $notNeedLogin = ['resetPassword'];
  28. /**
  29. * @notes 获取个人中心
  30. * @return \think\response\Json
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. * @author 段誉
  35. * @date 2022/9/16 18:19
  36. */
  37. public function center()
  38. {
  39. $data = UserLogic::center($this->userInfo);
  40. return $this->success('', $data);
  41. }
  42. /**
  43. * @notes 获取个人信息
  44. * @return \think\response\Json
  45. * @author 段誉
  46. * @date 2022/9/20 19:46
  47. */
  48. public function info()
  49. {
  50. $result = UserLogic::info($this->userId);
  51. return $this->data($result);
  52. }
  53. /**
  54. * @notes 重置密码
  55. * @return \think\response\Json
  56. * @author 段誉
  57. * @date 2022/9/16 18:06
  58. */
  59. public function resetPassword()
  60. {
  61. $params = (new PasswordValidate())->post()->goCheck('resetPassword');
  62. $result = UserLogic::resetPassword($params);
  63. if (true === $result) {
  64. return $this->success('操作成功', [], 1, 1);
  65. }
  66. return $this->fail(UserLogic::getError());
  67. }
  68. /**
  69. * @notes 修改密码
  70. * @return \think\response\Json
  71. * @author 段誉
  72. * @date 2022/9/20 19:16
  73. */
  74. public function changePassword()
  75. {
  76. $params = (new PasswordValidate())->post()->goCheck('changePassword');
  77. $result = UserLogic::changePassword($params, $this->userId);
  78. if (true === $result) {
  79. return $this->success('操作成功', [], 1, 1);
  80. }
  81. return $this->fail(UserLogic::getError());
  82. }
  83. /**
  84. * @notes 获取小程序手机号
  85. * @return \think\response\Json
  86. * @author 段誉
  87. * @date 2022/9/21 16:46
  88. */
  89. public function getMobileByMnp()
  90. {
  91. $params = (new UserValidate())->post()->goCheck('getMobileByMnp');
  92. $params['user_id'] = $this->userId;
  93. $result = UserLogic::getMobileByMnp($params);
  94. if ($result === false) {
  95. return $this->fail(UserLogic::getError());
  96. }
  97. return $this->success('绑定成功', [], 1, 1);
  98. }
  99. /**
  100. * @notes 编辑用户信息
  101. * @return \think\response\Json
  102. * @author 段誉
  103. * @date 2022/9/21 17:01
  104. */
  105. public function setInfo()
  106. {
  107. $params = (new SetUserInfoValidate())->post()->goCheck(null, ['id' => $this->userId]);
  108. $result = UserLogic::setInfo($this->userId, $params);
  109. if (false === $result) {
  110. return $this->fail(UserLogic::getError());
  111. }
  112. return $this->success('操作成功', [], 1, 1);
  113. }
  114. /**
  115. * @notes 绑定/变更 手机号
  116. * @return \think\response\Json
  117. * @author 段誉
  118. * @date 2022/9/21 17:29
  119. */
  120. public function bindMobile()
  121. {
  122. $params = (new UserValidate())->post()->goCheck('bindMobile');
  123. $params['user_id'] = $this->userId;
  124. $result = UserLogic::bindMobile($params);
  125. if($result) {
  126. return $this->success('绑定成功', [], 1, 1);
  127. }
  128. return $this->fail(UserLogic::getError());
  129. }
  130. public function saveFirmInfo()
  131. {
  132. $params = (new UserValidate())->post()->goCheck();
  133. }
  134. }