|
@@ -1,10 +1,12 @@
|
|
|
package com.citu.module.menduner.system.service.person.info;
|
|
|
|
|
|
+import cn.hutool.core.codec.Base64Decoder;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.citu.framework.common.pojo.PageParam;
|
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
|
import com.citu.framework.common.util.validation.ValidationUtils;
|
|
|
+import com.citu.module.infra.api.file.FileApi;
|
|
|
import com.citu.module.menduner.common.dto.TimeRangeBaseReqVO;
|
|
|
import com.citu.module.menduner.common.util.LoginUserContext;
|
|
|
import com.citu.module.menduner.system.api.python.GraphSendDTO;
|
|
@@ -52,6 +54,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
|
|
|
@Resource
|
|
|
private GraphProducer graphProducer;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private FileApi fileApi;
|
|
|
+
|
|
|
@Override
|
|
|
@DSTransactional // 单机+多数据源方案,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
|
public Long createUserInfo(PersonInfoSaveReqVO createReqVO) {
|
|
@@ -198,6 +203,22 @@ public class PersonInfoServiceImpl implements PersonInfoService {
|
|
|
Long userId = LoginUserContext.getUserId();
|
|
|
PersonInfoDO info = personInfoMapper.selectOne(PersonInfoDO::getUserId, userId);
|
|
|
PersonInfoDO userInfo = BeanUtils.toBean(reqVO, PersonInfoDO.class);
|
|
|
+ if (null != reqVO.getAvatar()) {
|
|
|
+ if (reqVO.getAvatar().contains("base64")) {
|
|
|
+ // base64编码
|
|
|
+ // 截取, 之后的所有
|
|
|
+ int index = reqVO.getAvatar().indexOf(",");
|
|
|
+ byte[] data = Base64Decoder.decode(reqVO.getAvatar().substring(index + 1));
|
|
|
+ // 转为图片地址保存
|
|
|
+ String path = "person/" + userId + "/";
|
|
|
+ // 取字符当文件名称
|
|
|
+ String name = reqVO.getAvatar()
|
|
|
+ .substring(reqVO.getAvatar().length() - 10).replaceAll("/", "") + ".jpg";
|
|
|
+ reqVO.setAvatar(fileApi.createFile(reqVO.getName(), path + name, data));
|
|
|
+ }
|
|
|
+ // 头像
|
|
|
+ userInfo.setAvatar(reqVO.getAvatar());
|
|
|
+ }
|
|
|
userInfo.setUserId(userId);
|
|
|
if (null == info) {
|
|
|
personInfoMapper.insert(userInfo);
|