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.TbYjxxRyQuery;
import com.mosty.base.model.vo.yjzl.TbYjxxRyVo;
import com.mosty.yjzl.service.TbYjxxRyService;
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;

/**
 * <p>
 * 预警信息-人员表 前端控制器
 * </p>
 *
 * @author zengbo
 * @since 2022-07-19
 */
@Api(tags = "预警信息人员接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbYjxxRy")
public class TbYjxxRyController {

    private TbYjxxRyService tbYjxxRyService;

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

    @ApiOperation("分页查询")
    @JwtSysUser
    @GetMapping("/paginQuery")
    public ResponseResult<IPage<TbYjxxRyVo>> paginQuery(TbYjxxRyQuery tbYjxxRyQuery){
        return ResponseResult.success(tbYjxxRyService.queryByPage(tbYjxxRyQuery));
    }

    @ApiOperation("不分页查询")
    @JwtSysUser
    @GetMapping("/queryListNoPager")
    public ResponseResult<List<TbYjxxRyVo>> queryListNoPager(TbYjxxRyQuery tbYjxxRyQuery){
        return ResponseResult.success(tbYjxxRyService.queryList(tbYjxxRyQuery));
    }

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "预警信息人员新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbYjxxRyVo ryVo){
        return ResponseResult.success(tbYjxxRyService.insert(ryVo));
    }

    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "预警信息人员更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbYjxxRyVo ryVo){
        return ResponseResult.success(tbYjxxRyService.update(ryVo));
    }

    @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(tbYjxxRyService.deleteById(list));
    }

}

