package com.mosty.base.manager.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.entity.jcgl.TbJcglBxd;
import com.mosty.base.model.query.jcgl.TbJcglBxdQuery;
import com.mosty.base.manager.service.TbJcglBxdService;
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;
import java.util.Map;

@Api(tags = {"巡防区域必巡点接口"})
@AllArgsConstructor
@RestController
@RequestMapping("/tbJcglBxd")
public class TbJcglBxdController {

    private final TbJcglBxdService tbJcglBxdService;

    @GetMapping({"/queryList"})
    @JwtSysUser
    @ApiOperation(value = "查询必巡点列表")
    public ResponseResult<IPage<TbJcglBxd>> queryList(TbJcglBxdQuery bxdQuery) {
        return ResponseResult.success(tbJcglBxdService.queryBxd(bxdQuery));
    }

    @PostMapping({"/addBxd"})
    @JwtSysUser
    @Log(title = "新增必巡点", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增必巡点")
    public ResponseResult addBxd(@RequestBody TbJcglBxd bxd) {
        return ResponseResult.success(tbJcglBxdService.addBxd(bxd));
    }

    @PostMapping({"/updateBxd"})
    @JwtSysUser
    @Log(title = "修改必巡点", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改必巡点")
    public ResponseResult updateBxd(@RequestBody TbJcglBxd bxd) {
        return ResponseResult.success(tbJcglBxdService.editBxd(bxd));
    }

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

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

    @PostMapping({"/createdBxd"})
    @ApiOperation(value = "自动计算的必巡点添加")
    public ResponseResult createdBxd(@RequestBody List<Map<String, Object>> list) {
        tbJcglBxdService.createdBxd(list);
        return ResponseResult.success();
    }
}

