Commit 19cbccd6 authored by wujipeng's avatar wujipeng
Browse files

新增用户逻辑修改

parent 9704da5d
package com.platform.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.platform.mapper.UserMapper;
import com.platform.model.dto.RelationShipDTO;
import com.platform.model.dto.UserDTO;
......@@ -13,11 +15,15 @@ import com.platform.model.vo.UserVO;
import com.platform.service.UserAccountService;
import com.platform.service.UserService;
import com.platform.utils.DozerUtils;
import com.platform.utils.IdCardUtils;
import com.platform.utils.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
......@@ -64,9 +70,33 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
//数据转化成json
List<RelationShipDTO> relationShipList = userDTO.getRelationShipList();
if(!relationShipList.isEmpty()){
for (RelationShipDTO relationShipDTO : relationShipList) {
//查询被选中人信息
UserEntity user = getById(relationShipDTO.getId());
//更新被选中人的关系
String relationShip = user.getRelationShip();
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));
}
}
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);
}
}
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