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.jcgl.TbJcglXfqyDto;
import com.mosty.base.model.dto.qwzx.AppSearchQuery;
import com.mosty.base.model.entity.jcgl.TbJcglXfqy;
import com.mosty.base.model.query.hczx.RyClTjQuery;
import com.mosty.base.model.query.jcgl.TbJcglXfqyQuery;
import com.mosty.base.manager.service.TbJcglXfqyService;
import com.mosty.base.model.query.jcgl.XfqyQuery;
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;
import java.util.Map;

/**
 * @author zengbo
 * @since 2022-07-14
 */
@RestController
@AllArgsConstructor
@Api(tags = "巡防区域功能接口")
@RequestMapping("/tbJcglXfqy")
public class TbJcglXfqyController {

    private final TbJcglXfqyService tbJcglXfqyService;

    @GetMapping({"/queryList"})
    @JwtSysUser
    @ApiOperation(value = "查询巡防区列表")
    public ResponseResult<IPage<TbJcglXfqyDto>> queryList(TbJcglXfqyQuery xfqyQuery) {
        return ResponseResult.success(tbJcglXfqyService.getXfqy(xfqyQuery));
    }

    @PostMapping({"/addXfqy"})
    @JwtSysUser
    @Log(title = "新增巡防区域", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增巡防区域")
    public ResponseResult<Integer> addXfqy(@RequestBody TbJcglXfqyDto xfqy) {
        return ResponseResult.success(tbJcglXfqyService.addXfqy(xfqy));
    }

    @PostMapping({"/updateXfqy"})
    @JwtSysUser
    @Log(title = "修改巡防区域", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改巡防区域")
    public ResponseResult<Integer> updateXfqy(@RequestBody TbJcglXfqyDto xfqy) {
        return ResponseResult.success(tbJcglXfqyService.editXfqy(xfqy));
    }

    @GetMapping({"/selectById"})
    @JwtSysUser
    @ApiOperation(value = "查询巡防区域详情")
    public ResponseResult<TbJcglXfqyDto> selectByid(String id) {
        return ResponseResult.success(tbJcglXfqyService.selectById(id));
    }

    @PostMapping({"/deleteXfqy"})
    @JwtSysUser
    @Log(title = "删除巡防区域", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除巡防区域")
    public ResponseResult<Integer> deleteXfqy(@RequestBody List<String> list) {
        return ResponseResult.success(tbJcglXfqyService.deleteXfqy(list));
    }

    @GetMapping("/getXfqList")
    @JwtSysUser
    @ApiOperation(value = "app获取巡防区域信息")
    public ResponseResult<Page<TbJcglXfqy>> getXfqList(AppSearchQuery dto) {
        return ResponseResult.success(tbJcglXfqyService.getXfqList(dto));
    }

    // 泸州态势统计-各区县重点巡防区域
    @ApiOperation("泸州态势统计-各区县重点巡防区域")
    @PostMapping("/getZdxfqy")
    @JwtSysUser
    public ResponseResult<Map<String,Object>> getZdxfqy(XfqyQuery dto) {
        return ResponseResult.success(this.tbJcglXfqyService.getZdxfqy(dto));
    }

    // 泸州态势统计-各区县重点巡防区域
    @ApiOperation("泸州态势统计-警情与重点区域巡逻对比分析")
    @PostMapping("/getJqandQyxf")
    @JwtSysUser
    public ResponseResult<Map<String,Object>> getJqandQyxf(XfqyQuery dto) {
        return ResponseResult.success(this.tbJcglXfqyService.getJqandQyxf(dto));
    }

    // 查询所有巡防区域数据
    @ApiOperation("查询所有巡防区域数据")
    @PostMapping("/getListAll")
    @JwtSysUser
    public ResponseResult<List<TbJcglXfqyDto>> getListAll() {
        return ResponseResult.success(this.tbJcglXfqyService.getListAll());
    }

}

