123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Http\Controllers\Client;
- use App\Http\Controllers\Controller;
- use App\Services\Client\CommentService;
- use Illuminate\Http\Request;
- /**
- * @group 用户端-评论管理
- *
- * 评论相关的API接口
- */
- class CommentController extends Controller
- {
- protected CommentService $service;
- public function __construct(CommentService $service)
- {
- $this->service = $service;
- }
- /**
- * 发表评价
- *
- * 发表评价
- *
- * @authenticated
- *
- * @bodyParam coach_id int required 技师ID. Example: 1
- * @bodyParam content string required 评价内容. Example: 很棒的服务!
- * @bodyParam rating int required 评分. Example: 5
- *
- * @response {
- * "code": 200,
- * "message": "评价成功",
- * "data": {
- * "id": 1,
- * "coach_id": 1,
- * "content": "很棒的服务!",
- * "rating": 5,
- * "created_at": "2024-01-01 10:00:00"
- * }
- * }
- */
- public function create(Request $request)
- {
- $coachId = $request->input('coach_id');
- $content = $request->input('content');
- $rating = $request->input('rating');
- return $this->service->createComment($coachId, $content, $rating);
- }
- /**
- * 评价列表
- *
- * 获取评价列表
- *
- * @authenticated
- *
- * @queryParam coach_id int required 技师ID. Example: 1
- *
- * @response {
- * "code": 200,
- * "message": "获取成功",
- * "data": [
- * {
- * "id": 1,
- * "coach_id": 1,
- * "content": "很棒的服务!",
- * "rating": 5,
- * "created_at": "2024-01-01 10:00:00"
- * }
- * ]
- * }
- */
- public function list(Request $request)
- {
- $coachId = $request->input('coach_id');
- return $this->service->getCommentList($coachId);
- }
- }
|