Compare commits
3 Commits
c3f1343ea9
...
2a35ec2152
Author | SHA1 | Date | |
---|---|---|---|
|
2a35ec2152 | ||
|
c655d47680 | ||
|
de3ae509d6 |
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.maku.maku.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -39,9 +38,8 @@ public class TUserServiceImpl extends BaseServiceImpl<TUserDao, TUserEntity> imp
|
|||
|
||||
private LambdaQueryWrapper<TUserEntity> getWrapper(TUserQuery query){
|
||||
LambdaQueryWrapper<TUserEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(TUserEntity::getUsername, query.getUsername());
|
||||
wrapper.eq(ObjectUtil.isNotNull(query.getStatus()), TUserEntity::getStatus, query.getStatus());
|
||||
|
||||
wrapper.like(ObjectUtils.isNotEmpty(query.getUsername()), TUserEntity::getUsername, query.getUsername());
|
||||
wrapper.eq(ObjectUtils.isNotEmpty(query.getStatus()), TUserEntity::getStatus, query.getStatus());
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
@ -72,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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user