From f2861c27127ce891e56e7fbd8394a9f90b9df3e8 Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Thu, 29 Aug 2024 23:33:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E8=9E=8D=E4=BF=A1=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E9=9A=8F=E6=9C=BA=E9=82=AE?= =?UTF-8?q?=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bocloud/sms/service/TrxServiceImpl.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java index b9630de..f5bb1db 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java @@ -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> 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);