From 49931ba22752b5d2a797200e5e6a7d86b430e3e1 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Wed, 24 Jan 2024 11:08:32 +0800 Subject: [PATCH] revert. --- .../ops/framework/common/constant/Const.java | 2 - .../asset/service/impl/HostServiceImpl.java | 8 +- .../ops/module/infra/api/DataGroupApi.java | 21 +---- .../entity/dto/data/DataGroupCreateDTO.java | 3 - .../infra/api/impl/DataGroupApiImpl.java | 18 +---- .../ops/module/infra/dao/DataGroupDAO.java | 12 --- .../define/cache/DataGroupCacheKeyDefine.java | 12 +-- .../infra/entity/domain/DataGroupDO.java | 12 +-- .../infra/entity/domain/DataGroupRelDO.java | 12 +-- .../request/data/DataGroupCreateRequest.java | 4 - .../infra/service/DataGroupRelService.java | 11 +-- .../infra/service/DataGroupService.java | 20 ++--- .../service/impl/DataGroupRelServiceImpl.java | 15 ++-- .../service/impl/DataGroupServiceImpl.java | 77 ++++--------------- .../service/impl/SystemUserServiceImpl.java | 5 -- .../main/resources/mapper/DataGroupMapper.xml | 3 +- 16 files changed, 48 insertions(+), 187 deletions(-) diff --git a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/Const.java b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/Const.java index 012cfcee..310b86ff 100644 --- a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/Const.java +++ b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/Const.java @@ -21,8 +21,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons String INTRANET_IP = "内网IP"; - Long SYSTEM_USER_ID = 0L; - Long ROOT_PARENT_ID = 0L; Integer DEFAULT_SORT = 10; diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostServiceImpl.java index bbd5c912..899c9cc7 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostServiceImpl.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostServiceImpl.java @@ -146,12 +146,8 @@ public class HostServiceImpl implements HostService { Valid.notNull(record, ErrorMessage.HOST_ABSENT); // 转换 HostVO vo = HostConvert.MAPPER.to(record); - // 设置 tag 信息 - List tags = tagFuture.get(); - // 设置分组信息 - vo.setTags(tags); - Set groupIdList = groupIdFuture.get(); - vo.setGroupIdList(groupIdList); + vo.setTags(tagFuture.get()); + vo.setGroupIdList(groupIdFuture.get()); return vo; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupApi.java b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupApi.java index d13879a6..74158af2 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupApi.java +++ b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupApi.java @@ -53,30 +53,11 @@ public interface DataGroupApi { /** * 通过缓存查询数据分组 * - * @param type type - * @param userId userId - * @return rows - */ - List getDataGroupList(DataGroupTypeEnum type, Long userId); - - /** - * 通过缓存查询数据分组 - * - * @param type type - * @param userId userId + * @param type type * @return rows */ List getDataGroupTree(DataGroupTypeEnum type); - /** - * 通过缓存查询数据分组 - * - * @param type type - * @param userId userId - * @return rows - */ - List getDataGroupTree(DataGroupTypeEnum type, Long userId); - /** * 通过 id 查询 * diff --git a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/entity/dto/data/DataGroupCreateDTO.java b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/entity/dto/data/DataGroupCreateDTO.java index e70b29ea..8cd9a3de 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/entity/dto/data/DataGroupCreateDTO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/entity/dto/data/DataGroupCreateDTO.java @@ -25,9 +25,6 @@ import java.io.Serializable; @Schema(name = "DataGroupCreateDTO", description = "数据分组 创建请求业务对象") public class DataGroupCreateDTO implements Serializable { - @Schema(description = "userId") - private Long userId; - @NotNull @Schema(description = "父id") private Long parentId; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupApiImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupApiImpl.java index b83c6b78..f7dc6e24 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupApiImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupApiImpl.java @@ -1,6 +1,5 @@ package com.orion.ops.module.infra.api.impl; -import com.orion.ops.framework.common.constant.Const; import com.orion.ops.framework.common.utils.Valid; import com.orion.ops.module.infra.api.DataGroupApi; import com.orion.ops.module.infra.convert.DataGroupProviderConvert; @@ -43,9 +42,6 @@ public class DataGroupApiImpl implements DataGroupApi { @Override public Long createDataGroup(DataGroupTypeEnum type, DataGroupCreateDTO dto) { Valid.valid(dto); - if (dto.getUserId() == null) { - dto.setUserId(Const.SYSTEM_USER_ID); - } DataGroupCreateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto); request.setType(type.name()); return dataGroupService.createDataGroup(request); @@ -67,23 +63,13 @@ public class DataGroupApiImpl implements DataGroupApi { @Override public List getDataGroupList(DataGroupTypeEnum type) { - return this.getDataGroupList(type, Const.SYSTEM_USER_ID); - } - - @Override - public List getDataGroupList(DataGroupTypeEnum type, Long userId) { - List rows = dataGroupService.getDataGroupListByCache(type.name(), userId); + List rows = dataGroupService.getDataGroupListByCache(type.name()); return DataGroupProviderConvert.MAPPER.toList(rows); } @Override public List getDataGroupTree(DataGroupTypeEnum type) { - return this.getDataGroupTree(type, Const.SYSTEM_USER_ID); - } - - @Override - public List getDataGroupTree(DataGroupTypeEnum type, Long userId) { - List rows = dataGroupService.getDataGroupTreeByCache(type.name(), userId); + List rows = dataGroupService.getDataGroupTreeByCache(type.name()); return DataGroupProviderConvert.MAPPER.toList(rows); } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DataGroupDAO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DataGroupDAO.java index 4f2c2dc0..806a38e7 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DataGroupDAO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/dao/DataGroupDAO.java @@ -53,16 +53,4 @@ public interface DataGroupDAO extends IMapper { return this.selectList(wrapper); } - /** - * 通过 userId 查询 - * - * @param userId userId - * @return rows - */ - default List selectByUserId(Long userId) { - LambdaQueryWrapper wrapper = this.lambda() - .eq(DataGroupDO::getUserId, userId); - return this.selectList(wrapper); - } - } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DataGroupCacheKeyDefine.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DataGroupCacheKeyDefine.java index dbc45094..27905062 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DataGroupCacheKeyDefine.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/define/cache/DataGroupCacheKeyDefine.java @@ -18,16 +18,16 @@ import java.util.concurrent.TimeUnit; public interface DataGroupCacheKeyDefine { CacheKeyDefine DATA_GROUP_LIST = new CacheKeyBuilder() - .key("data:group-list:{}:{}") - .desc("数据分组列表结构 ${type} ${userId}") + .key("data:group-list:{}") + .desc("数据分组列表结构 ${type}") .type(DataGroupCacheDTO.class) .struct(RedisCacheStruct.STRING) .timeout(1, TimeUnit.DAYS) .build(); CacheKeyDefine DATA_GROUP_TREE = new CacheKeyBuilder() - .key("data:group-tree:{}:{}") - .desc("数据分组树结构 ${type} ${userId}") + .key("data:group-tree:{}") + .desc("数据分组树结构 ${type}") .type(DataGroupCacheDTO.class) .struct(RedisCacheStruct.STRING) .timeout(1, TimeUnit.DAYS) @@ -42,8 +42,8 @@ public interface DataGroupCacheKeyDefine { .build(); CacheKeyDefine DATA_GROUP_REL_TYPE = new CacheKeyBuilder() - .key("data:group-rel:type:{}:{}") - .desc("数据分组数据关联-类型 ${type} ${userId}") + .key("data:group-rel:type:{}") + .desc("数据分组数据关联-类型 ${type}") .type(DataGroupRelCacheDTO.class) .struct(RedisCacheStruct.STRING) .timeout(1, TimeUnit.DAYS) diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupDO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupDO.java index de297115..b6febf5b 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupDO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupDO.java @@ -1,13 +1,13 @@ package com.orion.ops.module.infra.entity.domain; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.orion.ops.framework.mybatis.core.domain.BaseDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; -import java.math.*; - /** * 数据分组 实体对象 * @@ -34,10 +34,6 @@ public class DataGroupDO extends BaseDO { @TableField("parent_id") private Long parentId; - @Schema(description = "用户id") - @TableField("user_id") - private Long userId; - @Schema(description = "组名称") @TableField("name") private String name; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupRelDO.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupRelDO.java index efbc7386..ddc42b17 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupRelDO.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/domain/DataGroupRelDO.java @@ -1,13 +1,13 @@ package com.orion.ops.module.infra.entity.domain; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.orion.ops.framework.mybatis.core.domain.BaseDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; -import java.math.*; - /** * 数据分组关联 实体对象 * @@ -34,10 +34,6 @@ public class DataGroupRelDO extends BaseDO { @TableField("group_id") private Long groupId; - @Schema(description = "用户id") - @TableField("user_id") - private Long userId; - @Schema(description = "引用id") @TableField("rel_id") private Long relId; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/data/DataGroupCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/data/DataGroupCreateRequest.java index f69fe61f..aba4bd6e 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/data/DataGroupCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/data/DataGroupCreateRequest.java @@ -25,10 +25,6 @@ import java.io.Serializable; @Schema(name = "DataGroupCreateRequest", description = "数据分组 创建请求对象") public class DataGroupCreateRequest implements Serializable { - @NotNull - @Schema(description = "userId") - private Long userId; - @NotNull @Schema(description = "父id") private Long parentId; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupRelService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupRelService.java index 2a2dde79..f8b6c7a4 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupRelService.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupRelService.java @@ -27,28 +27,25 @@ public interface DataGroupRelService { * 设置关联 * * @param type type - * @param userId userId * @param groupIdList groupIdList * @param relId relId */ - void updateGroupRel(String type, Long userId, List groupIdList, Long relId); + void updateGroupRel(String type, List groupIdList, Long relId); /** * 添加关联 * - * @param userId userId * @param groupId groupId * @param relId relId */ - void addGroupRel(Long userId, Long groupId, Long relId); + void addGroupRel(Long groupId, Long relId); /** * 添加关联 * - * @param userId userId - * @param list list + * @param list list */ - void addGroupRel(Long userId, List list); + void addGroupRel(List list); /** * 通过 type 查询 relId 缓存 diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupService.java index b2d6297d..2dd7dba8 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupService.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DataGroupService.java @@ -43,35 +43,25 @@ public interface DataGroupService { /** * 通过缓存查询数据分组 - 列表 * - * @param type type - * @param userId userId + * @param type type * @return rows */ - List getDataGroupListByCache(String type, Long userId); + List getDataGroupListByCache(String type); /** * 通过缓存查询数据分组 - 树结构 * - * @param type type - * @param userId userId + * @param type type * @return rows */ - List getDataGroupTreeByCache(String type, Long userId); + List getDataGroupTreeByCache(String type); /** - * 通过 id 删除数据分组 + * 删除数据分组 * * @param id id * @return effect */ Integer deleteDataGroupById(Long id); - /** - * 通过 userId 删除数据分组 - * - * @param userId userId - * @return effect - */ - Integer deleteDataGroupByUserId(Long userId); - } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java index 96a4a871..b527156f 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java @@ -84,7 +84,6 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { List insertRecords = relIdList.stream() .map(s -> DataGroupRelDO.builder() .groupId(groupId) - .userId(group.getUserId()) .type(type) .relId(s) .build()) @@ -93,12 +92,12 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { } } // 删除缓存 - this.deleteCache(type, group.getUserId(), Lists.of(groupId)); + this.deleteCache(type, Lists.of(groupId)); } @Override @Transactional(rollbackFor = Exception.class) - public void updateGroupRel(String type, Long userId, List groupIdList, Long relId) { + public void updateGroupRel(String type, List groupIdList, Long relId) { Valid.notNull(relId); // 删除引用 this.deleteByRelId(type, relId); @@ -109,12 +108,11 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { .type(type) .groupId(s) .relId(relId) - .userId(userId) .build()) .collect(Collectors.toList()); dataGroupRelDAO.insertBatch(relList); // 删除缓存 - this.deleteCache(type, userId, groupIdList); + this.deleteCache(type, groupIdList); } } @@ -127,7 +125,7 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { .build(); // 插入 SpringHolder.getBean(DataGroupRelService.class) - .addGroupRel(groupId,Lists.singleton(record)); + .addGroupRel(Lists.singleton(record)); } @Override @@ -288,12 +286,11 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { * 删除缓存 * * @param type type - * @param userId userId * @param groupIdList groupIdList */ - private void deleteCache(String type, Long userId, Collection groupIdList) { + private void deleteCache(String type, Collection groupIdList) { // 类型缓存 - List keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type, userId)); + List keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type)); // 分组缓存 if (!Lists.isEmpty(groupIdList)) { groupIdList.stream() diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupServiceImpl.java index 45f966bb..1fbd85fc 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupServiceImpl.java @@ -26,10 +26,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; /** @@ -64,7 +61,7 @@ public class DataGroupServiceImpl implements DataGroupService { Long id = record.getId(); log.info("DataGroupService-createDataGroup id: {}, effect: {}", id, effect); // 删除缓存 - this.deleteCache(record); + this.deleteCache(request.getType()); return id; } @@ -88,7 +85,7 @@ public class DataGroupServiceImpl implements DataGroupService { // 更新 int effect = dataGroupDAO.updateById(updateRecord); // 删除缓存 - this.deleteCache(record); + this.deleteCache(record.getType()); return effect; } @@ -142,7 +139,7 @@ public class DataGroupServiceImpl implements DataGroupService { effect = dataGroupDAO.updateById(update); } // 删除缓存 - this.deleteCache(moveRecord); + this.deleteCache(type); // 添加日志参数 OperatorLogs.add(OperatorLogs.SOURCE, moveRecord.getName()); OperatorLogs.add(OperatorLogs.TARGET, targetRecord.getName()); @@ -151,16 +148,15 @@ public class DataGroupServiceImpl implements DataGroupService { } @Override - public List getDataGroupListByCache(String type, Long userId) { + public List getDataGroupListByCache(String type) { // 查询缓存 - String key = DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type, userId); + String key = DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type); List list = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_LIST); if (Lists.isEmpty(list)) { // 查询数据库 list = dataGroupDAO.of() .createWrapper() .eq(DataGroupDO::getType, type) - .eq(DataGroupDO::getUserId, userId) .then() .list(DataGroupConvert.MAPPER::toCache); // 设置屏障 防止穿透 @@ -174,13 +170,13 @@ public class DataGroupServiceImpl implements DataGroupService { } @Override - public List getDataGroupTreeByCache(String type, Long userId) { + public List getDataGroupTreeByCache(String type) { // 查询缓存 - String key = DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type, userId); + String key = DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type); List treeData = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_TREE); if (Lists.isEmpty(treeData)) { // 查询列表缓存 - List rows = this.getDataGroupListByCache(type, userId); + List rows = this.getDataGroupListByCache(type); // 设置屏障 防止穿透 CacheBarriers.checkBarrier(rows, DataGroupCacheDTO::new); if (!Lists.isEmpty(rows)) { @@ -217,39 +213,12 @@ public class DataGroupServiceImpl implements DataGroupService { dataGroupRelService.deleteByGroupIdList(type, deleteIdList); log.info("DataGroupService-deleteDataGroupById id: {}, effect: {}", id, effect); // 删除缓存 - this.deleteCache(record); + this.deleteCache(type); // 添加日志参数 OperatorLogs.add(OperatorLogs.GROUP_NAME, record.getName()); return effect; } - @Override - public Integer deleteDataGroupByUserId(Long userId) { - // 查询数据 - List rows = dataGroupDAO.selectByUserId(userId); - if (rows.isEmpty()) { - return rows.size(); - } - // 删除分组 - List idList = rows.stream() - .map(DataGroupDO::getId) - .collect(Collectors.toList()); - dataGroupDAO.deleteBatchIds(idList); - // 删除分组内数据 - Map> groupRelGroup = rows.stream() - .collect(Collectors.groupingBy( - DataGroupDO::getType, - Collectors.mapping( - DataGroupDO::getId, - Collectors.toList() - ) - )); - groupRelGroup.forEach((k, v) -> dataGroupRelService.deleteByGroupIdList(k, v)); - // 删除缓存 - this.deleteCache(userId, groupRelGroup.keySet()); - return rows.size(); - } - /** * 获取所有子节点 id * @@ -283,7 +252,6 @@ public class DataGroupServiceImpl implements DataGroupService { .ne(DataGroupDO::getId, domain.getId()) // 用其他字段做重复校验 .eq(DataGroupDO::getParentId, domain.getParentId()) - .eq(DataGroupDO::getUserId, domain.getUserId()) .eq(DataGroupDO::getName, domain.getName()) .eq(DataGroupDO::getType, domain.getType()); // 检查是否存在 @@ -294,30 +262,11 @@ public class DataGroupServiceImpl implements DataGroupService { /** * 删除缓存 * - * @param type type - * @param userId userId + * @param type type */ - private void deleteCache(DataGroupDO record) { - String type = record.getType(); - Long userId = record.getUserId(); - RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type, userId), - DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type, userId)); - } - - /** - * 删除缓存 - * - * @param userId userId - * @param types types - * @param userId userId - */ - private void deleteCache(Long userId, Collection types) { - List deleteKeys = new ArrayList<>(); - for (String type : types) { - deleteKeys.add(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type, userId)); - deleteKeys.add(DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type, userId)); - } - RedisStrings.delete(deleteKeys); + private void deleteCache(String type) { + RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type), + DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type)); } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/SystemUserServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/SystemUserServiceImpl.java index 0303bd31..bbd537ce 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/SystemUserServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/SystemUserServiceImpl.java @@ -70,9 +70,6 @@ public class SystemUserServiceImpl implements SystemUserService { @Resource private DataPermissionService dataPermissionService; - @Resource - private DataGroupService dataGroupService; - @Resource private DataExtraService dataExtraService; @@ -254,8 +251,6 @@ public class SystemUserServiceImpl implements SystemUserService { preferenceService.deletePreferenceByUserId(id); // 删除用户数据权限 dataPermissionService.deleteByUserId(id); - // 删除用户分组信息 - dataGroupService.deleteDataGroupByUserId(id); // 删除用户拓展数据 dataExtraService.deleteByUserId(id); } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml index 40055b1e..cea2ba06 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml @@ -6,7 +6,6 @@ - @@ -19,7 +18,7 @@ - id, parent_id, user_id, name, type, sort, create_time, update_time, creator, updater, deleted + id, parent_id, name, type, sort, create_time, update_time, creator, updater, deleted