ProjectController.php 3.9 KB

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