清理组织和公司下的用户缓存,包含子机构
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
package com.jeesite.modules.sys.service.support;
|
package com.jeesite.modules.sys.service.support;
|
||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.service.TreeService;
|
import com.jeesite.common.service.TreeService;
|
||||||
import com.jeesite.common.utils.PageUtils;
|
import com.jeesite.common.utils.PageUtils;
|
||||||
import com.jeesite.modules.sys.dao.CompanyDao;
|
import com.jeesite.modules.sys.dao.CompanyDao;
|
||||||
@@ -17,7 +18,6 @@ import com.jeesite.modules.sys.service.DataScopeService;
|
|||||||
import com.jeesite.modules.sys.service.EmpUserService;
|
import com.jeesite.modules.sys.service.EmpUserService;
|
||||||
import com.jeesite.modules.sys.utils.EmpUtils;
|
import com.jeesite.modules.sys.utils.EmpUtils;
|
||||||
import com.jeesite.modules.sys.utils.UserUtils;
|
import com.jeesite.modules.sys.utils.UserUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -100,6 +100,7 @@ public class CompanyServiceSupport extends TreeService<CompanyDao, Company>
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(Company company) {
|
public void delete(Company company) {
|
||||||
|
company.sqlMap().markIdDelete();
|
||||||
super.delete(company);
|
super.delete(company);
|
||||||
// 清理公司相关缓存
|
// 清理公司相关缓存
|
||||||
clearCompanyCache(company);
|
clearCompanyCache(company);
|
||||||
@@ -121,9 +122,24 @@ public class CompanyServiceSupport extends TreeService<CompanyDao, Company>
|
|||||||
*/
|
*/
|
||||||
private void clearCompanyCache(Company company){
|
private void clearCompanyCache(Company company){
|
||||||
EmpUtils.removeCache(EmpUtils.CACHE_COMPANY_ALL_LIST);
|
EmpUtils.removeCache(EmpUtils.CACHE_COMPANY_ALL_LIST);
|
||||||
// 清理公司下的用户缓存
|
// 清理公司下的用户缓存,包含子公司
|
||||||
|
if (company == null || StringUtils.isBlank(company.getCompanyCode())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(company.getParentCode())){
|
||||||
|
company = get(company);
|
||||||
|
if (company == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Company where = new Company();
|
||||||
|
where.setStatus(Company.STATUS_NORMAL);
|
||||||
|
where.setParentCodes(company.getParentCodes() + company.getCompanyCode() + ",%");
|
||||||
EmpUser empUserWhere = new EmpUser();
|
EmpUser empUserWhere = new EmpUser();
|
||||||
empUserWhere.setCodes(new String[]{ company.getCompanyCode() });
|
empUserWhere.setCodes(this.findByParentCodesLike(where).stream().map(Company::getCompanyCode).toArray(String[]::new));
|
||||||
|
if (empUserWhere.getCodes().length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PageUtils.findList(empUserWhere, null, e -> {
|
PageUtils.findList(empUserWhere, null, e -> {
|
||||||
List<EmpUser> empUserList = empUserService.findUserListByCompanyCodes((EmpUser)e);
|
List<EmpUser> empUserList = empUserService.findUserListByCompanyCodes((EmpUser)e);
|
||||||
empUserList.forEach(UserUtils::clearCache);
|
empUserList.forEach(UserUtils::clearCache);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package com.jeesite.modules.sys.service.support;
|
package com.jeesite.modules.sys.service.support;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.service.ServiceException;
|
import com.jeesite.common.service.ServiceException;
|
||||||
import com.jeesite.common.service.TreeService;
|
import com.jeesite.common.service.TreeService;
|
||||||
import com.jeesite.common.utils.PageUtils;
|
import com.jeesite.common.utils.PageUtils;
|
||||||
@@ -175,9 +176,24 @@ public class OfficeServiceSupport extends TreeService<OfficeDao, Office>
|
|||||||
*/
|
*/
|
||||||
private void clearOfficeCache(Office office){
|
private void clearOfficeCache(Office office){
|
||||||
EmpUtils.removeCache(EmpUtils.CACHE_OFFICE_ALL_LIST);
|
EmpUtils.removeCache(EmpUtils.CACHE_OFFICE_ALL_LIST);
|
||||||
// 清理组织下的用户缓存
|
// 清理组织下的用户缓存,包含子机构
|
||||||
|
if (office == null || StringUtils.isBlank(office.getOfficeCode())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(office.getParentCode())){
|
||||||
|
office = get(office);
|
||||||
|
if (office == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Office where = new Office();
|
||||||
|
where.setStatus(Office.STATUS_NORMAL);
|
||||||
|
where.setParentCodes(office.getParentCodes() + office.getOfficeCode() + ",%");
|
||||||
EmpUser empUserWhere = new EmpUser();
|
EmpUser empUserWhere = new EmpUser();
|
||||||
empUserWhere.setCodes(new String[]{ office.getOfficeCode() });
|
empUserWhere.setCodes(this.findByParentCodesLike(where).stream().map(Office::getOfficeCode).toArray(String[]::new));
|
||||||
|
if (empUserWhere.getCodes().length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PageUtils.findList(empUserWhere, null, e -> {
|
PageUtils.findList(empUserWhere, null, e -> {
|
||||||
List<EmpUser> empUserList = empUserService.findUserListByOfficeCodes((EmpUser)e);
|
List<EmpUser> empUserList = empUserService.findUserListByOfficeCodes((EmpUser)e);
|
||||||
empUserList.forEach(UserUtils::clearCache);
|
empUserList.forEach(UserUtils::clearCache);
|
||||||
|
|||||||
Reference in New Issue
Block a user