package com.mosty.wzzx.controller;

import com.mosty.base.model.query.wzzx.TbWzLswzSearchDto;
import com.mosty.base.model.query.wzzx.TbWzSbLswzSearchDto;
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.entity.wzzx.TbWzXfwz;
import com.mosty.base.model.dto.wzzx.AppLocationReceiveDto;
import com.mosty.wzzx.service.TbWzXfwzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@AllArgsConstructor
@RestController
@Api(tags = "巡防位置相关接口")
@RequestMapping("/tbWzXfwz")
public class TbWzXfwzController {

    private final TbWzXfwzService tbWzXfwzService;

    @GetMapping
    @ApiOperation(value = "查询所有数据")
    @JwtSysUser
    public ResponseEntity<List> queryAll() {
        return ResponseEntity.ok(this.tbWzXfwzService.queryAll());
    }
    
    @GetMapping("{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    @JwtSysUser
    public ResponseEntity<TbWzXfwz> queryById(@PathVariable("id") String id) {
        return ResponseEntity.ok(this.tbWzXfwzService.queryById(id));
    }

    @PostMapping
    @ApiOperation(value = "新增数据")
    @JwtSysUser
    public ResponseEntity<TbWzXfwz> add(TbWzXfwz tbWzXfwz) {
        return ResponseEntity.ok(this.tbWzXfwzService.insert(tbWzXfwz));
    }

    @PutMapping
    @ApiOperation(value = "编辑数据")
    @JwtSysUser
    public ResponseEntity<TbWzXfwz> edit(TbWzXfwz tbWzXfwz) {
        return ResponseEntity.ok(this.tbWzXfwzService.update(tbWzXfwz));
    }

    @DeleteMapping
    @ApiOperation(value = "删除数据")
    @JwtSysUser
    public ResponseEntity<Boolean> deleteById(String id) {
        return ResponseEntity.ok(this.tbWzXfwzService.deleteById(id));
    }

    @PostMapping("/selectTrack")
    @ApiOperation(value = "大屏-地图-轨迹回放")
    @Log(title = "大屏-地图-轨迹回放", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult selectTrack(@RequestBody TbWzXfwz tbWzXfwz) {
        return ResponseResult.success(tbWzXfwzService.selectTrack(tbWzXfwz));
    }

    @PostMapping("/selectLswz")
    @ApiOperation(value = "历史位置轨迹回放")
    @Log(title = "历史位置轨迹回放", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult selectLswz(@RequestBody TbWzLswzSearchDto dto) {
        return ResponseResult.success(tbWzXfwzService.selectLswz(dto));
    }

    @PostMapping("/locationReceive")
    @ApiOperation(value = "接收app端位置数据")
    @Log(title = "接收app端位置数据", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult locationReceive(@RequestBody AppLocationReceiveDto receiveDto) {
        return ResponseResult.success(this.tbWzXfwzService.locationReceive(receiveDto));
    }

    @PostMapping("/selectSbLswz")
    @ApiOperation(value = "设备历史位置轨迹回放")
    @Log(title = "设备历史位置轨迹回放", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult selectSbLswz(@RequestBody TbWzSbLswzSearchDto dto) {
        return ResponseResult.success(tbWzXfwzService.selectSbLswz(dto));
    }

    @PostMapping("/selectSbLswzMo")
    @ApiOperation(value = "设备历史位置轨迹回放mo")
    @Log(title = "设备历史位置轨迹回放", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult selectSbLswzMo(@RequestBody TbWzSbLswzSearchDto dto) {
        return ResponseResult.success(tbWzXfwzService.selectSbLswzMo(dto));
    }

}


