package com.tourguide.api.admin;
|
|
import com.tourguide.common.api.ApiResponse;
|
import com.tourguide.common.api.PageResponse;
|
import com.tourguide.modules.feedback.dto.FeedbackProcessRequest;
|
import com.tourguide.modules.feedback.dto.UserFeedbackResponse;
|
import com.tourguide.modules.feedback.service.UserFeedbackService;
|
import com.tourguide.security.AppUserPrincipal;
|
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.web.bind.annotation.*;
|
import javax.validation.Valid;
|
import java.time.LocalDate;
|
|
/**
|
* 管理后台用户反馈处理接口。
|
* 同时支持游客和导游反馈,通过 feedbackType 明确区分来源账号体系。
|
*/
|
@RestController
|
@RequestMapping("/api/admin/feedback")
|
public class AdminUserFeedbackController {
|
private final UserFeedbackService feedbackService;
|
|
public AdminUserFeedbackController(UserFeedbackService feedbackService) {
|
this.feedbackService = feedbackService;
|
}
|
|
/**
|
* 分页查询用户反馈,支持按反馈来源、手机号、处理状态和提交日期筛选。
|
*
|
* @param page 页码,从 1 开始
|
* @param size 每页记录数
|
* @param feedbackType 反馈来源类型,默认 VISITOR,可切换为导游反馈类型
|
* @param mobile 提交人手机号
|
* @param status 反馈处理状态
|
* @param startDate 提交日期起始值,包含当天
|
* @param endDate 提交日期结束值,包含当天
|
* @return 用户反馈分页结果
|
*/
|
@GetMapping
|
public ApiResponse<PageResponse<UserFeedbackResponse>> page(@RequestParam(defaultValue = "1") long page,
|
@RequestParam(defaultValue = "10") long size,
|
@RequestParam(defaultValue = "VISITOR") String feedbackType,
|
@RequestParam(required = false) String mobile,
|
@RequestParam(required = false) Integer status,
|
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
|
return ApiResponse.success(feedbackService.page(page, size, feedbackType, mobile, status, startDate, endDate));
|
}
|
|
/**
|
* 查询指定反馈的提交人、反馈内容和处理记录。
|
*
|
* @param id 反馈主键
|
* @return 用户反馈详情
|
*/
|
@GetMapping("/{id}")
|
public ApiResponse<UserFeedbackResponse> detail(@PathVariable Long id) {
|
return ApiResponse.success(feedbackService.detail(id));
|
}
|
|
/**
|
* 填写处理结果并完成指定反馈,记录当前后台处理人的账号信息。
|
*
|
* @param id 反馈主键
|
* @param request 反馈处理结果
|
* @param principal 当前登录后台账号身份
|
* @return 处理后的反馈详情
|
*/
|
@PutMapping("/{id}/process")
|
public ApiResponse<UserFeedbackResponse> process(@PathVariable Long id,
|
@Valid @RequestBody FeedbackProcessRequest request,
|
@AuthenticationPrincipal AppUserPrincipal principal) {
|
return ApiResponse.success(feedbackService.process(
|
id, request.getResult(), principal.getUserId(), principal.getUsername()));
|
}
|
}
|