UserController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace App\Http\Controllers\Client;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\Client\UserService;
  5. use Illuminate\Http\Request;
  6. /**
  7. * @group 用户端
  8. *
  9. * 用户相关的API接口
  10. */
  11. class UserController extends Controller
  12. {
  13. protected UserService $service;
  14. public function __construct(UserService $service)
  15. {
  16. $this->service = $service;
  17. }
  18. /**
  19. * [用户]获取用户信息
  20. *
  21. * 获取当前用户的信息
  22. *
  23. * @authenticated
  24. *
  25. * @response {
  26. * "code": 200,
  27. * "message": "获取成功",
  28. * "data": {
  29. * "id": 1,
  30. * "mobile": "13800138000",
  31. * "nickname": "用户昵称"
  32. * }
  33. * }
  34. */
  35. public function show()
  36. {
  37. return $this->service->getUserInfo();
  38. }
  39. /**
  40. * [用户]修改用户信息
  41. *
  42. * 修改当前用户的信息
  43. *
  44. * @authenticated
  45. *
  46. * @bodyParam nickname string 用户昵称. Example: 用户昵称
  47. * @bodyParam avatar string 用户头像. Example: https://example.com/avatar.jpg
  48. *
  49. * @response {
  50. * "code": 200,
  51. * "message": "修改成功",
  52. * "data": null
  53. * }
  54. */
  55. public function update(Request $request)
  56. {
  57. $data = $request->all();
  58. $result = $this->service->updateUserInfo($data);
  59. return $result;
  60. }
  61. /**
  62. * [用户]用户反馈
  63. *
  64. * 提交用户的反馈信息
  65. *
  66. * @authenticated
  67. *
  68. * @bodyParam content string 反馈内容. Example: 这是一个反馈信息
  69. *
  70. * @response {
  71. * "code": 200,
  72. * "message": "提交成功",
  73. * "data": null
  74. * }
  75. */
  76. public function feedback(Request $request)
  77. {
  78. $content = $request->input('content');
  79. $result = $this->service->feedback($content);
  80. return $result;
  81. }
  82. /**
  83. * [用户]申请成为技师
  84. *
  85. * 申请成为技师
  86. *
  87. * @authenticated
  88. *
  89. * @bodyParam mobile string 手机号. Example: 13800138000
  90. * @bodyParam gender string 性别. Example: male
  91. * @bodyParam work_years string 工作年限. Example: 5
  92. * @bodyParam intention_city string 意向城市. Example: 杭州
  93. *
  94. * @response {
  95. * "code": 200,
  96. * "message": "申请成功",
  97. * "data": null
  98. * }
  99. */
  100. public function applyCoach(Request $request)
  101. {
  102. $mobile = $request->input('mobile');
  103. $gender = $request->input('gender');
  104. $work_years = $request->input('work_years');
  105. $intention_city = $request->input('intention_city');
  106. $result = $this->service->applyCoach($mobile, $gender, $work_years, $intention_city);
  107. return $result;
  108. }
  109. /**
  110. * [用户]生成二维码
  111. *
  112. * @description 生成当前用户的邀请码和对应的二维码
  113. *
  114. * @response {
  115. * "code": 200,
  116. * "message": "生成成功",
  117. * "data": {
  118. * "invite_code": "ABC123",
  119. * "qr_code": "data:image/png;base64,..."
  120. * }
  121. * }
  122. */
  123. public function generateInviteCode()
  124. {
  125. // 调用服务层生成邀请码
  126. return $this->service->generateInviteCode();
  127. }
  128. }