ProjectController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace App\Http\Controllers\Client;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\Client\ProjectService;
  5. use Illuminate\Http\Request;
  6. /**
  7. * @group 用户端
  8. *
  9. * 项目相关的API接口
  10. */
  11. class ProjectController extends Controller
  12. {
  13. protected ProjectService $service;
  14. public function __construct(ProjectService $service)
  15. {
  16. $this->service = $service;
  17. }
  18. /**
  19. * [项目]获取项目列表
  20. *
  21. * 根据区域代码获取项目列表
  22. *
  23. * @authenticated
  24. *
  25. * @queryParam area_code string 区域代码. Example: 330100
  26. * @queryParam project_cate_id integer 项目分类ID. Example: 1
  27. * @queryParam type string 项目类型(1:普通项目,2:加钟项目). Example: 1
  28. *
  29. * @response {
  30. * "code": 200,
  31. * "message": "获取成功",
  32. * "data": {
  33. * "current_page": 1,
  34. * "data": [
  35. * {
  36. * "id": 1,
  37. * "name": "项目名称",
  38. * "description": "项目描述",
  39. * "price": "100.00",
  40. * "duration": 60,
  41. * "category": {
  42. * "id": 1,
  43. * "name": "分类名称"
  44. * }
  45. * }
  46. * ],
  47. * "total": 10,
  48. * "per_page": 10
  49. * }
  50. * }
  51. */
  52. public function index(Request $request)
  53. {
  54. $validated = $request->validate([
  55. 'area_code' => 'required|string',
  56. 'project_cate_id' => 'nullable|integer',
  57. 'type' => 'required|in:1,2',
  58. ]);
  59. return $this->success(
  60. $this->service->getProjectList(
  61. $validated['area_code'],
  62. $validated['project_cate_id'] ?? null,
  63. $validated['type']
  64. )
  65. );
  66. }
  67. /**
  68. * [项目]获取项目详情
  69. *
  70. * 获取指定项目的详细信息
  71. *
  72. * @authenticated
  73. *
  74. * @queryParam id integer required 项目ID. Example: 1
  75. * @queryParam area_code string required 区域代码. Example: 330100
  76. *
  77. * @response {
  78. * "code": 200,
  79. * "message": "获取成功",
  80. * "data": {
  81. * "id": 1,
  82. * "name": "项目名称",
  83. * "description": "项目描述",
  84. * "price": "100.00",
  85. * "duration": 60,
  86. * "category": {
  87. * "id": 1,
  88. * "name": "分类名称"
  89. * },
  90. * "agent": {
  91. * "id": 1,
  92. * "name": "代理商名称",
  93. * "contact": "联系人",
  94. * "mobile": "13800138000"
  95. * }
  96. * }
  97. * }
  98. * @response 404 {
  99. * "code": 404,
  100. * "message": "项目不存在"
  101. * }
  102. * @response 400 {
  103. * "code": 400,
  104. * "message": "该区域暂无代理商"
  105. * }
  106. */
  107. public function detail(Request $request)
  108. {
  109. $projectId = $request->input('id');
  110. $areaCode = $request->input('area_code');
  111. return $this->success($this->service->getProjectDetail($projectId, $areaCode));
  112. }
  113. /**
  114. * [项目]获取技师项目列表
  115. *
  116. * 获取指定技师已开通的项目列表
  117. *
  118. * @authenticated
  119. *
  120. * @queryParam coach_id integer required 技师ID. Example: 6
  121. * @queryParam area_code string required 区域代码. Example: 330100
  122. * @queryParam project_cate_id integer 项目分类ID. Example: 1
  123. *
  124. * @response {
  125. * "code": 200,
  126. * "message": "获取成功",
  127. * "data": {
  128. * "current_page": 1,
  129. * "data": [
  130. * {
  131. * "id": 1,
  132. * "name": "项目名称",
  133. * "description": "项目描述",
  134. * "price": "100.00",
  135. * "duration": 60,
  136. * "category": {
  137. * "id": 1,
  138. * "name": "分类名称"
  139. * }
  140. * }
  141. * ],
  142. * "total": 10,
  143. * "per_page": 10
  144. * }
  145. * }
  146. * @response 404 {
  147. * "code": 404,
  148. * "message": "技师不存在或未通过认证"
  149. * }
  150. */
  151. public function coachProjectList(Request $request)
  152. {
  153. $validated = $request->validate([
  154. 'coach_id' => 'required|integer',
  155. 'area_code' => 'required|string',
  156. 'project_cate_id' => 'required|integer',
  157. ]);
  158. return $this->success(
  159. $this->service->getCoachProjectList(
  160. $validated['coach_id'],
  161. $validated['area_code'],
  162. $validated['project_cate_id']
  163. )
  164. );
  165. }
  166. }