package com.neusoft.smart.pos.org.repository;

import com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionary;
import com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionaryExample;
import com.neusoft.smart.pos.org.persistent.mapper.CityRegionDictionaryMapper;

import lombok.val;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author tjm
 * @date 2018-03-01 13：57
 * @description 省市管理使用Repository
 */
@Component
public class CityRegionDictionaryRepository {

	@Autowired
	public CityRegionDictionaryMapper cityRegionDictionaryMapper;

	/**
	 * 查询所有一级省市
	 * @param 
	 * @return
	 */
	public List<CityRegionDictionary> getAllProvinces(){
		val example = new CityRegionDictionaryExample();
		example.createCriteria()
				.andLevelEqualTo(1)
				.andIsEnableEqualTo(0);
		return cityRegionDictionaryMapper.selectByExample(example);
	}
	
	/**
	 * 根据省ID查询所属市使用方法
	 * @param id：省ID
	 * @return
	 */
	public List<CityRegionDictionary> getCitysById(Integer parentId){
		val example = new CityRegionDictionaryExample();
		example.createCriteria()
				.andParentNumberEqualTo(parentId)
				.andIsEnableEqualTo(0);
		return cityRegionDictionaryMapper.selectByExample(example);
	}

}
