package com.njzscloud.supervisory.geo.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.geo.mapper.GeoFenceConfigMapper;
import com.njzscloud.supervisory.geo.pojo.entity.GeoFenceConfigEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 地图栅栏配置
 */
@Slf4j
@Service
public class GeoFenceConfigService extends ServiceImpl<GeoFenceConfigMapper, GeoFenceConfigEntity> implements IService<GeoFenceConfigEntity> {

    /**
     * 新增
     */
    public void add(GeoFenceConfigEntity geoFenceConfigEntity) {
        this.save(geoFenceConfigEntity);
    }

    /**
     * 修改
     */
    public void modify(GeoFenceConfigEntity geoFenceConfigEntity) {
        this.updateById(geoFenceConfigEntity);
    }

    /**
     * 删除
     */
    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     */
    public GeoFenceConfigEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     */
    public PageResult<GeoFenceConfigEntity> paging(PageParam pageParam, GeoFenceConfigEntity geoFenceConfigEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<GeoFenceConfigEntity>query(geoFenceConfigEntity)));
    }

}
