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