ProjectController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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->service->getProjectList(
  60. $validated['area_code'],
  61. $validated['project_cate_id'] ?? null,
  62. $validated['type']
  63. );
  64. }
  65. /**
  66. * [项目]获取项目详情
  67. *
  68. * 获取指定项目的详细信息
  69. *
  70. * @authenticated
  71. *
  72. * @queryParam id integer required 项目ID. Example: 1
  73. * @queryParam area_code string required 区域代码. Example: 330100
  74. *
  75. * @response {
  76. * "code": 200,
  77. * "message": "获取成功",
  78. * "data": {
  79. * "id": 1,
  80. * "name": "项目名称",
  81. * "description": "项目描述",
  82. * "price": "100.00",
  83. * "duration": 60,
  84. * "category": {
  85. * "id": 1,
  86. * "name": "分类名称"
  87. * },
  88. * "agent": {
  89. * "id": 1,
  90. * "name": "代理商名称",
  91. * "contact": "联系人",
  92. * "mobile": "13800138000"
  93. * }
  94. * }
  95. * }
  96. * @response 404 {
  97. * "code": 404,
  98. * "message": "项目不存在"
  99. * }
  100. * @response 400 {
  101. * "code": 400,
  102. * "message": "该区域暂无代理商"
  103. * }
  104. */
  105. public function detail(Request $request)
  106. {
  107. $projectId = $request->input('id');
  108. $areaCode = $request->input('area_code');
  109. return $this->service->getProjectDetail($projectId, $areaCode);
  110. }
  111. /**
  112. * [项目]获取技师项目列表
  113. *
  114. * 获取指定技师已开通的项目列表
  115. *
  116. * @authenticated
  117. *
  118. * @queryParam coach_id integer required 技师ID. Example: 6
  119. * @queryParam area_code string required 区域代码. Example: 330100
  120. * @queryParam project_cate_id integer 项目分类ID. Example: 1
  121. *
  122. * @response {
  123. * "code": 200,
  124. * "message": "获取成功",
  125. * "data": {
  126. * "current_page": 1,
  127. * "data": [
  128. * {
  129. * "id": 1,
  130. * "name": "项目名称",
  131. * "description": "项目描述",
  132. * "price": "100.00",
  133. * "duration": 60,
  134. * "category": {
  135. * "id": 1,
  136. * "name": "分类名称"
  137. * }
  138. * }
  139. * ],
  140. * "total": 10,
  141. * "per_page": 10
  142. * }
  143. * }
  144. * @response 404 {
  145. * "code": 404,
  146. * "message": "技师不存在或未通过认证"
  147. * }
  148. */
  149. public function coachProjectList(Request $request)
  150. {
  151. $validated = $request->validate([
  152. 'coach_id' => 'required|integer',
  153. 'area_code' => 'required|string',
  154. 'project_cate_id' => 'required|integer',
  155. ]);
  156. return $this->service->getCoachProjectList(
  157. $validated['coach_id'],
  158. $validated['area_code'],
  159. $validated['project_cate_id']
  160. );
  161. }
  162. }