package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.common.controller.IController;
import com.kym.entity.Feedback;
import com.kym.entity.queryParams.FeedbackQueryParam;
import com.kym.service.FeedbackService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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;


/**
 * 纠错反馈接口
 *
 * @date 2024-09-22T20:40:35.300431885
 */
@RestController
@RequestMapping("feedback")
public class FeedbackController extends IController {

    @Resource
    private FeedbackService feedbackService;


    /**
     * 纠错反馈新增接口
     *
     * @param feedback 新增纠错反馈
     * @return Res
     */
    @SaCheckPermission(value = "feedback.add")
    @PostMapping("add")
    @SysLog(value = "纠错反馈新增接口")
    public R<?> add(@Valid @RequestBody Feedback feedback) {
//other params checked
        return resp(() -> feedbackService.add(feedback));
    }

    /**
     * 纠错反馈编辑
     *
     * @return Res
     */
    @SaCheckPermission(value = "feedback.modify")
    @PostMapping("modify")
    @SysLog(value = "纠错反馈更新接口")
    public R<?> reply(@Valid @RequestBody Feedback feedback) {
        return resp((t) -> feedbackService.reply(feedback));
    }


    /**
     * 纠错反馈查询接口
     *
     * @return Res
     */
    @SaCheckPermission(value = "feedback.list")
    @PostMapping("list")
    @SysLog(value = "纠错反馈列表查询接口")
    public R<?> list(@RequestBody FeedbackQueryParam query) {
        return resp(() -> feedbackService.list(query));
    }


    /**
     * 纠错反馈查询详情接口
     *
     * @return Res
     */
    @SaCheckPermission(value = "feedback.list")
    @GetMapping("detail/{id}")
    @SysLog(value = "纠错反馈详情查询接口")
    public R<?> detail(@PathVariable long id) {
        return resp(() -> feedbackService.detail(id));
    }


    /**
     * 纠错反馈变更状态接口
     *
     * @return Res
     */
    @SaCheckPermission(value = "feedback.modify")
    @GetMapping("status/{id}/{status}")
    @SysLog(value = "纠错反馈变更状态")
    public R<?> status(@PathVariable long id, @PathVariable int status) {
        return resp((t) -> feedbackService.status(id, status));
    }


    /**
     * 纠错反馈删除接口
     *
     * @return Res
     */
    @SaCheckPermission(value = "feedback.remove")
    @GetMapping("remove/{id}")
    @SysLog(value = "纠错反馈删除")
    public R<?> remove(@PathVariable long id) {
        return resp((t) -> feedbackService.remove(id));
    }


}
