package com.mosty.base.manager.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.dto.qwzx.AppSearchQuery;
import com.mosty.base.model.query.jcgl.TbJcglJzQuery;
import com.mosty.base.model.vo.jcgl.TbJcglJzAllVo;
import com.mosty.base.manager.service.TbJcglJzService;
import com.mosty.base.model.vo.jcgl.TbJcglJzVo;
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.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 勤务警组 前端控制器
 * </p>
 *
 * @author zengbo
 * @since 2022-06-30
 */
@Api(tags = {"勤务警组接口"})
@AllArgsConstructor
@RestController
@RequestMapping("/tbJcglJz")
public class TbJcglJzController {

    private final TbJcglJzService tbJcglJzService;

    @GetMapping({"/queryList"})
    @JwtSysUser
    @ApiOperation(value = "查询勤务警组列表")
    public ResponseResult<IPage<TbJcglJzAllVo>> queryList(TbJcglJzQuery tbJcglJzQuery) {
        return ResponseResult.success(this.tbJcglJzService.queryList(tbJcglJzQuery));
    }

    @PostMapping({"/addJz"})
    @JwtSysUser
    @Log(title = "新增勤务警组", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增勤务警组")
    public ResponseResult<Integer> addJz(@RequestBody TbJcglJzAllVo vo) {
        return ResponseResult.success(this.tbJcglJzService.saveJz(vo));
    }

    @PostMapping({"/updateJz"})
    @JwtSysUser
    @Log(title = "修改勤务警组", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改勤务警组")
    public ResponseResult<Integer> updateJz(@RequestBody TbJcglJzAllVo vo) {
        return ResponseResult.success(this.tbJcglJzService.updateJz(vo));
    }

    @GetMapping({"/selectByid"})
    @JwtSysUser
    @ApiOperation(value = "查询勤务警组详情")
    public ResponseResult<TbJcglJzAllVo> selectByid(String id) {
        return ResponseResult.success(this.tbJcglJzService.selectById(id));
    }

    @PostMapping({"/deleteJz"})
    @JwtSysUser
    @Log(title = "删除勤务警组", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除勤务警组")
    public ResponseResult<Boolean> deleteJz(@RequestBody List<String> list) {
        return ResponseResult.success(this.tbJcglJzService.deleteBatch(list));
    }

    @GetMapping("selectJzList")
    @JwtSysUser
    @ApiOperation(value = "app查询警组信息")
    public ResponseResult<Page<TbJcglJzAllVo>> selectJzList(AppSearchQuery dto) {
        return ResponseResult.success(this.tbJcglJzService.selectJzList(dto));
    }


    @GetMapping({"/tbJzQx"})
    @ApiOperation(value = "同步警组器械")
    public ResponseResult<Void> tbJzQx() {
        this.tbJcglJzService.tbJzQx();
        return ResponseResult.success();
    }
}

