package com.mosty.yjzl.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
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.base.model.query.yjzl.TbYjxxDypzQuery;
import com.mosty.base.model.vo.yjzl.TbYjxxDypzVo;
import com.mosty.yjzl.service.TbYjxxDypzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "预警信息配置接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbYjxxDypz")
public class TbYjxxDypzController {

    private TbYjxxDypzService tbYjxxDypzService;

    @ApiOperation("通过ID查询单条数据")
    @JwtSysUser
    @GetMapping("{id}")
    @Log(title = "预警配置数据", businessType = BusinessType.OTHER)
    @ApiImplicitParam(name = "id", value = "配置ID", paramType = "path", required = true, dataType="String")
    public ResponseResult<TbYjxxDypzVo> queryById(@PathVariable String id){
        return ResponseResult.success(tbYjxxDypzService.queryById(id));
    }

    @ApiOperation("分页查询")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbYjxxDypzVo>> paginQuery(TbYjxxDypzQuery dto){
        return ResponseResult.success(tbYjxxDypzService.queryList(dto));
    }

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "预警配置新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbYjxxDypzVo dypz){
        return ResponseResult.success(tbYjxxDypzService.insert(dypz));
    }

    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "预警配置更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbYjxxDypzVo dypz){
        return ResponseResult.success(tbYjxxDypzService.updateById(dypz));
    }

    @ApiOperation("通过主键删除数据")
    @DeleteMapping("/bacth")
    @Log(title = "预警配置删除", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "list", value = "标签主键", paramType = "path", required = true, dataType="String")
    public ResponseResult<Integer> deleteByIds(@RequestParam List<String> list){
        return ResponseResult.success(tbYjxxDypzService.deleteById(list));
    }
}

