/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtygis.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.entity.Videoconfig;
import com.tofly.xrtygis.service.VideoconfigService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;

/**
 * 视频监控信息表
 *
 * @author admin
 * @date Fri Apr 02 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/videoconfig")
@Api(tags = " 视频监控信息表接口")
public class VideoconfigController {

    private final VideoconfigService videoconfigService;

    /**
     * 分页查询
     *
     * @param page        分页对象
     * @param videoconfig 视频监控信息表
     * @return
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone getVideoconfigPage(Page page, @ModelAttribute Videoconfig videoconfig) {
        return ResultRespone.success(videoconfigService.page(page, Wrappers.query(videoconfig)));
    }


    /**
     * 通过id查询 视频监控信息表
     *
     * @param groupName id
     * @return ResultRespone
     */
    @GetMapping("/{groupName}")
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupName", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("groupName") String groupName) {
        return ResultRespone.success(videoconfigService.getById(groupName));
    }

    /**
     * 新增 视频监控信息表
     *
     * @param videoconfig 视频监控信息表
     * @return ResultRespone
     */
    //(title = "新增 视频监控信息表")
    @ApiOperation(value = "新增 视频监控信息表")
    @PostMapping
    public ResultRespone save(@RequestBody Videoconfig videoconfig) {
        return ResultRespone.success(videoconfigService.save(videoconfig));
    }

    /**
     * 修改 视频监控信息表
     *
     * @param videoconfig 视频监控信息表
     * @return ResultRespone
     */
    //(title = "修改 视频监控信息表")
    @ApiOperation(value = "修改 视频监控信息表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Videoconfig videoconfig) {
        return ResultRespone.success(videoconfigService.updateById(videoconfig));
    }

    /**
     * 通过id删除 视频监控信息表
     *
     * @param groupName id
     * @return ResultRespone
     */
    //(title = "通过id删除 视频监控信息表")
    @ApiOperation(value = "通过ID删除 视频监控信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupName", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{groupName}")
    public ResultRespone removeById(@PathVariable String groupName) {
        return ResultRespone.success(videoconfigService.removeById(groupName));
    }

    /**
     * 通过id批量删除 视频监控信息表
     *
     * @param ids id
     * @return ResultRespone
     */
    //(title = "通过id批量删除 视频监控信息表")
    @ApiOperation(value = "通过ID批量删除 视频监控信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds")
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(videoconfigService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
