修改用户注册接口
This commit is contained in:
parent
a3f06f2f95
commit
764a788671
|
@ -46,25 +46,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||
|
||||
@Override
|
||||
public R<String> register(UserRegisterDTO userRegisterDTO) {
|
||||
if (checkUser(userRegisterDTO)){
|
||||
return R.fail("用户已被注册");
|
||||
try {
|
||||
if (checkUser(userRegisterDTO)) {
|
||||
return R.fail("用户已被注册");
|
||||
}
|
||||
String password = desUtil.SHA512(userRegisterDTO.getPassword());
|
||||
User user = User.builder()
|
||||
.username(userRegisterDTO.getUsername())
|
||||
.password(password)
|
||||
.phone(userRegisterDTO.getPhone())
|
||||
.status(1)
|
||||
.build();
|
||||
int insert = baseMapper.insert(user);
|
||||
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);
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
String password = desUtil.SHA512(userRegisterDTO.getPassword());
|
||||
User user = User.builder()
|
||||
.username(userRegisterDTO.getUsername())
|
||||
.password(password)
|
||||
.phone(userRegisterDTO.getPhone())
|
||||
.status(1)
|
||||
.build();
|
||||
int insert = baseMapper.insert(user);
|
||||
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("注册失败");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue