|
@@ -9,6 +9,7 @@ import io.qifan.infrastructure.common.exception.BusinessException;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.babyfish.jimmer.client.FetchBy;
|
|
import org.babyfish.jimmer.client.FetchBy;
|
|
import org.babyfish.jimmer.sql.EnableDtoGeneration;
|
|
import org.babyfish.jimmer.sql.EnableDtoGeneration;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
@@ -19,6 +20,7 @@ import java.util.Optional;
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class UserController {
|
|
public class UserController {
|
|
private final UserRepository userRepository;
|
|
private final UserRepository userRepository;
|
|
|
|
+ private final RedisTemplate<String,String> redisTemplate;
|
|
|
|
|
|
@GetMapping
|
|
@GetMapping
|
|
public @FetchBy(value = "FETCHER", ownerType = UserRepository.class) User userInfo() {
|
|
public @FetchBy(value = "FETCHER", ownerType = UserRepository.class) User userInfo() {
|
|
@@ -34,6 +36,7 @@ public class UserController {
|
|
throw new BusinessException("用户名/密码错误");
|
|
throw new BusinessException("用户名/密码错误");
|
|
}
|
|
}
|
|
StpUtil.login(databaseUser.id());
|
|
StpUtil.login(databaseUser.id());
|
|
|
|
+ redisTemplate.opsForValue().set(StpUtil.getTokenInfo().tokenValue, databaseUser.id());
|
|
return StpUtil.getTokenInfo();
|
|
return StpUtil.getTokenInfo();
|
|
}
|
|
}
|
|
|
|
|