service = $service; } /** * 提交评价 * * @group 评价管理 * * @bodyParam order_id integer required 订单ID * @bodyParam score integer required 评分(1-5) * @bodyParam content string 评价内容 * @bodyParam images array 图片列表 * @bodyParam images.* string 图片地址 * @bodyParam is_anonymous boolean 是否匿名 * @bodyParam tag_ids array 标签ID列表 * @bodyParam tag_ids.* integer 标签ID * * @response { * "code": 0, * "message": "操作成功", * "data": { * "id": 1, * "message": "评价提交成功" * } * } */ public function store(CreateRequest $request): array { $data = $request->validated(); return $this->success($this->service->create($data)); } /** * 获取技师评价列表 * * @group 评价管理 * * @queryParam coach_id integer required 技师ID * @queryParam score integer 评分筛选(1-5) * @queryParam tag_id integer 标签筛选 * @queryParam page integer 页码 Example: 1 * @queryParam per_page integer 每页数量 Example: 10 * * @response { * "code": 0, * "message": "操作成功", * "data": { * "total": 100, * "current_page": 1, * "last_page": 10, * "items": [ * { * "id": 1, * "score": 5, * "content": "服务很好", * "images": ["url1", "url2"], * "created_at": "2024-01-01 12:00:00", * "user": { * "id": 1, * "nickname": "用户昵称", * "avatar": "头像地址" * }, * "tags": [ * { * "id": 1, * "name": "标签名称" * } * ] * } * ] * } * } */ public function index(Request $request): array { $filters = $request->validate([ 'coach_id' => 'required|integer|exists:coach_users,id', 'score' => 'nullable|integer|min:1|max:5', 'tag_id' => 'nullable|integer|exists:coach_comment_tags,id', 'page' => 'nullable|integer|min:1', 'per_page' => 'nullable|integer|min:1|max:50', ]); return $this->success($this->service->getCoachComments($filters['coach_id'], $filters)); } }