package com.bonus.material.reply.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.reply.entity.BmReply;
import com.bonus.material.reply.service.ReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * @Author：liang.chao
 * @Date：2024/12/16 - 11:15
 */
@RestController
@RequestMapping("/reply")
@Api(value = "快捷回复", tags = "快捷回复")
public class ReplyController extends BaseController {
    @Resource
    private ReplyService replyService;

    @GetMapping("/list")
    @ApiOperation("获取快捷回复列表")
    public AjaxResult list(BmReply bmReply) {
        startPage();
        List<BmReply> list = replyService.list(bmReply);
        return success(getDataTable(list));
    }


    @PostMapping("/add")
    @ApiOperation("新增快捷回复")
    public AjaxResult add(@RequestBody BmReply bmReply) {
        Integer i = replyService.add(bmReply);
        if (i > 0) {
            return AjaxResult.success("新增成功");
        } else {
            return AjaxResult.error("新增失败");
        }
    }
    @PostMapping("/edit")
    @ApiOperation("修改快捷回复")
    public AjaxResult edit(@RequestBody BmReply bmReply) {
        Integer i = replyService.edit(bmReply);
        if (i > 0) {
            return AjaxResult.success("修改成功");
        } else {
            return AjaxResult.error("修改失败");
        }
    }

    @PostMapping("/del")
    @ApiOperation("删除快捷回复")
    public AjaxResult del(@RequestBody BmReply bmReply) {
        Integer i = replyService.del(bmReply);
        if (i > 0) {
            return AjaxResult.success("删除成功");
        } else {
            return AjaxResult.error("删除失败");
        }
    }

}
