package com.sckw.system.controller.forkliftapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sckw.core.web.response.BaseResult;
import com.sckw.system.model.vo.req.FeedbackListReqVo;
import com.sckw.system.model.vo.req.SubmitFeedbackReqVo;
import com.sckw.system.model.vo.res.FeedbackResVo;
import com.sckw.system.service.KwsFeedbackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 意见反馈Controller
 * @author chenxiaofei
 * @date 2026-01-12
 */
@RestController
@RequestMapping("/feedback")
@Tag(name = "意见反馈相关接口")
@RequiredArgsConstructor
public class FeedbacksController {

    private final KwsFeedbackService kwsFeedbackService;

    /**
     * 提交意见反馈
     * @param reqVo 提交反馈请求对象
     * @return BaseResult<FeedbackResVo>
     */
    @PostMapping("/submit")
    @Operation(summary = "提交意见反馈", description = "用户提交意见反馈，可上传图片")
    public BaseResult<FeedbackResVo> submitFeedback(@RequestBody @Valid SubmitFeedbackReqVo reqVo) {
        FeedbackResVo resVo = kwsFeedbackService.submitFeedback(reqVo);
        return BaseResult.success(resVo);
    }

    /**
     * 查询用户反馈列表（分页）
     * @param reqVo 反馈列表查询请求对象
     * @return BaseResult<Page<FeedbackResVo>>
     */
    @PostMapping("/list")
    @Operation(summary = "查询反馈列表", description = "分页查询当前用户的反馈列表")
    public BaseResult<Page<FeedbackResVo>> getFeedbackList(@RequestBody @Valid FeedbackListReqVo reqVo) {
        Page<FeedbackResVo> page = kwsFeedbackService.getFeedbackList(reqVo);
        return BaseResult.success(page);
    }

    /**
     * 查询反馈详情
     * @param feedbackId 反馈ID
     * @return BaseResult<FeedbackResVo>
     */
    @GetMapping("/detail/{feedbackId}")
    @Operation(summary = "查询反馈详情", description = "根据反馈ID查询详细信息")
    public BaseResult<FeedbackResVo> getFeedbackDetail(@PathVariable("feedbackId") Long feedbackId) {
        FeedbackResVo resVo = kwsFeedbackService.getFeedbackDetail(feedbackId);
        return BaseResult.success(resVo);
    }

}




