package com.cool.store.dao;

import com.cool.store.entity.RegionAreaConfigDO;
import com.cool.store.mapper.RegionAreaConfigMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @author wxp
 * @ClassName RegionAreaConfigDao
 * @Description 用一句话描述什么
 */
@Repository
public class RegionAreaConfigDao {

    @Resource
    private RegionAreaConfigMapper regionAreaConfigMapper;

    public void deleteRegionAreaConfigByRegionId(Long regionId) {
        if (regionId == null) {
            return;
        }
        regionAreaConfigMapper.deleteRegionAreaConfigByRegionId(regionId);
    }

    public void deleteByWantShopAreaIds(List<Long> wantShopAreaIds) {
        if (CollectionUtils.isEmpty(wantShopAreaIds)) {
            return;
        }
        regionAreaConfigMapper.deleteByWantShopAreaIds(wantShopAreaIds);
    }

    public void batchInsertOrUpdateRegionAreaConfig(List<RegionAreaConfigDO> regionAreaConfigList) {
        if (CollectionUtils.isEmpty(regionAreaConfigList)) {
            return;
        }
        regionAreaConfigMapper.batchInsertOrUpdateRegionAreaConfig(regionAreaConfigList);
    }

    public List<RegionAreaConfigDO> listAreaByRegionId(Long regionId){
        if (regionId == null) {
            return Collections.emptyList();
        }
        return regionAreaConfigMapper.listAreaByRegionId(regionId);
    }

    public List<RegionAreaConfigDO> listAreaByRegionIdList(List<Long> regionIdList){
        if (CollectionUtils.isEmpty(regionIdList)) {
            return Collections.emptyList();
        }
        return regionAreaConfigMapper.listAreaByRegionIdList(regionIdList);
    }

    public Long getByWantShopAreaId(Long wantShopAreaId){
        if (wantShopAreaId == null) {
            return 0L;
        }
        return regionAreaConfigMapper.getByWantShopAreaId(wantShopAreaId);
    }

}
