package cn.iocoder.yudao.module.inspection.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.iocoder.yudao.module.core.controller.BaseController;
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
import cn.iocoder.yudao.module.inspection.service.IWarnMessageService;

/**
 * warnMsgController
 *
 * @author zcy
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/admin-api/warnMsg/warnMsg")
public class WarnMessageController extends BaseController
{
    @Autowired
    private IWarnMessageService warnMessageService;

    /**
     * 查询warnMsg列表
     */
    @GetMapping("/list")
    public CommonResult list(WarnMessage warnMessage) throws Exception {
        List<WarnMessage> list = warnMessageService.selectWarnMessageList(warnMessage);
        return success(list);
    }

    @GetMapping("/pageList")
    public CommonResult pageList(WarnMessage warnMessage,Integer pageNo,Integer pageSize) throws Exception {
        Page page =new Page(pageNo,pageSize);
        IPage<WarnMessage> list = warnMessageService.pageList(page,warnMessage);
        return success(list);
    }
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarnMessage warnMessage) throws Exception {
        List<WarnMessage> list = warnMessageService.selectWarnMessageList(warnMessage);
        ExcelUtil<WarnMessage> util = new ExcelUtil<WarnMessage>(WarnMessage.class);
        util.exportExcel(response, list, "warnMsg数据");
    }

    /**
     * 获取warnMsg详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(warnMessageService.selectWarnMessageById(id));
    }


    @PostMapping("/add")
    public CommonResult add(@RequestBody WarnMessage warnMessage)
    {
        return toAjax(warnMessageService.insertWarnMessage(warnMessage));
    }


    @PostMapping("/edit")
    public CommonResult edit(@RequestBody WarnMessage warnMessage)
    {
        return toAjax(warnMessageService.updateWarnMessage(warnMessage));
    }


	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(warnMessageService.deleteWarnMessageByIds(ids));
    }
}
