|
@@ -85,198 +85,4 @@ class ProjectController extends AdminController
|
|
|
amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
|
|
|
]);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * [项目管理]获取项目列表
|
|
|
- *
|
|
|
- * @description 获取项目列表,支持分页和搜索
|
|
|
- *
|
|
|
- * @queryParam page int 页码 Example: 1
|
|
|
- * @queryParam per_page int 每页数量 Example: 10
|
|
|
- * @queryParam keyword string 搜索关键词 Example: null
|
|
|
- *
|
|
|
- * @response {
|
|
|
- * "code": 0,
|
|
|
- * "message": "success",
|
|
|
- * "data": {
|
|
|
- * "items": [],
|
|
|
- * "total": 0
|
|
|
- * }
|
|
|
- * }
|
|
|
- */
|
|
|
- public function getProjects(Request $request): JsonResponse
|
|
|
- {
|
|
|
- $result = $this->service->getProjects(
|
|
|
- $request->input('page', 1),
|
|
|
- $request->input('per_page', 10),
|
|
|
- $request->input('keyword')
|
|
|
- );
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'code' => 0,
|
|
|
- 'message' => 'success',
|
|
|
- 'data' => $result,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * [项目管理]创建项目
|
|
|
- *
|
|
|
- * @description 创建新的项目
|
|
|
- *
|
|
|
- * @header x-xsrf-token string required CSRF令牌 Example: 7d9ht4EM6kGpzE9eSfSVsqC2RJRyZaBZQAnXCPB3
|
|
|
- *
|
|
|
- * @bodyParam title string required 项目标题 Example: 精油SPA
|
|
|
- * @bodyParam subtitle string required 项目副标题 Example: 专业精油按摩
|
|
|
- * @bodyParam cover string required 项目封面 Example: http:
|
|
|
- * @bodyParam price numeric required 项目金额 Example: 299.00
|
|
|
- * @bodyParam original_price numeric required 项目原价 Example: 399.00
|
|
|
- * @bodyParam duration int required 服务时长(分钟) Example: 60
|
|
|
- * @bodyParam project_desc string required 项目介绍 Example: 专业精油按摩服务
|
|
|
- * @bodyParam service_desc string required 服务说明 Example: 服务流程说明
|
|
|
- * @bodyParam type int required 服务类型 Example: 1
|
|
|
- * @bodyParam state int required 状态(0:下架 1:上架) Example: 1
|
|
|
- *
|
|
|
- * @response {
|
|
|
- * "code": 0,
|
|
|
- * "message": "success",
|
|
|
- * "data": null
|
|
|
- * }
|
|
|
- */
|
|
|
- public function createProject(Request $request): JsonResponse
|
|
|
- {
|
|
|
-
|
|
|
- $validated = $request->validate([
|
|
|
- 'title' => 'required|string|max:100',
|
|
|
- 'subtitle' => 'required|string|max:200',
|
|
|
- 'cover' => 'required|string|max:255',
|
|
|
- 'price' => 'required|numeric|min:0',
|
|
|
- 'original_price' => 'required|numeric|min:0',
|
|
|
- 'duration' => 'required|integer|min:1',
|
|
|
- 'project_desc' => 'required|string',
|
|
|
- 'service_desc' => 'required|string',
|
|
|
- 'type' => 'required|integer|in:1,2,3',
|
|
|
- 'state' => 'required|integer|in:0,1',
|
|
|
- ]);
|
|
|
-
|
|
|
-
|
|
|
- $validated['cate_id'] = 1;
|
|
|
-
|
|
|
- try {
|
|
|
- $result = $this->service->createProject($validated);
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'code' => 0,
|
|
|
- 'message' => 'success',
|
|
|
- 'data' => $result,
|
|
|
- ]);
|
|
|
- } catch (\Exception $e) {
|
|
|
- return response()->json([
|
|
|
- 'code' => 500,
|
|
|
- 'message' => '创建项目失败:'.$e->getMessage(),
|
|
|
- ], 500);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * [项目管理]更新项目
|
|
|
- *
|
|
|
- * @description 更新项目信息
|
|
|
- *
|
|
|
- * @header x-xsrf-token string required CSRF令牌 Example: 7d9ht4EM6kGpzE9eSfSVsqC2RJRyZaBZQAnXCPB3
|
|
|
- *
|
|
|
- * @bodyParam title string 项目标题 Example: 精油SPA
|
|
|
- * @bodyParam subtitle string 项目副标题 Example: 专业精油按摩
|
|
|
- * @bodyParam cover string 项目封面 Example: http:
|
|
|
- * @bodyParam price numeric 项目金额 Example: 299.00
|
|
|
- * @bodyParam original_price numeric 项目原价 Example: 399.00
|
|
|
- * @bodyParam duration int 服务时长(分钟) Example: 60
|
|
|
- * @bodyParam project_desc string 项目介绍 Example: 专业精油按摩服务
|
|
|
- * @bodyParam service_desc string 服务说明 Example: 服务流程说明
|
|
|
- * @bodyParam type int 服务类型 Example: 1
|
|
|
- * @bodyParam state int 状态(0:下架 1:上架) Example: 1
|
|
|
- *
|
|
|
- * @response {
|
|
|
- * "code": 0,
|
|
|
- * "message": "success",
|
|
|
- * "data": null
|
|
|
- * }
|
|
|
- */
|
|
|
- public function updateProject(Request $request, int $id): JsonResponse
|
|
|
- {
|
|
|
-
|
|
|
- $validated = $request->validate([
|
|
|
- 'title' => 'sometimes|string|max:100',
|
|
|
- 'subtitle' => 'sometimes|string|max:200',
|
|
|
- 'cover' => 'sometimes|string|max:255',
|
|
|
- 'price' => 'sometimes|numeric|min:0',
|
|
|
- 'original_price' => 'sometimes|numeric|min:0',
|
|
|
- 'duration' => 'sometimes|integer|min:1',
|
|
|
- 'project_desc' => 'sometimes|string',
|
|
|
- 'service_desc' => 'sometimes|string',
|
|
|
- 'type' => 'sometimes|integer|in:1,2,3',
|
|
|
- 'state' => 'sometimes|integer|in:0,1',
|
|
|
- ]);
|
|
|
-
|
|
|
- try {
|
|
|
- $result = $this->service->updateProject($id, $validated);
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'code' => 0,
|
|
|
- 'message' => 'success',
|
|
|
- 'data' => $result,
|
|
|
- ]);
|
|
|
- } catch (\Exception $e) {
|
|
|
- return response()->json([
|
|
|
- 'code' => 500,
|
|
|
- 'message' => '更新项目失败:'.$e->getMessage(),
|
|
|
- ], 500);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * [项目管理]删除项目
|
|
|
- *
|
|
|
- * @description 删除指定项目
|
|
|
- *
|
|
|
- * @header x-xsrf-token string required CSRF令牌 Example: 7d9ht4EM6kGpzE9eSfSVsqC2RJRyZaBZQAnXCPB3
|
|
|
- *
|
|
|
- * @response {
|
|
|
- * "code": 0,
|
|
|
- * "message": "success",
|
|
|
- * "data": null
|
|
|
- * }
|
|
|
- */
|
|
|
- public function deleteProject(int $id): JsonResponse
|
|
|
- {
|
|
|
- $result = $this->service->deleteProject($id);
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'code' => 0,
|
|
|
- 'message' => 'success',
|
|
|
- 'data' => $result,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * [项目管理]获取项目详情
|
|
|
- *
|
|
|
- * @description 获取指定项目的详细信息
|
|
|
- *
|
|
|
- * @response {
|
|
|
- * "code": 0,
|
|
|
- * "message": "success",
|
|
|
- * "data": {}
|
|
|
- * }
|
|
|
- */
|
|
|
- public function getProject(int $id): JsonResponse
|
|
|
- {
|
|
|
- $result = $this->service->getProject($id);
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'code' => 0,
|
|
|
- 'message' => 'success',
|
|
|
- 'data' => $result,
|
|
|
- ]);
|
|
|
- }
|
|
|
}
|