fix: CRM selectBatchIds 权限查询 ids 筛选不生效的 bug

This commit is contained in:
puhui999 2024-01-20 18:42:06 +08:00
parent 7914423c66
commit 8920b9787d
8 changed files with 11 additions and 5 deletions

View File

@ -58,6 +58,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId);
query.selectAll(CrmBusinessDO.class).in(CrmBusinessDO::getId, ids).orderByDesc(CrmBusinessDO::getId);
return selectJoinList(CrmBusinessDO.class, query); return selectJoinList(CrmBusinessDO.class, query);
} }

View File

@ -45,6 +45,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> {
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId);
query.selectAll(CrmClueDO.class).in(CrmClueDO::getId, ids).orderByDesc(CrmClueDO::getId);
return selectJoinList(CrmClueDO.class, query); return selectJoinList(CrmClueDO.class, query);
} }

View File

@ -67,6 +67,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId);
query.selectAll(CrmContactDO.class).in(CrmContactDO::getId, ids).orderByDesc(CrmContactDO::getId);
return selectJoinList(CrmContactDO.class, query); return selectJoinList(CrmContactDO.class, query);
} }

View File

@ -54,10 +54,11 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
} }
default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) { default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) {
MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
// 构建数据权限连表条件 // 构建数据权限连表条件
CrmQueryWrapperUtils.appendPermissionCondition(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId);
return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX); query.selectAll(CrmContractDO.class).in(CrmContractDO::getId, ids).orderByDesc(CrmContractDO::getId);
return selectJoinList(CrmContractDO.class, query);
} }
default Long selectCountByContactId(Long contactId) { default Long selectCountByContactId(Long contactId) {

View File

@ -64,6 +64,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId);
query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId);
return selectJoinList(CrmCustomerDO.class, query); return selectJoinList(CrmCustomerDO.class, query);
} }

View File

@ -53,6 +53,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId);
query.selectAll(CrmReceivableDO.class).in(CrmReceivableDO::getId, ids).orderByDesc(CrmReceivableDO::getId);
return selectJoinList(CrmReceivableDO.class, query); return selectJoinList(CrmReceivableDO.class, query);
} }

View File

@ -52,6 +52,7 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件 // 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId); CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId);
query.selectAll(CrmReceivablePlanDO.class).in(CrmReceivablePlanDO::getId, ids).orderByDesc(CrmReceivablePlanDO::getId);
return selectJoinList(CrmReceivablePlanDO.class, query); return selectJoinList(CrmReceivablePlanDO.class, query);
} }

View File

@ -84,10 +84,9 @@ public class CrmQueryWrapperUtils {
if (CrmPermissionUtils.isCrmAdmin()) {// 管理员不需要数据权限 if (CrmPermissionUtils.isCrmAdmin()) {// 管理员不需要数据权限
return; return;
} }
query.innerJoin(CrmPermissionDO.class, on -> query.innerJoin(CrmPermissionDO.class, on ->
on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds)
.in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); .eq(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId));
} }
/** /**