/*
 * 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.TfCameraType;
import com.tofly.xrtygis.service.TfCameraTypeService;
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 Thu Jun 01 00:00:00 CST 2023
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tfcameratype")
@Api(tags="摄像头所属类型接口")
public class TfCameraTypeController {

    private final  TfCameraTypeService tfCameraTypeService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param tfCameraType 摄像头所属类型
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getTfCameraTypePage(Page page, @ModelAttribute TfCameraType tfCameraType) {
      return ResultRespone.success(tfCameraTypeService.page(page, Wrappers.query(tfCameraType)));
    }

    /**
     * @return
     */
    @GetMapping("/tree" )
    @ApiOperation(value = "获取树类型形结构")
    public ResultRespone getTfCameraTypeList() {
        return ResultRespone.success(tfCameraTypeService.getTfCameraTypeList());
    }

    /**
     * 通过id查询摄像头所属类型
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("id" ) String id) {
      return ResultRespone.success(tfCameraTypeService.getById(id));
    }

    /**
     * 新增摄像头所属类型
     * @param tfCameraType 摄像头所属类型
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增摄像头所属类型" )
    @ApiOperation(value = "新增摄像头所属类型")
    @PostMapping
    public ResultRespone save(@RequestBody TfCameraType tfCameraType) {
      return ResultRespone.success(tfCameraTypeService.save(tfCameraType));
    }

    /**
     * 修改摄像头所属类型
     * @param tfCameraType 摄像头所属类型
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改摄像头所属类型" )
    @ApiOperation(value = "修改摄像头所属类型")
    @PutMapping
    public ResultRespone updateById(@RequestBody TfCameraType tfCameraType) {
      return ResultRespone.success(tfCameraTypeService.updateById(tfCameraType));
    }

    /**
     * 通过id删除摄像头所属类型
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除摄像头所属类型" )
    @ApiOperation(value = "通过ID删除摄像头所属类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable String id) {
      return ResultRespone.success(tfCameraTypeService.removeById(id));
    }

    /**
     * 通过id批量删除摄像头所属类型
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(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(tfCameraTypeService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
