Browse Source

微信小程序signup接口修改3

tags/B.2.6.4_20240106_base
yk 1 year ago
parent
commit
e84cf32bdb
2 changed files with 4 additions and 12 deletions
  1. +4
    -5
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/wechat/controller/WeappController.java
  2. +0
    -7
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/wechat/service/WeappService.java

+ 4
- 5
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/wechat/controller/WeappController.java View File

@@ -131,13 +131,12 @@ public class WeappController {
log.info("信息 phone:{}", phone);
R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(phone, SecurityConstants.INNER);

log.info("根据手机号获取用户信息返回:{}", loginInfoResult.getData().getEnterpriseName());
if (ObjectUtil.isNull(loginInfoResult.getData())) {
response.setStatus(500);
return AjaxResult.error("手机号可能错误,请查证后重试!", signUpReq);
if (ObjectUtil.isNull(loginInfoResult.getData()) || loginInfoResult.isFail()) {
log.info("根据手机号获取用户信息返回:{}", loginInfoResult.getData().getEnterpriseName());
response.setStatus(401);
return AjaxResult.error("手机号无对应员工,请查证后重试!");
} else {
Map<String, Object> map = tokenService.createToken(loginInfoResult.getData());
// map.put("openid", signUpReq.getOpenid());
return AjaxResult.success(map);
}
}


+ 0
- 7
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/wechat/service/WeappService.java View File

@@ -67,24 +67,17 @@ public class WeappService {
byte[] sessionKeyBytes = Base64.getDecoder().decode(obj.getSessionKey());
byte[] encryptedDataBytes = Base64.getDecoder().decode(encryptedData);
byte[] ivBytes = Base64.getDecoder().decode(iv);
log.info("sessionKeyBytes: {}", new String(sessionKeyBytes));
log.info("encryptedDataBytes: {}", new String(encryptedDataBytes));
log.info("ivBytes: {}", new String(ivBytes));

// 创建 AES 密钥对象
SecretKey secretKey = new SecretKeySpec(sessionKeyBytes, "AES");
log.info("secretKey: {} 1===", secretKey.getAlgorithm());

// 创建 AES 解密器
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
log.info("cipher: {} 2===", cipher.getAlgorithm());
cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(ivBytes));

// 解密
byte[] decryptedBytes = cipher.doFinal(encryptedDataBytes);
log.info("decryptedBytes: {} 3===", new String(decryptedBytes));
String decoded = new String(decryptedBytes, "UTF-8");
log.info("decoded: {} 4===", decoded);
return decoded;

}


Loading…
Cancel
Save