package com.mosty.yjzl.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.query.yjzl.TbYjmxCsbQuery;
import com.mosty.base.model.vo.yjzl.TbYjmxCsbVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbYjmxCsbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


@Api(tags = "预警模型参数表接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbYjmxCsb")
public class TbYjmxCsbController {

    private TbYjmxCsbService tbYjmxCsbService;

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "预警模型参数表新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbYjmxCsbVo vo){
        return ResponseResult.success(tbYjmxCsbService.insert(vo));
    }

    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "预警模型参数表更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbYjmxCsbVo clVo){
        return ResponseResult.success(tbYjmxCsbService.updateById(clVo));
    }

    @ApiOperation("删除数据")
    @JwtSysUser
    @DeleteMapping("/{id}")
    @Log(title = "预警模型参数表删除", businessType = BusinessType.DELETE)
    public ResponseResult<Integer> delete(@PathVariable("id") String id){
        return ResponseResult.success(tbYjmxCsbService.deleteById(id));
    }


    @ApiOperation("分页查询")
    @JwtSysUser
    @GetMapping
    @Log(title = "分页查询", businessType = BusinessType.OTHER)
    public ResponseResult<IPage<TbYjmxCsbVo>> getPage(TbYjmxCsbQuery dto){
        return ResponseResult.success(tbYjmxCsbService.getPage(dto));
    }



}
