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