UserController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. * 用户相关的API接口
  8. */
  9. class UserController extends Controller
  10. {
  11. protected UserService $service;
  12. public function __construct(UserService $service)
  13. {
  14. $this->service = $service;
  15. }
  16. /**
  17. * [用户管理] 获取用户信息
  18. *
  19. * 获取当前用户的信息
  20. *
  21. * @authenticated
  22. * @response {
  23. * "code": 200,
  24. * "message": "获取成功",
  25. * "data": {
  26. * "id": 1,
  27. * "mobile": "13800138000",
  28. * "nickname": "用户昵称"
  29. * }
  30. * }
  31. */
  32. public function show()
  33. {
  34. return $this->service->getUserInfo();
  35. }
  36. /**
  37. * [用户管理] 修改用户信息
  38. *
  39. * 修改当前用户的信息
  40. *
  41. * @authenticated
  42. * @bodyParam nickname string 用户昵称. Example: 用户昵称
  43. * @bodyParam avatar string 用户头像. Example: https://example.com/avatar.jpg
  44. * @response {
  45. * "code": 200,
  46. * "message": "修改成功",
  47. * "data": null
  48. * }
  49. */
  50. public function update(Request $request)
  51. {
  52. $data = $request->all();
  53. return $this->service->updateUserInfo($data);
  54. }
  55. /**
  56. * [用户管理] 获取用户钱包
  57. *
  58. * 获取当前用户的钱包信息
  59. *
  60. * @authenticated
  61. * @response {
  62. * "code": 200,
  63. * "message": "获取成功",
  64. * "data": {
  65. * "balance": 100.00,
  66. * "freeze": 0.00
  67. * }
  68. * }
  69. */
  70. public function wallet()
  71. {
  72. return $this->service->getUserWallet();
  73. }
  74. /**
  75. * [用户管理] 用户提现
  76. *
  77. * 提现用户的余额
  78. *
  79. * @authenticated
  80. * @bodyParam amount decimal 提现金额. Example: 100.00
  81. * @bodyParam type string 提现方式. Example: wechat
  82. * @bodyParam area_code string 行政区划代码. Example: 330100
  83. * @response {
  84. * "code": 200,
  85. * "message": "提现成功",
  86. * "data": null
  87. * }
  88. */
  89. public function withdraw(Request $request)
  90. {
  91. $amount = $request->input('amount');
  92. $type = $request->input('type', 'wechat');
  93. $area_code = $request->input('area_code', '');
  94. return $this->service->withdraw($amount, $type, $area_code);
  95. }
  96. /**
  97. * [用户管理] 用户反馈
  98. *
  99. * 提交用户的反馈信息
  100. *
  101. * @authenticated
  102. * @bodyParam content string 反馈内容. Example: 这是一个反馈信息
  103. * @response {
  104. * "code": 200,
  105. * "message": "提交成功",
  106. * "data": null
  107. * }
  108. */
  109. public function feedback(Request $request)
  110. {
  111. $content = $request->input('content');
  112. return $this->service->feedback($content);
  113. }
  114. /**
  115. * [用户管理] 申请成为技师
  116. *
  117. * 申请成为技师
  118. *
  119. * @authenticated
  120. * @bodyParam mobile string 手机号. Example: 13800138000
  121. * @bodyParam gender string 性别. Example: male
  122. * @bodyParam work_years string 工作年限. Example: 5
  123. * @bodyParam intention_city string 意向城市. Example: 杭州
  124. * @response {
  125. * "code": 200,
  126. * "message": "申请成功",
  127. * "data": null
  128. * }
  129. */
  130. public function applyCoach(Request $request)
  131. {
  132. $mobile = $request->input('mobile');
  133. $gender = $request->input('gender');
  134. $work_years = $request->input('work_years');
  135. $intention_city = $request->input('intention_city');
  136. return $this->service->applyCoach($mobile, $gender, $work_years, $intention_city);
  137. }
  138. }