package com.mosty.spxl.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.spxl.TbSpxlSpxlfaUpdateDto;
import com.mosty.base.model.entity.spxl.TbSpxlSpxlfa;
import com.mosty.base.model.query.spxl.TbSpxlSpxlfaQuery;
import com.mosty.spxl.service.TbSpxlSpxlfaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author dw
 * @since 2022/7/11
 **/
@Api(tags = "视频巡逻方案接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbSpxlSpxlfa")
public class TbSpxlSpxlfaController {

    private final TbSpxlSpxlfaService tbSpxlSpxlfaService;

    @ApiOperation("新增视频巡逻方案")
    @JwtSysUser
    @PostMapping
    @Log(title = "新增视频巡逻方案", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbSpxlSpxlfa fa) {
        return ResponseResult.success(this.tbSpxlSpxlfaService.addEntity(fa));
    }

    @ApiOperation("删除视频巡逻方案")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "删除视频巡逻方案", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> delEntity(@RequestBody List<String> ids) {
        return ResponseResult.success(this.tbSpxlSpxlfaService.delEntity(ids));
    }

    @ApiOperation("修改视频巡逻方案")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改视频巡逻方案", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> updateEntity(@RequestBody TbSpxlSpxlfaUpdateDto dto) {
        return ResponseResult.success(this.tbSpxlSpxlfaService.updateEntity(dto));
    }

    @ApiOperation("查询视频方案分页列表")
    @JwtSysUser
    @GetMapping("queryPage")
    public ResponseResult<IPage<TbSpxlSpxlfa>> queryPage(TbSpxlSpxlfaQuery dto) {
        return ResponseResult.success(this.tbSpxlSpxlfaService.queryPage(dto));
    }

    @ApiOperation("查询视频方案详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbSpxlSpxlfa> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbSpxlSpxlfaService.getInfo(id));
    }
}
