liujie
2026-09-15 ad491191ab50a259da548863d805c57d8a95d083
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.tourguide.api.guide;
 
import com.tourguide.common.api.ApiResponse;
import com.tourguide.modules.feedback.dto.MiniFeedbackCreateRequest;
import com.tourguide.modules.feedback.dto.UserFeedbackResponse;
import com.tourguide.modules.feedback.service.UserFeedbackService;
import com.tourguide.modules.user.entity.GuideUser;
import com.tourguide.modules.user.service.GuideUserService;
import com.tourguide.security.AppUserPrincipal;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
 
/** 导游端意见反馈接口。 */
@RestController
@RequestMapping("/api/guide/feedback")
public class GuideFeedbackController {
    private final UserFeedbackService feedbackService;
    private final GuideUserService guideUserService;
 
    public GuideFeedbackController(UserFeedbackService feedbackService, GuideUserService guideUserService) {
        this.feedbackService = feedbackService;
        this.guideUserService = guideUserService;
    }
 
    /** 提交当前登录导游的意见反馈。 */
    @PostMapping
    public ApiResponse<UserFeedbackResponse> create(@AuthenticationPrincipal AppUserPrincipal principal,
                                                     @Valid @RequestBody MiniFeedbackCreateRequest request) {
        GuideUser guide = guideUserService.findEnabledById(principal.getUserId());
        return ApiResponse.success(feedbackService.createGuide(guide, request.getContent()));
    }
}