|
@@ -26,67 +26,74 @@ public class CrmQueryWrapperUtils {
|
|
|
|
|
|
* 构造 CRM 数据类型数据分页查询条件
|
|
* 构造 CRM 数据类型数据分页查询条件
|
|
*
|
|
*
|
|
- * @param queryMapper 连表查询对象
|
|
+ * @param query 连表查询对象
|
|
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
|
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
|
* @param bizId 数据编号
|
|
* @param bizId 数据编号
|
|
* @param userId 用户编号
|
|
* @param userId 用户编号
|
|
* @param sceneType 场景类型
|
|
* @param sceneType 场景类型
|
|
* @param pool 公海
|
|
* @param pool 公海
|
|
*/
|
|
*/
|
|
- public static <T extends MPJLambdaWrapper<?>, S> void builderPageQuery(
|
|
+
|
|
- T queryMapper, Integer bizType, SFunction<S, ?> bizId, Long userId, Integer sceneType, Boolean pool) {
|
|
+
|
|
|
|
+ public static <T extends MPJLambdaWrapper<?>, S> void builderPageQuery(T query, Integer bizType, SFunction<S, ?> bizId,
|
|
|
|
+ Long userId, Integer sceneType, Boolean pool) {
|
|
|
|
|
|
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) {
|
|
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) {
|
|
- queryMapper.innerJoin(CrmPermissionDO.class, on ->
|
|
+ query.innerJoin(CrmPermissionDO.class, on ->
|
|
on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId)
|
|
on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId)
|
|
.eq(CrmPermissionDO::getUserId, userId));
|
|
.eq(CrmPermissionDO::getUserId, userId));
|
|
}
|
|
}
|
|
-
|
|
+
|
|
if (CrmSceneTypeEnum.isOwner(sceneType)) {
|
|
if (CrmSceneTypeEnum.isOwner(sceneType)) {
|
|
- queryMapper.eq("owner_user_id", userId);
|
|
+ query.eq("owner_user_id", userId);
|
|
}
|
|
}
|
|
-
|
|
+
|
|
|
|
+
|
|
if (CrmSceneTypeEnum.isInvolved(sceneType)) {
|
|
if (CrmSceneTypeEnum.isInvolved(sceneType)) {
|
|
- queryMapper.ne("owner_user_id", userId);
|
|
+ query.ne("owner_user_id", userId);
|
|
}
|
|
}
|
|
-
|
|
+
|
|
if (CrmSceneTypeEnum.isSubordinate(sceneType)) {
|
|
if (CrmSceneTypeEnum.isSubordinate(sceneType)) {
|
|
List<AdminUserRespDTO> subordinateUsers = getAdminUserApi().getUserListBySubordinate(userId);
|
|
List<AdminUserRespDTO> subordinateUsers = getAdminUserApi().getUserListBySubordinate(userId);
|
|
|
|
+
|
|
if (CollUtil.isNotEmpty(subordinateUsers)) {
|
|
if (CollUtil.isNotEmpty(subordinateUsers)) {
|
|
- queryMapper.in("owner_user_id", convertSet(subordinateUsers, AdminUserRespDTO::getId));
|
|
+ query.in("owner_user_id", convertSet(subordinateUsers, AdminUserRespDTO::getId));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjUtil.equal(pool, Boolean.TRUE)) {
|
|
if (ObjUtil.equal(pool, Boolean.TRUE)) {
|
|
- queryMapper.isNull("owner_user_id");
|
|
+ query.isNull("owner_user_id");
|
|
} else {
|
|
} else {
|
|
- queryMapper.isNotNull("owner_user_id");
|
|
+ query.isNotNull("owner_user_id");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
* 构造 CRM 数据类型批量数据查询条件
|
|
* 构造 CRM 数据类型批量数据查询条件
|
|
*
|
|
*
|
|
- * @param queryMapper 连表查询对象
|
|
+ * @param query 连表查询对象
|
|
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
|
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
|
* @param bizIds 数据编号
|
|
* @param bizIds 数据编号
|
|
* @param userId 用户编号
|
|
* @param userId 用户编号
|
|
*/
|
|
*/
|
|
- public static <T extends MPJLambdaWrapper<?>, S> void builderListQueryBatch(
|
|
+
|
|
- T queryMapper, Integer bizType, Collection<Long> bizIds, Long userId) {
|
|
+
|
|
-
|
|
+ public static <T extends MPJLambdaWrapper<?>, S> void builderListQueryBatch(T query, Integer bizType, Collection<Long> bizIds, Long userId) {
|
|
|
|
+
|
|
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) {
|
|
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) {
|
|
- queryMapper.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));
|
|
.in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private static AdminUserApi getAdminUserApi() {
|
|
private static AdminUserApi getAdminUserApi() {
|
|
return SpringUtil.getBean(AdminUserApi.class);
|
|
return SpringUtil.getBean(AdminUserApi.class);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
* 校验用户是否是管理员
|
|
* 校验用户是否是管理员
|
|
*
|
|
*
|