用户端注册退出登录修改

This commit is contained in:
xiaoqiantx223 2024-07-18 14:08:50 +08:00
parent de3ae509d6
commit c655d47680
2 changed files with 4 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.List;
import java.util.UUID;
/**
*
@ -54,7 +55,9 @@ public class TUserController {
public Result login(@RequestBody TUserEntity entity){
TUserEntity entity1 = tUserService.login(entity);
if(ObjectUtils.isNotNull(entity1)){
return Result.ok(entity1);
String token = UUID.randomUUID()+"";
redisCache.set(token,entity1);
return Result.ok(token);
}else {
return Result.error("登录失败");
}
@ -73,9 +76,6 @@ public class TUserController {
@Operation(summary = "退出登录")
public Result<String> logout(HttpServletRequest request) {
String token = request.getHeader("token");
if (token == null) {
return Result.error("token为空");
}
Object o = redisCache.get(token);
if (o != null) {
redisCache.delete(token);

View File

@ -70,9 +70,6 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
wrapper.eq(TUserEntity::getPassword, entity.getPassword());
TUserEntity one = getOne(wrapper);
if(ObjectUtils.isNotNull(one)) {
UUID uuid = UUID.randomUUID();
one.setAvatar(uuid.toString());
updateById(one);
return one;
}
return null;