package com.mosty.sjzx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.query.sjzx.TbSjQuery;
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.dto.sjzx.TbSjDto;
import com.mosty.base.model.dto.sjzx.TbSjQcszDto;
import com.mosty.base.model.dto.sjzx.TbSjRzDto;
import com.mosty.base.model.dto.sjzx.TbSjUpdateJwdDto;
import com.mosty.base.model.entity.sjzx.TbSj;
import com.mosty.base.model.query.sjzx.SearchDto;
import com.mosty.sjzx.service.TbSjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author dw
 * @since 2022/7/11
 **/
@AllArgsConstructor
@RestController
@RequestMapping("tbSj")
@Api(tags = "事件相关接口")
public class TbSjController {

    @Resource
    private TbSjService tbSjService;

    @GetMapping("/selectEventList")
    @ApiOperation(value = "大屏-地图-全局搜索")
    @JwtSysUser
    @Log(title = "大屏-地图-全局搜索", businessType = BusinessType.OTHER)
    public ResponseResult<Object> queryAll(SearchDto dto) {
        return ResponseResult.success(this.tbSjService.queryAll(dto));
    }

    @GetMapping("/getPageList")
    @ApiOperation(value = "查询事件列表")
    @JwtSysUser
    @Log(title = "查询事件列表", businessType = BusinessType.OTHER)
    public ResponseResult<IPage<TbSjDto>> getPageList(TbSjQuery dto) {
        return ResponseResult.success(this.tbSjService.getPageList(dto));
    }

    @GetMapping("selectById")
    @ApiOperation(value = "id查询单条")
    @Log(title = "id查询单条", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<TbSjDto> queryById(String id) {
        return ResponseResult.success(this.tbSjService.queryById(id));
    }

    @PostMapping
    @ApiOperation(value = "大屏-地图-手动新增事件")
    @Log(title = "新增事件信息", businessType = BusinessType.INSERT)
    @JwtSysUser
    public ResponseResult<TbSjDto> add(@RequestBody TbSj tbSj) {
        return ResponseResult.success(this.tbSjService.insert(tbSj));
    }

    @PutMapping
    @ApiOperation(value = "事件-圈层设置")
    @JwtSysUser
    @Log(title = "事件-圈层设置", businessType = BusinessType.UPDATE)
    public ResponseResult<Void> editQc(@RequestBody TbSjQcszDto dto) {
        this.tbSjService.editQc(dto);
        return ResponseResult.success();
    }

    @PutMapping("updateJwd")
    @ApiOperation(value = "事件-修改定位")
    @JwtSysUser
    @Log(title = "事件-修改定位", businessType = BusinessType.UPDATE)
    public ResponseResult<Void> updateJwd(@RequestBody TbSjUpdateJwdDto dto) {
        this.tbSjService.updateJwd(dto);
        return ResponseResult.success();
    }

    @PutMapping("addSjRz")
    @ApiOperation(value = "事件-记录日志")
    @JwtSysUser
    @Log(title = "事件-记录日志", businessType = BusinessType.UPDATE)
    public ResponseResult<Void> addSjRz(@RequestBody TbSjRzDto dto) {
        this.tbSjService.addSjRz(dto);
        return ResponseResult.success();
    }

    @DeleteMapping
    @ApiOperation(value = "id删除数据")
    @JwtSysUser
    @Log(title = "id删除数据", businessType = BusinessType.UPDATE)
    public ResponseResult<Boolean> deleteById(String id) {
        return ResponseResult.success(this.tbSjService.deleteById(id));
    }

    @PostMapping("finishDispose")
    @ApiOperation(value = "大屏-地图-完成处置")
    @Log(title = "大屏-地图-完成处置", businessType = BusinessType.UPDATE)
    @JwtSysUser
    public ResponseResult<Boolean> finishDispose(@RequestBody TbSj tbSj) {
        return ResponseResult.success(this.tbSjService.finishDispose(tbSj));
    }

    @GetMapping("bxdCreate")
    @ApiOperation(value = "计算必巡点数据")
    public ResponseResult<Object> bxdCreate() {
        return ResponseResult.success(this.tbSjService.bxdCreate());
    }

}


