ProjectController.php 3.9 KB

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