Commit cc1c67ea authored by 技术部-任文超's avatar 技术部-任文超

改善Json对空字符串容错性

parent 74a026a7
...@@ -979,13 +979,9 @@ public class InnerController implements IBaseController { ...@@ -979,13 +979,9 @@ public class InnerController implements IBaseController {
String district, String district,
String address, String address,
String contacts, @RequestParam(defaultValue = "0", required = false) Long btRegisterChannelId) { String contacts, @RequestParam(defaultValue = "0", required = false) Long btRegisterChannelId) {
log.info("[/innerapi/user/save_multi]保存用户、联系人、地址信息:registeredFrom:[{}], phoneNo[{}],name[{}],idNo[{}],provinceCode[{}],cityCode[{}],districtCode[{}]," +
"address[{}],contacts[{}]", registeredFrom, phoneNo, name, idNo, provinceCode, cityCode, districtCode, address, contacts);
if (!NumberUtils.isDigits(registeredFrom)) { if (!NumberUtils.isDigits(registeredFrom)) {
return JsonResult.buildErrorStateResult("注册渠道异常.", null); return JsonResult.buildErrorStateResult("注册渠道异常.", null);
} }
if (!ValidationUtil.validatePhoneNo(phoneNo)) { if (!ValidationUtil.validatePhoneNo(phoneNo)) {
return JsonResult.buildErrorStateResult("手机号异常.", null); return JsonResult.buildErrorStateResult("手机号异常.", null);
} }
...@@ -1002,7 +998,6 @@ public class InnerController implements IBaseController { ...@@ -1002,7 +998,6 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("用户身份证号异常.", null); return JsonResult.buildErrorStateResult("用户身份证号异常.", null);
} }
Address addressObj = null; Address addressObj = null;
//地址信息,同时存在provinceCode和address时才校验地址信息 //地址信息,同时存在provinceCode和address时才校验地址信息
if (StringUtils.isNotEmpty(provinceCode) && StringUtils.isNotEmpty(address)) { if (StringUtils.isNotEmpty(provinceCode) && StringUtils.isNotEmpty(address)) {
...@@ -1038,7 +1033,6 @@ public class InnerController implements IBaseController { ...@@ -1038,7 +1033,6 @@ public class InnerController implements IBaseController {
addressObj.setAddress(address); addressObj.setAddress(address);
} }
channelId = MoreObjects.firstNonNull(channelId, "-1"); channelId = MoreObjects.firstNonNull(channelId, "-1");
// 验证用户是否已存在 // 验证用户是否已存在
User user = userService.findByPhoneInDb(phoneNo); User user = userService.findByPhoneInDb(phoneNo);
...@@ -1047,9 +1041,8 @@ public class InnerController implements IBaseController { ...@@ -1047,9 +1041,8 @@ public class InnerController implements IBaseController {
} }
List<Contact> contactList = null; List<Contact> contactList = null;
if (contacts != null) { if (StringUtils.isNotBlank(contacts)) {
contactList = JSONObject.parseObject(contacts, new TypeReference<List<Contact>>() { contactList = JSONObject.parseObject(contacts, new TypeReference<List<Contact>>(){});
});
for (Contact contact : contactList) { for (Contact contact : contactList) {
contact.setRelation(contact.getRelation() == null ? Relation.OTHER : contact.getRelation()); contact.setRelation(contact.getRelation() == null ? Relation.OTHER : contact.getRelation());
Tuple<String, Boolean> stringBooleanTuple = contact.validAndResult(); Tuple<String, Boolean> stringBooleanTuple = contact.validAndResult();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment