package com.mosty.rzzx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
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.rzzx.TbRzSpbfInsertDto;
import com.mosty.base.model.entity.rzzx.TbRzSpbf;
import com.mosty.base.model.query.rzzx.TbRzSpbfQueryDto;
import com.mosty.rzzx.service.TbRzSpbfService;
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/12
 * 视频播放日志接口
 **/
@Api(tags = "视频巡逻方案-摄像头接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbSpxlSpxlfaSxt")
public class TbRzSpbfController {

    private final TbRzSpbfService tbRzSpbfService;

    @ApiOperation("视频开始播放")
    @JwtSysUser
    @Log(title = "视频开始播放", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseResult<Integer> insertEntity(@RequestBody TbRzSpbfInsertDto dto) {
        return ResponseResult.success(this.tbRzSpbfService.insertEntity(dto));
    }

    @ApiOperation("视频结束播放")
    @JwtSysUser
    @Log(title = "视频结束播放", businessType = BusinessType.UPDATE)
    @PutMapping("{id}")
    public ResponseResult<Integer> updateEntity(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbRzSpbfService.updateEntity(id));
    }

    @ApiOperation("视频播放日志分页查询")
    @JwtSysUser
    @Log(title = "视频结束播放", businessType = BusinessType.UPDATE)
    @GetMapping
    public ResponseResult<IPage<TbRzSpbf>> getPageList(TbRzSpbfQueryDto dto) {
        return ResponseResult.success(this.tbRzSpbfService.getPageList(dto));
    }

    @ApiOperation("查询视频日志详情信息")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbRzSpbf> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbRzSpbfService.getInfo(id));
    }
    @ApiOperation("来源id修改-视频结束播放")
    @JwtSysUser
    @Log(title = "来源id修改-视频结束播放", businessType = BusinessType.UPDATE)
    @PostMapping("updateLyId")
    public ResponseResult<Boolean> updateLyId(@RequestBody String lyId) {
        return ResponseResult.success(this.tbRzSpbfService.updateLyId(lyId));
    }

}
