|
@@ -60,13 +60,16 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
|
|
|
@Override
|
|
|
public UmsAdmin getAdminByUsername(String username) {
|
|
|
+ //先从缓存中获取数据
|
|
|
UmsAdmin admin = getCacheService().getAdmin(username);
|
|
|
- if(admin!=null) return admin;
|
|
|
+ if (admin != null) return admin;
|
|
|
+ //缓存中没有从数据库中获取
|
|
|
UmsAdminExample example = new UmsAdminExample();
|
|
|
example.createCriteria().andUsernameEqualTo(username);
|
|
|
List<UmsAdmin> adminList = adminMapper.selectByExample(example);
|
|
|
if (adminList != null && adminList.size() > 0) {
|
|
|
admin = adminList.get(0);
|
|
|
+ //将数据库中的数据存入缓存中
|
|
|
getCacheService().setAdmin(admin);
|
|
|
return admin;
|
|
|
}
|