package com.mosty.base.manager.controller;

import com.mosty.base.manager.service.TbSbGzjrService;
import com.mosty.base.model.entity.jcgl.TbSbGzjr;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "感知接入相关接口")
@RestController
@AllArgsConstructor
@RequestMapping("/gzjr")
public class TbSbGzjrController {

    private final TbSbGzjrService tbSbGzjrService;

    @ApiOperation("添加感知接入")
    @JwtSysUser
    @PostMapping
    @Log(title = "添加感知接入", businessType = BusinessType.INSERT)
    public ResponseResult<String> addEntity(@RequestBody TbSbGzjr dto) {
        return ResponseResult.success(this.tbSbGzjrService.addEntity(dto));
    }

    @ApiOperation("修改感知接入")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改感知接入", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbSbGzjr dto) {
        return ResponseResult.success(this.tbSbGzjrService.editEntity(dto));
    }

    @ApiOperation("批量删除感知接入")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "批量删除感知接入", businessType = BusinessType.DELETE)
    public ResponseResult<Void> deleteEntity(@RequestParam List<String> ids) {
        this.tbSbGzjrService.deleteEntity(ids);
        return ResponseResult.success();
    }

    @ApiOperation("查询感知接入列表")
    @JwtSysUser
    @PostMapping("/getList")
    public ResponseResult<List<TbSbGzjr>> getList(@RequestBody TbSbGzjr dto) {
        return ResponseResult.success(this.tbSbGzjrService.getList(dto));
    }

    @ApiOperation("查询感知接入详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbSbGzjr> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbSbGzjrService.getInfo(id));
    }


    @ApiOperation("根据id取消接入")
    @JwtSysUser
    @PostMapping("/qxjr")
    public ResponseResult<Integer> qxjrById(@RequestBody TbSbGzjr dto) {
        return ResponseResult.success(this.tbSbGzjrService.qxjr(dto));
    }



}
