|
|
@@ -12,6 +12,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
@@ -40,15 +41,28 @@ public class UserServiceImpl extends BaseService implements UserService {
|
|
|
@Autowired
|
|
|
private PermissionDao permissionDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
@Override
|
|
|
public List<User> getAll() {
|
|
|
return userInfoDao.getAll();
|
|
|
}
|
|
|
|
|
|
+ private int count;
|
|
|
+
|
|
|
@Override
|
|
|
- @Cacheable(value = "usercache",keyGenerator = "keyGenerator")
|
|
|
+// @Cacheable(value = "usercache",keyGenerator = "keyGenerator")
|
|
|
public User getOne(Long id) {
|
|
|
- return getUserById(id);
|
|
|
+ User user = new User();
|
|
|
+ user.setUsername("aa"+count++);
|
|
|
+ redisTemplate.opsForValue().set(user.getUsername(), user);
|
|
|
+
|
|
|
+ User u = (User) redisTemplate.opsForValue().get("aa"+(count-2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return u==null?getUserById(id):u;
|
|
|
}
|
|
|
|
|
|
@Override
|