修改异常

This commit is contained in:
2025-07-12 23:58:57 +08:00
parent 49b4add58d
commit 4f4ae78168

View File

@ -1,5 +1,6 @@
package com.sczx.user.service.impl;
import com.sczx.user.exception.BizException;
import com.sczx.user.model.LoginRequest;
import com.sczx.user.service.IUserService;
import com.sczx.user.util.JwtUtil;
@ -76,7 +77,7 @@ public class UserServiceImpl implements IUserService {
public String miniProgramLogin(String code) {
String openid = WECHAT_CODE_TO_OPENID.get(code);
if (openid == null) {
throw new RuntimeException("无效的微信登录code");
throw new BizException("无效的微信登录code");
}
// 存入 Redis
return jwtUtil.generateToken(openid, "USER");
@ -86,7 +87,7 @@ public class UserServiceImpl implements IUserService {
public String miniProgramRegister(String code, String username, String password) {
String openid = WECHAT_CODE_TO_OPENID.get(code);
if (openid == null) {
throw new RuntimeException("无效的微信登录code");
throw new BizException("无效的微信登录code");
}
// 模拟注册逻辑
// userRepository.save(new User(openid, username, password));
@ -97,7 +98,7 @@ public class UserServiceImpl implements IUserService {
public String alipayMiniProgramLogin(String userId) {
String realUserId = ALIPAY_ID_TO_USERID.get(userId);
if (realUserId == null) {
throw new RuntimeException("无效的支付宝用户ID");
throw new BizException("无效的支付宝用户ID");
}
return jwtUtil.generateToken(realUserId, "USER");
}
@ -106,7 +107,7 @@ public class UserServiceImpl implements IUserService {
public String alipayMiniProgramRegister(String userId, String username, String password) {
String realUserId = ALIPAY_ID_TO_USERID.get(userId);
if (realUserId == null) {
throw new RuntimeException("无效的支付宝用户ID");
throw new BizException("无效的支付宝用户ID");
}
// 模拟注册逻辑
// userRepository.save(new User(realUserId, username, password));