package com.corewing.app.modules.admin.biz;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corewing.app.common.Result;
import com.corewing.app.dto.biz.feedback.FeedbackBatchDeleteRequest;
import com.corewing.app.dto.biz.feedback.FeedbackBatchStatusRequest;
import com.corewing.app.entity.Feedback;
import com.corewing.app.service.FeedbackService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户反馈
 */
@Controller
@RequestMapping("/biz/feedback")
public class BizFeedBackController {

    @Resource
    private FeedbackService feedbackService;

    /**
     * 反馈管理首页
     * @return
     */
    @GetMapping("/index")
    public String index() {
        return "admin/biz/feedback/index";
    }

    /**
     * 查询反馈数据分页
     * @param feedback
     * @return
     */
    @GetMapping("/page")
    @ResponseBody
    public Result<Page<Feedback>> page(Feedback feedback) {
        return Result.success(feedbackService.page(feedback));
    }

    /**
     * 新增反馈
     * @param feedback
     * @return
     */
    @PostMapping("/save")
    @ResponseBody
    public Result<String> save(@RequestBody Feedback feedback) {
        return Result.isBool(feedbackService.save(feedback));
    }

    /**
     * 编辑反馈
     * @param feedback
     * @return
     */
    @PostMapping("/update")
    @ResponseBody
    public Result<String> update(@RequestBody Feedback feedback) {
        return Result.isBool(feedbackService.updateById(feedback));
    }

    /**
     * 删除反馈
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    @ResponseBody
    public Result<String> delete(Long id) {
        return Result.isBool(feedbackService.removeById(id));
    }

    /**
     * 批量删除反馈
     * @param feedbackBatchDeleteRequest
     * @return
     */
    @PostMapping("/batchDelete")
    @ResponseBody
    public Result<String> batchDelete(@RequestBody FeedbackBatchDeleteRequest feedbackBatchDeleteRequest) {
        return Result.isBool(feedbackService.removeBatchByIds(feedbackBatchDeleteRequest.getIds()));
    }

    /**
     * 批量更改状态
     * @param feedbackBatchStatusRequest
     * @return
     */
    @PostMapping("/batchStatus")
    @ResponseBody
    public Result<String> batchStatus(@RequestBody FeedbackBatchStatusRequest feedbackBatchStatusRequest) {
        return Result.isBool(feedbackService.batchStatus(feedbackBatchStatusRequest));
    }


}
