package com.hdkj.lt.bf.controller;

import com.hdkj.lt.base.model.response.PageVO;
import com.hdkj.lt.bf.entity.dto.ProblemFeedbackDTO;
import com.hdkj.lt.bf.entity.dto.ProblemFeedbackListDTO;
import com.hdkj.lt.bf.entity.dto.ProblemFeedbackUpdateDTO;
import com.hdkj.lt.bf.entity.vo.ProblemFeedbackVO;
import com.hdkj.lt.bf.service.FhzgProblemFeedbackService;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("/problem-feedback")
public class ProblemFeedbackController {

    private final FhzgProblemFeedbackService problemFeedbackService;

    /**
     * 保存用户反馈信息
     */
    @ApiOperation(value = "保存用户反馈信息")
    @PostMapping("/save")
    public ApiResponse<String> saveUserFeedback(@Valid @RequestBody ProblemFeedbackDTO problemFeedbackDTO) {
        problemFeedbackService.save(problemFeedbackDTO);
        return ApiResponse.success("保存成功");
    }

    /**
     * 后台管理 问题反馈列表
     */
    @ApiOperation(value = "问题反馈列表查询")
    @PostMapping("/list")
    public ApiResponse<PageVO<ProblemFeedbackVO>> list(@Valid @RequestBody ProblemFeedbackListDTO problemFeedbackListDTO) {
        PageVO<ProblemFeedbackVO> result = problemFeedbackService.list(problemFeedbackListDTO);
        return ApiResponse.success(result);
    }

    /**
     * 后台管理 问题更新
     */
    @ApiOperation(value = "问题更新")
    @PostMapping("/update")
    public ApiResponse<String> update(@Valid @RequestBody ProblemFeedbackUpdateDTO problemFeedbackUpdateDTO) {
        problemFeedbackService.update(problemFeedbackUpdateDTO);
        return ApiResponse.success("更新成功");
    }

    /**
     * 问题详情
     */
    @ApiOperation(value = "问题详情")
    @GetMapping("/{id}")
    public ApiResponse<ProblemFeedbackVO> getById(@PathVariable Long id) {
        return ApiResponse.success(problemFeedbackService.getById(id));
    }

}
