package com.mosty.sjzx.controller;

import com.mosty.base.model.dto.sjzx.TbSjSpbfDTO;
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.sjzx.TbSjSpbf;
import com.mosty.sjzx.service.TbSjSpbfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("tbSjSpbf")
@Api("事件-视频播放日志")
@AllArgsConstructor
public class TbSjSpbfController {

    @Resource
    private TbSjSpbfService tbSjSpbfService;

    @ApiOperation("查询视频播放日志所有")
    @JwtSysUser
    @Log(title = "查询视频播放日志所有", businessType = BusinessType.OTHER)
    @GetMapping("All")
    public ResponseResult<List> queryAll() {
        return ResponseResult.success(this.tbSjSpbfService.queryAll());
    }

    @ApiOperation("视频播放日志详情")
    @JwtSysUser
    @Log(title = "视频播放日志详情", businessType = BusinessType.OTHER)
    @GetMapping("{id}")
    public ResponseResult<TbSjSpbf> queryById(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbSjSpbfService.queryById(id));
    }

    @ApiOperation("视频播放日志新增")
    @JwtSysUser
    @Log(title = "视频播放日志新增", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public ResponseResult<TbSjSpbfDTO> add(@RequestBody TbSjSpbfDTO dto) {
        return ResponseResult.success(this.tbSjSpbfService.insert(dto));
    }

    @ApiOperation("视频播放日志修改")
    @JwtSysUser
    @Log(title = "视频播放日志修改", businessType = BusinessType.UPDATE)
    @PutMapping("update")
    public ResponseResult<TbSjSpbf> edit(TbSjSpbf tbSjSpbf) {
        return ResponseResult.success(this.tbSjSpbfService.update(tbSjSpbf));
    }

    @ApiOperation("视频播放日志删除")
    @JwtSysUser
    @Log(title = "视频播放日志删除", businessType = BusinessType.DELETE)
    @DeleteMapping("{id}")
    public ResponseResult<Boolean> deleteById(String id) {
        return ResponseResult.success(this.tbSjSpbfService.deleteById(id));
    }

}


