UserController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\openapi\controller;
  20. use app\adminapi\logic\toutiao\ToutiaoSettingLogic;
  21. use app\openapi\logic\user\UserLogic;
  22. use app\openapi\validate\UserValidate;
  23. /**
  24. * 用户接口示例
  25. * Class UserController
  26. * @package app\openapi\controller
  27. */
  28. class UserController extends BaseOpenController
  29. {
  30. /**
  31. * 获取用户信息
  32. * @return \think\response\Json
  33. */
  34. public function info()
  35. {
  36. $params = (new UserValidate())->post()->goCheckStrict('info');
  37. // 模拟用户数据
  38. $userData = [
  39. 'user_id' => $params['user_id'],
  40. 'nickname' => '测试用户',
  41. 'avatar' => 'https://example.com/avatar.jpg',
  42. 'mobile' => '138****8888',
  43. 'created_time' => date('Y-m-d H:i:s'),
  44. ];
  45. return $this->success('获取成功', $userData);
  46. }
  47. /*
  48. * 查询会员信息
  49. * */
  50. public function getUserInfo(){
  51. $params = (new UserValidate())->get()->goCheckStrict('getUserInfo');
  52. $detail = (new UserLogic)->detail($params['mobile']);
  53. return $this->success('获取成功', $detail);
  54. }
  55. /*
  56. * 查询会员信息
  57. * */
  58. public function addUser(){
  59. $params = (new UserValidate())->post()->goCheckStrict('addUser');
  60. $result = (new UserLogic)->addUserInfo($params);
  61. if ($result) {
  62. return $this->success('新增会员成功', [],1,1);
  63. }
  64. return $this->fail(UserLogic::getError());
  65. }
  66. /*
  67. * 更新会员信息
  68. * */
  69. public function updateUserInfo(){
  70. $params = (new UserValidate())->post()->goCheckStrict('updateUserInfo');
  71. $result = (new UserLogic)->updateUserInfo($params);
  72. if ($result) {
  73. return $this->success('编辑会员成功', [],1,1);
  74. }
  75. return $this->fail(UserLogic::getError());
  76. }
  77. /*
  78. * 会员充值
  79. * */
  80. public function userRecharge(){
  81. $params = (new UserValidate())->post()->goCheckStrict('userRecharge');
  82. $result = (new UserLogic)->userRecharge($params);
  83. if ($result) {
  84. return $this->success('会员充值同步成功', [],1,1);
  85. }
  86. return $this->fail(UserLogic::getError());
  87. }
  88. /**
  89. * 更新用户信息
  90. * @return \think\response\Json
  91. */
  92. public function update()
  93. {
  94. $params = (new UserValidate())->post()->goCheckStrict('update');
  95. // 这里处理更新逻辑
  96. // ...
  97. return $this->success('更新成功');
  98. }
  99. }