姜锅说传来的code是对的,name不保证对,所以我忽略传来的name,用code自己找一个name

This commit is contained in:
liuchengqian 2023-11-09 16:13:51 +08:00
parent aba3b12135
commit 560105d2ca

View File

@ -126,6 +126,7 @@ public class SysUserServiceImpl implements SysUserService {
String countyCode = sysUserQo.getCountyCode();
String countyName = sysUserQo.getCountyName();
countyName = adapterCountyNameByCountyCode(countyCode);
if (TextUtils.isEmpty(countyCode)) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道编码不能为空!", locale);
}
@ -212,6 +213,34 @@ public class SysUserServiceImpl implements SysUserService {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale);
}
private String adapterCountyNameByCountyCode(String countyCode) {
if (9 == countyCode.length()) {
List<StreetEntity> streetCodeList = streetDao.findByStreetCode(countyCode);
if (streetCodeList == null || streetCodeList.isEmpty()) {
return null;
}
return streetCodeList.get(0).getStreetName();
} else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) {
return null;
}
return proCodeList.get(0).getProName();
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) {
return null;
}
return cityCodeList.get(0).getCityName();
} else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) {
return null;
}
return countyCodeList.get(0).getCountyName();
}
}
/**
* 适配2023-11-09到2023-11-12之间注册的街道用户
*/