package com.mosty.yjzl.controller;

import com.mosty.base.model.dto.yjzl.TbFzycXljlDto;
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
import com.mosty.base.model.entity.yjzl.TbFzycXljl;
import com.mosty.base.model.vo.wzzx.TbWzSblswzVo;
import com.mosty.base.model.vo.yjzl.TbFzJlVo;
import com.mosty.base.model.vo.yjzl.TbFzycPzVo;
import com.mosty.base.model.vo.yjzl.TbFzycXljlVo;
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.yjzl.service.TbFzycPzService;
import com.mosty.yjzl.service.TbFzycXljlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "犯罪预测巡逻记录接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbFzycXljl")
public class TbFzycXljlController {

    private TbFzycXljlService tbFzycXljlService;

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "犯罪预测巡逻记录新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbFzycXljlVo vo) {
        return ResponseResult.success(tbFzycXljlService.insert(vo));
    }

    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "犯罪预测巡逻记录更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbFzycXljlVo vo) {
        return ResponseResult.success(tbFzycXljlService.updateById(vo));
    }

    @ApiOperation("删除数据")
    @JwtSysUser
    @DeleteMapping("/{id}")
    @Log(title = "犯罪预测巡逻记录删除", businessType = BusinessType.DELETE)
    public ResponseResult<Integer> update(@PathVariable("id") String id) {
        return ResponseResult.success(tbFzycXljlService.deleteById(id));
    }

    @ApiOperation("根据ID查询")
    @JwtSysUser
    @GetMapping("/{id}")
    @Log(title = "根据ID查询", businessType = BusinessType.OTHER)
    public ResponseResult<TbFzycXljl> queryById(@PathVariable("id") String id) {
        return ResponseResult.success(tbFzycXljlService.queryById(id));
    }

    @ApiOperation("查询犯罪预警预测指令巡逻记录列表")
    @JwtSysUser
    @GetMapping("/qfzxl")
    @Log(title = "查询犯罪预警预测指令巡逻记录列表", businessType = BusinessType.OTHER)
    public ResponseResult<List<TbFzycXljlDto>> qfzxl(String id) {
        return ResponseResult.success(tbFzycXljlService.qfzxl(id));
    }

    @ApiOperation("新增数据")
    @PostMapping("/addBySbwz")
    @Log(title = "通过设备位置新增犯罪预测巡逻记录", businessType = BusinessType.INSERT)
    public ResponseResult<Void> addBySbwz(@RequestBody TbFzJlVo vo) {
        tbFzycXljlService.addBySbwz(vo);
        return ResponseResult.success();
    }

}
