天融信用户设置默认随机邮箱

develop
bayuzhen 2024-08-29 23:33:38 +08:00
parent f77121c19a
commit f2861c2712
1 changed files with 13 additions and 11 deletions

View File

@ -32,10 +32,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@ -115,13 +112,10 @@ public class TrxServiceImpl implements TrxService {
JSONObject result = new JSONObject();
GeneralResult<Map<String, Object>> login = new GeneralResult<>();
try {
String requestData = "{ \"cookie\": \"" + trxAuthModel.getClientHello() + "\", \"Authen\": [ { \"loginName\": \"" + trxAuthModel.getLoginName() +
"\", \"passwd\": \"" + trxAuthModel.getPasswd() + "\" }, { \"certMd5\": \"" + trxAuthModel.getServerHello() + "\", \"value\": \"\", \"hashType\": \"\" }, " +
"{ \"passcode\": \"\" }, { \"df_code\": \"\" }, { \"client_ip\": \"" + trxAuthModel.getClientIp() + "\" } ] }";
HttpRequest httpRequest = HttpRequest.post(url)
.header("isToken", "false")
.body(requestData);
log.info("调用天融信用户登录接口, 请求方法" + httpRequest.getMethod() + ",参数:" + requestData);
.body(JSONObject.toJSONString(paramsMap));
log.info("调用天融信用户登录接口, 请求信息:" + JSONObject.toJSONString(httpRequest));
HttpResponse response = httpRequest.execute();
result = JSONObject.parseObject(response.body());
if (!"0".equals(result.getString("result"))) {
@ -156,6 +150,14 @@ public class TrxServiceImpl implements TrxService {
params.put("userId", userId);
//请求运控系统获取用户信息
YkUserModel ykUser = JSONArray.parseArray(ykUtils.call(YkInf.queryAllUser, params, String.class), YkUserModel.class).get(0);
// 处理邮箱
Random random = new Random();
// 生成指定长度的随机数字字符串
StringBuilder emailStr = new StringBuilder(9);
for (int i = 0; i < 9; i++) {
emailStr.append(random.nextInt(10)); // 生成 0 到 9 之间的随机数字
}
String email = emailStr.toString() + "@163.com";
if (ObjectUtils.isEmpty(user)) {
log.info("开始新增天融信登录用户userId: " + userId);
// 新增 以userId作为account 并添加注释
@ -169,7 +171,7 @@ public class TrxServiceImpl implements TrxService {
userBean.setAccount(ykUser.getLoginName());
userBean.setName(ykUser.getUserName());
userBean.setMobile(ykUser.getMobile());
userBean.setEmail(ykUser.getEmail());
userBean.setEmail(ykUser.getEmail() == null ? email : ykUser.getEmail());
userBean.setUserId(userId);
RequestContext context = new RequestContext();
context.setTarget(1L);
@ -197,7 +199,7 @@ public class TrxServiceImpl implements TrxService {
userBean.setAccount(ykUser.getLoginName());
userBean.setName(ykUser.getUserName());
userBean.setMobile(ykUser.getMobile());
userBean.setEmail(ykUser.getEmail());
userBean.setEmail(ykUser.getEmail() == null ? email : ykUser.getEmail());
RequestContext context = new RequestContext();
context.setTarget(1L);
context.setCatalog(RequestContext.Catalog.Manager);