Commit b99cbb59 authored by wujipeng's avatar wujipeng
Browse files

新增用户逻辑修改-优化

parent 19cbccd6
......@@ -13,7 +13,7 @@ import lombok.Data;
public class RelationShipDTO {
@ApiModelProperty(value = "id")
private String id;
private Integer id;
@ApiModelProperty(value = "用户名")
private String userName;
......
......@@ -69,34 +69,37 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public Boolean add(UserDTO userDTO) {
//数据转化成json
List<RelationShipDTO> relationShipList = userDTO.getRelationShipList();
//解析身份证号
Map<String, String> idCardInfo = IdCardUtils.parseIdCardInfo(userDTO.getIdCard());
if(MapUtil.isNotEmpty(idCardInfo)){
userDTO.setAge(Integer.parseInt(idCardInfo.get("age")));
userDTO.setSex(idCardInfo.get("sex"));
userDTO.setIdType("身份证");
}
if(!relationShipList.isEmpty()){
userDTO.setRelationShip(JSON.toJSONString(relationShipList));
}
save(userDTO);
//更新被选中人的关系
if(!relationShipList.isEmpty()){
for (RelationShipDTO relationShipDTO : relationShipList) {
//查询被选中人信息
UserEntity user = getById(relationShipDTO.getId());
//更新被选中人的关系
String relationShip = user.getRelationShip();
//关系反转
relationShipDTO.setId(userDTO.getId());
if(StringUtils.isNotEmpty(relationShip)){
String oldRelationShip = user.getRelationShip();
List<RelationShipDTO> oldRelationShipList = JSON.parseArray(oldRelationShip, RelationShipDTO.class);
oldRelationShipList.add(relationShipDTO);
user.setRelationShip(JSON.toJSONString(oldRelationShipList));
updateById(user);
}else {
List<RelationShipDTO> relationShipList1 = Lists.newArrayList();
relationShipList1.add(relationShipDTO);
user.setRelationShip(JSON.toJSONString(relationShipList1));
}
updateById(user);
}
String relationShip = JSON.toJSONString(relationShipList);
userDTO.setRelationShip(relationShip);
}
//解析身份证号
Map<String, String> idCardInfo = IdCardUtils.parseIdCardInfo(userDTO.getIdCard());
if(MapUtil.isNotEmpty(idCardInfo)){
userDTO.setAge(Integer.parseInt(idCardInfo.get("age")));
userDTO.setSex(idCardInfo.get("sex"));
userDTO.setIdType("身份证");
}
return save(userDTO);
return Boolean.TRUE;
}
}
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