修改用户注册接口

This commit is contained in:
muhua 2024-07-13 17:06:13 +08:00
parent a3f06f2f95
commit 764a788671
1 changed files with 22 additions and 18 deletions

View File

@ -46,7 +46,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
@Override
public R<String> register(UserRegisterDTO userRegisterDTO) {
if (checkUser(userRegisterDTO)){
try {
if (checkUser(userRegisterDTO)) {
return R.fail("用户已被注册");
}
String password = desUtil.SHA512(userRegisterDTO.getPassword());
@ -57,14 +58,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
.status(1)
.build();
int insert = baseMapper.insert(user);
if (insert == 1){
if (insert == 1) {
Map<String, String> map = new HashMap<>();
map.put("id", user.getId().toString());
String token = JwtUtil.getToken(map, CommonConstant.TOKEN_EXPIRE_TIME);
redisService.hSet(CommonConstant.LOGIN_USER, user.getId().toString(), user, CommonConstant.EXPIRE_TIME);
return R.ok(token);
}
return R.ok("注册失败");
} catch (Exception e){
e.printStackTrace();
}
return null;
}
@Override