package com.njzscloud.supervisory.geo.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.geo.pojo.entity.GeoFenceConfigEntity;
import com.njzscloud.supervisory.geo.service.GeoFenceConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 地图栅栏配置
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/geo_fence_config")
@RequiredArgsConstructor
public class GeoFenceConfigController {

    private final GeoFenceConfigService geoFenceConfigService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody GeoFenceConfigEntity geoFenceConfigEntity) {
        geoFenceConfigService.add(geoFenceConfigEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody GeoFenceConfigEntity geoFenceConfigEntity) {
        geoFenceConfigService.modify(geoFenceConfigEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        geoFenceConfigService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<GeoFenceConfigEntity> detail(@RequestParam Long id) {
        return R.success(geoFenceConfigService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<GeoFenceConfigEntity>> paging(PageParam pageParam, GeoFenceConfigEntity geoFenceConfigEntity) {
        return R.success(geoFenceConfigService.paging(pageParam, geoFenceConfigEntity));
    }

}
