49 lines
1.3 KiB
Java
49 lines
1.3 KiB
Java
package com.mca.cmmn.service;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.mca.cmmn.mapper.AreaCodeMapper;
|
|
import com.mca.cmmn.vo.AreaCodeVO;
|
|
|
|
@Service("areaCodeService")
|
|
public class AreaCodeService {
|
|
|
|
@Resource(name="areaCodeMapper")
|
|
AreaCodeMapper areaCodeMapper;
|
|
|
|
public List<?> selectCity() throws Exception {
|
|
// TODO Auto-generated method stub
|
|
return areaCodeMapper.selectCity();
|
|
}
|
|
|
|
|
|
public List<?> selectCounty(String code, String area) throws Exception {
|
|
// TODO Auto-generated method stub
|
|
code = code + "___";
|
|
AreaCodeVO areaCodeVO = new AreaCodeVO();
|
|
areaCodeVO.setCode(code);
|
|
return areaCodeMapper.selectCounty(areaCodeVO);
|
|
}
|
|
|
|
|
|
public String selectAreaName(String code) throws Exception{
|
|
// TODO Auto-generated method stub
|
|
String areaName = null;
|
|
if(code.length() == 5){
|
|
areaName = areaCodeMapper.selectAreaName(code.substring(0, 2));
|
|
areaName = areaName + " " + areaCodeMapper.selectAreaName(code);
|
|
}else if(code.length() == 8){
|
|
areaName = areaCodeMapper.selectAreaName(code.substring(0, 2));
|
|
areaName = areaName + " " + areaCodeMapper.selectAreaName(code.substring(0, 5));
|
|
areaName = areaName + " " + areaCodeMapper.selectAreaName(code);
|
|
}else {
|
|
areaName = areaCodeMapper.selectAreaName(code);
|
|
}
|
|
return areaName;
|
|
}
|
|
}
|