package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.jcgl.TbJcglBqDto;
import com.mosty.base.model.query.jcgl.TbJcglBqQuery;
import com.mosty.base.model.vo.jcgl.TbJcglBqVo;
import com.mosty.base.manager.service.TbJcglBqService;
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 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;

/**
 * 巡防警力标签表（技能/经验）;(tb_jcgl_bq)表控制层
 * @author : http://www.chiner.pro
 * @date : 2022-6-6
 */
@Api(tags = "巡防警力标签表对象功能接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbJcglBq")
public class TbJcglBqController{

    private final TbJcglBqService tbJcglBqService;
    
    /** 
     * 通过ID查询单条数据 
     *
     * @param id 主键
     * @return 实例对象
     */
    @ApiOperation("通过ID查询单条数据")
    @JwtSysUser
    @GetMapping("{id}")
    @Log(title = "巡防警力标签单条数据", businessType = BusinessType.OTHER)
    @ApiImplicitParam(name = "id", value = "标签ID", paramType = "path", required = true, dataType="String")
    public ResponseResult<TbJcglBqVo> queryById(@PathVariable String id){
        return ResponseResult.success(tbJcglBqService.queryById(id));
    }
    
    /** 
     * 分页查询
     *
     * @param tbJcglBq 筛选条件
     * @return 查询结果
     */
    @ApiOperation("分页查询")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbJcglBqVo>> paginQuery(TbJcglBqQuery tbJcglBq){
        IPage<TbJcglBqVo> page = tbJcglBqService.paginQuery(tbJcglBq);
        return ResponseResult.success(page);
    }
    
    /** 
     * 新增数据
     *
     * @param tbJcglBq 实例对象
     * @return 实例对象
     */
    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "巡防警力标签新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbJcglBqDto tbJcglBq){
        return ResponseResult.success(tbJcglBqService.insert(tbJcglBq));
    }
    
    /** 
     * 更新数据
     *
     * @param tbJcglBq 实例对象
     * @return 实例对象
     */
    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "巡防警力标签更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbJcglBqDto tbJcglBq){
        return ResponseResult.success(tbJcglBqService.update(tbJcglBq));
    }
    
    /** 
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @ApiOperation("通过主键删除数据")
    @DeleteMapping("{id}")
    @Log(title = "巡防警力标签删除", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType="String")
    public ResponseResult<Boolean> deleteById(@PathVariable("id") String id){
        return ResponseResult.success(tbJcglBqService.deleteById(id));
    }

     /**
      * 通过主键删除数据
      *
      * @param id 主键
      * @return 是否成功
      */
     @ApiOperation("通过主键删除数据")
     @DeleteMapping("/bacth")
     @Log(title = "巡防警力标签删除", businessType = BusinessType.UPDATE)
     @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType="String")
     public ResponseResult<Boolean> deleteByIds(@RequestParam List<String> id){
         return ResponseResult.success(tbJcglBqService.deleteByIds(id));
     }

     /**
      * 通过标签名称验证是否重复
      *
      * @param mc 标签名称
      * @return 是否成功
      */
     @ApiOperation("通过标签名称验证是否重复")
     @JwtSysUser
     @GetMapping("/check")
     @ApiImplicitParam(name = "mc", value = "标签名称", paramType = "query", required = true, dataType="String")
     public ResponseResult<Boolean> check(@RequestParam(value = "mc") String mc){
         return ResponseResult.success(tbJcglBqService.checkMc(mc));
     }

     /**
      * 统计标签数量
      *
      * @param
      * @return 是否成功
      */
     @ApiOperation("统计标签数量")
     @JwtSysUser
     @GetMapping("/countBqsl")
     public ResponseResult countBqsl(TbJcglBqVo tbJcglBqVo){
         return ResponseResult.success(tbJcglBqService.countBqsl(tbJcglBqVo ));
     }

    /**
     * 通过主键注销数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @ApiOperation("通过主键注销数据")
    @JwtSysUser
    @PutMapping("/zcbqByIds")
    @Log(title = "巡防警力标签注销", businessType = BusinessType.UPDATE)
//    @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType="String")
    public ResponseResult<Boolean> zcbqByIds(@RequestBody  List<String> id){
        return ResponseResult.success(tbJcglBqService.zcbqByIds(id));
    }


}