/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtygis.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.entity.Costwarn;
import com.tofly.xrtygis.service.CostwarnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 报警提示信息表
 *
 * @author admin
 * @date Wed Jun 02 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/costwarn")
@Api(tags = "报警提示信息表接口")
public class CostwarnController {

    private final CostwarnService costwarnService;

    /**
     * 分页查询
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone getCostwarnPage(Page page,String state) {
        return ResultRespone.success(costwarnService.page(page, Wrappers.<Costwarn>lambdaQuery()
                .eq(state != null,Costwarn::getState,state)));
    }

    /**
     * 新增报警提示信息表
     */
    //(title = "新增报警提示信息表")
    @ApiOperation(value = "新增报警提示信息表")
    @PostMapping
    public ResultRespone save(@RequestBody Costwarn costwarn) {
        costwarn.setState("1");
        return ResultRespone.success(costwarnService.save(costwarn));
    }

    /**
     * 关闭报警提示信息表
     */
    //(title = "关闭报警提示信息表")
    @ApiOperation(value = "关闭报警提示信息表")
    @PutMapping("/shutDownWarn")
    public ResultRespone shutDownWarn(Long id) {
        return ResultRespone.success(costwarnService.shutDownWarn(id));
    }
}
