package com.mosty.base.manager.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.jcgl.TbJcglXfwgInsertDto;
import com.mosty.base.model.entity.jcgl.TbJcglXfwg;
import com.mosty.base.model.query.jcgl.TbJcglXfwgQuery;
import com.mosty.base.manager.service.TbJcglXfwgService;
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;

/**
 * <p>
 * 巡防网格 前端控制器
 * </p>
 *
 * @author zengbo
 * @since 2022-07-14
 */
@RestController
@AllArgsConstructor
@Api(tags = "巡防网格功能接口")
@RequestMapping("/tbJcglXfwg")
public class TbJcglXfwgController {

    private final TbJcglXfwgService tbJcglXfwgService;

    @GetMapping({"/queryList"})
    @JwtSysUser
    @ApiOperation(value = "查询巡防网格列表")
    public ResponseResult<IPage<TbJcglXfwgInsertDto>> queryList(TbJcglXfwgQuery dto) {
        return ResponseResult.success(tbJcglXfwgService.getXfwg(dto));
    }

    @PostMapping({"/addXfwg"})
    @JwtSysUser
    @Log(title = "新增巡防网格", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增巡防网格")
    public ResponseResult addXfwg(@RequestBody TbJcglXfwgInsertDto xfwg) {
        return ResponseResult.success(tbJcglXfwgService.addXfwg(xfwg));
    }

    @PostMapping({"/updateXfwg"})
    @JwtSysUser
    @Log(title = "修改巡防网格", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改巡防网格")
    public ResponseResult updateXfwg(@RequestBody TbJcglXfwgInsertDto xfwg) {
        return ResponseResult.success(tbJcglXfwgService.editXfwg(xfwg));
    }

    @GetMapping({"/selectById"})
    @JwtSysUser
    @ApiOperation(value = "查询巡防网格详情")
    public ResponseResult<TbJcglXfwgInsertDto> selectByid(String id) {
        return ResponseResult.success(tbJcglXfwgService.selectById(id));
    }

    @PostMapping({"/deleteXfwg"})
    @JwtSysUser
    @Log(title = "删除巡防网格", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除巡防网格")
    public ResponseResult deleteXfwg(@RequestBody List<String> list) {
        return ResponseResult.success(tbJcglXfwgService.deleteXfwg(list));
    }

}

