UserController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. return $this->service->updateUserInfo($data);
  59. }
  60. /**
  61. * 获取用户钱包
  62. *
  63. * 获取当前用户的钱包信息
  64. *
  65. * @authenticated
  66. *
  67. * @response {
  68. * "code": 200,
  69. * "message": "获取成功",
  70. * "data": {
  71. * "balance": 100.00,
  72. * "freeze": 0.00
  73. * }
  74. * }
  75. */
  76. public function wallet()
  77. {
  78. return $this->service->getUserWallet();
  79. }
  80. /**
  81. * 用户提现
  82. *
  83. * 提现用户的余额
  84. *
  85. * @authenticated
  86. *
  87. * @bodyParam amount decimal 提现金额. Example: 100.00
  88. * @bodyParam type string 提现方式. Example: wechat
  89. * @bodyParam area_code string 行政区划代码. Example: 330100
  90. *
  91. * @response {
  92. * "code": 200,
  93. * "message": "提现成功",
  94. * "data": null
  95. * }
  96. */
  97. public function withdraw(Request $request)
  98. {
  99. $amount = $request->input('amount');
  100. $type = $request->input('type', 'wechat');
  101. $area_code = $request->input('area_code', '');
  102. return $this->service->withdraw($amount, $type, $area_code);
  103. }
  104. /**
  105. * 用户反馈
  106. *
  107. * 提交用户的反馈信息
  108. *
  109. * @authenticated
  110. *
  111. * @bodyParam content string 反馈内容. Example: 这是一个反馈信息
  112. *
  113. * @response {
  114. * "code": 200,
  115. * "message": "提交成功",
  116. * "data": null
  117. * }
  118. */
  119. public function feedback(Request $request)
  120. {
  121. $content = $request->input('content');
  122. return $this->service->feedback($content);
  123. }
  124. /**
  125. * 申请成为技师
  126. *
  127. * 申请成为技师
  128. *
  129. * @authenticated
  130. *
  131. * @bodyParam mobile string 手机号. Example: 13800138000
  132. * @bodyParam gender string 性别. Example: male
  133. * @bodyParam work_years string 工作年限. Example: 5
  134. * @bodyParam intention_city string 意向城市. Example: 杭州
  135. *
  136. * @response {
  137. * "code": 200,
  138. * "message": "申请成功",
  139. * "data": null
  140. * }
  141. */
  142. public function applyCoach(Request $request)
  143. {
  144. $mobile = $request->input('mobile');
  145. $gender = $request->input('gender');
  146. $work_years = $request->input('work_years');
  147. $intention_city = $request->input('intention_city');
  148. return $this->service->applyCoach($mobile, $gender, $work_years, $intention_city);
  149. }
  150. }