|
@@ -14,6 +14,7 @@ import com.macro.mall.mapper.UmsAdminMapper;
|
|
|
import com.macro.mall.mapper.UmsAdminRoleRelationMapper;
|
|
|
import com.macro.mall.model.*;
|
|
|
import com.macro.mall.security.util.JwtTokenUtil;
|
|
|
+import com.macro.mall.security.util.SpringUtil;
|
|
|
import com.macro.mall.service.UmsAdminCacheService;
|
|
|
import com.macro.mall.service.UmsAdminService;
|
|
|
import org.slf4j.Logger;
|
|
@@ -56,19 +57,17 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
private UmsAdminRoleRelationDao adminRoleRelationDao;
|
|
|
@Autowired
|
|
|
private UmsAdminLoginLogMapper loginLogMapper;
|
|
|
- @Autowired
|
|
|
- private UmsAdminCacheService adminCacheService;
|
|
|
|
|
|
@Override
|
|
|
public UmsAdmin getAdminByUsername(String username) {
|
|
|
- UmsAdmin admin = adminCacheService.getAdmin(username);
|
|
|
+ UmsAdmin admin = getCacheService().getAdmin(username);
|
|
|
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);
|
|
|
- adminCacheService.setAdmin(admin);
|
|
|
+ getCacheService().setAdmin(admin);
|
|
|
return admin;
|
|
|
}
|
|
|
return null;
|
|
@@ -159,7 +158,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
UmsAdminExample example = new UmsAdminExample();
|
|
|
UmsAdminExample.Criteria criteria = example.createCriteria();
|
|
|
- if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ if (!StrUtil.isEmpty(keyword)) {
|
|
|
criteria.andUsernameLike("%" + keyword + "%");
|
|
|
example.or(example.createCriteria().andNickNameLike("%" + keyword + "%"));
|
|
|
}
|
|
@@ -182,15 +181,15 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
}
|
|
|
}
|
|
|
int count = adminMapper.updateByPrimaryKeySelective(admin);
|
|
|
- adminCacheService.delAdmin(id);
|
|
|
+ getCacheService().delAdmin(id);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int delete(Long id) {
|
|
|
- adminCacheService.delAdmin(id);
|
|
|
+ getCacheService().delAdmin(id);
|
|
|
int count = adminMapper.deleteByPrimaryKey(id);
|
|
|
- adminCacheService.delResourceList(id);
|
|
|
+ getCacheService().delResourceList(id);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
@@ -212,7 +211,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
}
|
|
|
adminRoleRelationDao.insertList(list);
|
|
|
}
|
|
|
- adminCacheService.delResourceList(adminId);
|
|
|
+ getCacheService().delResourceList(adminId);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
@@ -223,13 +222,13 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
|
|
|
@Override
|
|
|
public List<UmsResource> getResourceList(Long adminId) {
|
|
|
- List<UmsResource> resourceList = adminCacheService.getResourceList(adminId);
|
|
|
+ List<UmsResource> resourceList = getCacheService().getResourceList(adminId);
|
|
|
if(CollUtil.isNotEmpty(resourceList)){
|
|
|
return resourceList;
|
|
|
}
|
|
|
resourceList = adminRoleRelationDao.getResourceList(adminId);
|
|
|
if(CollUtil.isNotEmpty(resourceList)){
|
|
|
- adminCacheService.setResourceList(adminId,resourceList);
|
|
|
+ getCacheService().setResourceList(adminId,resourceList);
|
|
|
}
|
|
|
return resourceList;
|
|
|
}
|
|
@@ -253,7 +252,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
}
|
|
|
umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword()));
|
|
|
adminMapper.updateByPrimaryKey(umsAdmin);
|
|
|
- adminCacheService.delAdmin(umsAdmin.getId());
|
|
|
+ getCacheService().delAdmin(umsAdmin.getId());
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -267,4 +266,9 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
}
|
|
|
throw new UsernameNotFoundException("用户名或密码错误");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UmsAdminCacheService getCacheService() {
|
|
|
+ return SpringUtil.getBean(UmsAdminCacheService.class);
|
|
|
+ }
|
|
|
}
|