ProjectController.php 4.0 KB

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