package com.mosty.base.manager.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.jcgl.TbJcglBxxDto;
import com.mosty.base.model.query.jcgl.TbJcglBxxQuery;
import com.mosty.base.manager.service.TbJcglBxxService;
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 = {"巡防区域必巡线接口"})
@AllArgsConstructor
@RestController
@RequestMapping("/tbJcglBxx")
public class TbJcglBxxController {

    private final TbJcglBxxService tbJcglBxxService;

    @GetMapping({"/queryList"})
    @JwtSysUser
    @ApiOperation(value = "查询必巡线列表")
    public ResponseResult<IPage<TbJcglBxxDto>> queryList(TbJcglBxxQuery bxxQuery) {
        return ResponseResult.success(tbJcglBxxService.queryBxx(bxxQuery));
    }

    @PostMapping({"/addBxx"})
    @JwtSysUser
    @Log(title = "新增必巡线", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增必巡线")
    public ResponseResult<Integer> addBxx(@RequestBody TbJcglBxxDto bxx) {
        return ResponseResult.success(tbJcglBxxService.addBxx(bxx));
    }

    @PostMapping({"/updateBxx"})
    @JwtSysUser
    @Log(title = "修改必巡线", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改必巡线")
    public ResponseResult<Integer> updateBxx(@RequestBody TbJcglBxxDto bxx) {
        return ResponseResult.success(tbJcglBxxService.editBxx(bxx));
    }

    @GetMapping({"/selectById"})
    @JwtSysUser
    @ApiOperation(value = "查询必巡线详情")
    public ResponseResult<TbJcglBxxDto> selectByid(String id) {
        return ResponseResult.success(tbJcglBxxService.selectById(id));
    }

    @PostMapping({"/deleteBxx"})
    @JwtSysUser
    @Log(title = "删除必巡线", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除必巡线")
    public ResponseResult<Integer>  deleteBxx(@RequestBody List<String> list) {
        return ResponseResult.success(tbJcglBxxService.deleteBxx(list));
    }

}

