package com.hotent.baseInfo.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hotent.baseInfo.model.CostDistrict;
import com.hotent.baseInfo.dao.CostDistrictDao;
import com.hotent.baseInfo.manager.CostDistrictManager;
import com.hotent.base.manager.impl.BaseManagerImpl;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;

/**
 * 地区表 服务实现类
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-09-17
 */
@Service
public class CostDistrictManagerImpl extends BaseManagerImpl<CostDistrictDao, CostDistrict> implements CostDistrictManager {


	/**
	 * 根据pid获取区、市数据
	 * @param pid
	 * @return
	 */
	@Override
	public List<CostDistrict> getListByPid(Integer pid) {
		LambdaQueryWrapper<CostDistrict> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CostDistrict::getPid, pid);
		queryWrapper.eq(CostDistrict::getStatus, 0);
		return this.list(queryWrapper);
	}

	/**
	 * 获取省级数据
	 * @return
	 */
	@Override
	public List<CostDistrict> getProvinces() {
		LambdaQueryWrapper<CostDistrict> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CostDistrict::getLevel, 0);
		queryWrapper.eq(CostDistrict::getStatus, 0);
		return this.list(queryWrapper);
	}

	@Override
	public CostDistrict getByCode(String code) {
		LambdaQueryWrapper<CostDistrict> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CostDistrict::getCode, code);
		return this.getOne(queryWrapper,false);
	}

	@Override
	public List<CostDistrict> getDistrictTree() {
		return this.list();
	}


}
