diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/ExecTemplateController.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/ExecTemplateController.java index a3528b31..3f4b2962 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/ExecTemplateController.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/ExecTemplateController.java @@ -92,6 +92,5 @@ public class ExecTemplateController { return execTemplateService.deleteExecTemplateById(id); } - } 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 dfb72791..ad070dce 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 @@ -29,7 +29,6 @@ import com.orion.ops.module.infra.api.DataExtraApi; import com.orion.ops.module.infra.api.DataGroupRelApi; import com.orion.ops.module.infra.api.FavoriteApi; import com.orion.ops.module.infra.api.TagRelApi; -import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO; import com.orion.ops.module.infra.entity.dto.tag.TagDTO; import com.orion.ops.module.infra.enums.DataExtraTypeEnum; import com.orion.ops.module.infra.enums.DataGroupTypeEnum; @@ -103,13 +102,7 @@ public class HostServiceImpl implements HostService { // 引用分组 List groupIdList = request.getGroupIdList(); if (!Lists.isEmpty(groupIdList)) { - List groupRelList = groupIdList.stream() - .map(s -> DataGroupRelCreateDTO.builder() - .groupId(s) - .relId(id) - .build()) - .collect(Collectors.toList()); - dataGroupRelApi.addGroupRel(groupRelList); + dataGroupRelApi.updateRelGroup(DataGroupTypeEnum.HOST, request.getGroupIdList(), id); } // 创建配置 hostConfigService.initHostConfig(id); @@ -134,7 +127,7 @@ public class HostServiceImpl implements HostService { int effect = hostDAO.updateById(updateRecord); log.info("HostService-updateHostById effect: {}", effect); // 引用分组 - dataGroupRelApi.updateGroupRel(DataGroupTypeEnum.HOST, request.getGroupIdList(), id); + dataGroupRelApi.updateRelGroup(DataGroupTypeEnum.HOST, request.getGroupIdList(), id); // 更新 tag tagRelApi.setTagRel(TagTypeEnum.HOST, id, request.getTags()); // 删除缓存 diff --git a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupRelApi.java b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupRelApi.java index a6de3ef9..f28802f2 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupRelApi.java +++ b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupRelApi.java @@ -32,7 +32,7 @@ public interface DataGroupRelApi { * @param groupIdList groupIdList * @param relId relId */ - void updateGroupRel(DataGroupTypeEnum type, List groupIdList, Long relId); + void updateRelGroup(DataGroupTypeEnum type, List groupIdList, Long relId); /** * 添加关联 @@ -40,14 +40,14 @@ public interface DataGroupRelApi { * @param groupId groupId * @param relId relId */ - void addGroupRel(Long groupId, Long relId); + void addGroupRel(DataGroupTypeEnum type, Long groupId, Long relId); /** * 批量添加关联 * * @param list list */ - void addGroupRel(List list); + void addGroupRel(DataGroupTypeEnum type, List list); /** * 通过 type 查询 relId 缓存 diff --git a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserApi.java b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserApi.java new file mode 100644 index 00000000..268291fa --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserApi.java @@ -0,0 +1,46 @@ +package com.orion.ops.module.infra.api; + +import com.orion.ops.module.infra.entity.dto.data.DataGroupCreateDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO; +import com.orion.ops.module.infra.enums.DataGroupTypeEnum; + +import java.util.List; + +/** + * 数据分组用户 对外服务类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-11-7 18:44 + */ +public interface DataGroupUserApi { + + /** + * 创建数据分组 + * + * @param type type + * @param userId userId + * @param dto dto + * @return id + */ + Long createDataGroup(DataGroupTypeEnum type, Long userId, DataGroupCreateDTO dto); + + /** + * 通过缓存查询数据分组 + * + * @param type type + * @param userId userId + * @return rows + */ + List getDataGroupList(DataGroupTypeEnum type, Long userId); + + /** + * 通过缓存查询数据分组 + * + * @param type type + * @param userId userId + * @return rows + */ + List getDataGroupTree(DataGroupTypeEnum type, Long userId); + +} diff --git a/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserRelApi.java b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserRelApi.java new file mode 100644 index 00000000..f46c5980 --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-provider/src/main/java/com/orion/ops/module/infra/api/DataGroupUserRelApi.java @@ -0,0 +1,109 @@ +package com.orion.ops.module.infra.api; + +import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO; +import com.orion.ops.module.infra.enums.DataGroupTypeEnum; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Future; + +/** + * 数据分组用户关联 对外服务类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-11-7 18:44 + */ +public interface DataGroupUserRelApi { + + /** + * 设置关联 + * + * @param type type + * @param userId userId + * @param groupIdList groupIdList + * @param relId relId + */ + void updateGroupRel(DataGroupTypeEnum type, Long userId, List groupIdList, Long relId); + + /** + * 添加关联 + * + * @param type type + * @param userId userId + * @param groupId groupId + * @param relId relId + */ + void addGroupRel(DataGroupTypeEnum type, Long userId, Long groupId, Long relId); + + /** + * 批量添加关联 + * + * @param type type + * @param userId userId + * @param list list + */ + void addGroupRel(DataGroupTypeEnum type, Long userId, List list); + + /** + * 通过 type 查询 relId 缓存 + *

+ * groupId - relId + * + * @param type type + * @param userId userId + * @return rows + */ + Map> getGroupRelList(DataGroupTypeEnum type, Long userId); + + /** + * 通过 groupId 查询 relId 缓存 + * + * @param type type + * @param userId userId + * @param groupId groupId + * @return relId + */ + Set getGroupRelIdByGroupId(DataGroupTypeEnum type, Long userId, Long groupId); + + /** + * 通过 relId 查询 groupId + * + * @param type type + * @param relId relId + * @return groupId + */ + Future> getGroupIdByRelIdAsync(DataGroupTypeEnum type, Long userId, Long relId); + + /** + * 删除数据分组关联 + * + * @param type type + * @param userId userId + * @param relId relId + * @return effect + */ + Integer deleteByRelId(DataGroupTypeEnum type, Long userId, Long relId); + + /** + * 批量删除数据分组关联 + * + * @param type type + * @param userId userId + * @param relIdList relIdList + * @return effect + */ + Integer deleteByRelIdList(DataGroupTypeEnum type, Long userId, List relIdList); + + /** + * 批量删除数据分组关联 + * + * @param type type + * @param userId userId + * @param groupIdList groupIdList + * @return effect + */ + Integer deleteByGroupIdList(DataGroupTypeEnum type, Long userId, List groupIdList); + +} 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 f7dc6e24..1f7938ba 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,5 +1,6 @@ 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; @@ -44,6 +45,7 @@ public class DataGroupApiImpl implements DataGroupApi { Valid.valid(dto); DataGroupCreateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto); request.setType(type.name()); + request.setUserId(Const.SYSTEM_USER_ID); return dataGroupService.createDataGroup(request); } @@ -63,13 +65,13 @@ public class DataGroupApiImpl implements DataGroupApi { @Override public List getDataGroupList(DataGroupTypeEnum type) { - List rows = dataGroupService.getDataGroupListByCache(type.name()); + List rows = dataGroupService.getDataGroupListByCache(type.name(), Const.SYSTEM_USER_ID); return DataGroupProviderConvert.MAPPER.toList(rows); } @Override public List getDataGroupTree(DataGroupTypeEnum type) { - List rows = dataGroupService.getDataGroupTreeByCache(type.name()); + List rows = dataGroupService.getDataGroupTreeByCache(type.name(), Const.SYSTEM_USER_ID); 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/api/impl/DataGroupRelApiImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupRelApiImpl.java index cbc15c63..c5e927c5 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupRelApiImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupRelApiImpl.java @@ -1,5 +1,6 @@ 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.DataGroupRelApi; import com.orion.ops.module.infra.convert.DataGroupRelProviderConvert; @@ -43,28 +44,28 @@ public class DataGroupRelApiImpl implements DataGroupRelApi { } @Override - public void updateGroupRel(DataGroupTypeEnum type, List groupIdList, Long relId) { + public void updateRelGroup(DataGroupTypeEnum type, List groupIdList, Long relId) { Valid.notNull(relId); - dataGroupRelService.updateGroupRel(type.name(), groupIdList, relId); + dataGroupRelService.updateRelGroup(type.name(), Const.SYSTEM_USER_ID, groupIdList, relId); } @Override - public void addGroupRel(Long groupId, Long relId) { + public void addGroupRel(DataGroupTypeEnum type, Long groupId, Long relId) { Valid.notNull(groupId); Valid.notNull(relId); - dataGroupRelService.addGroupRel(groupId, relId); + dataGroupRelService.addGroupRel(type.name(), groupId, Const.SYSTEM_USER_ID, relId); } @Override - public void addGroupRel(List list) { + public void addGroupRel(DataGroupTypeEnum type, List list) { Valid.valid(list); List rows = DataGroupRelProviderConvert.MAPPER.toList(list); - dataGroupRelService.addGroupRel(rows); + dataGroupRelService.addGroupRel(type.name(), Const.SYSTEM_USER_ID, rows); } @Override public Map> getGroupRelList(DataGroupTypeEnum type) { - List rows = dataGroupRelService.getGroupRelListByCache(type.name()); + List rows = dataGroupRelService.getGroupRelListByCache(type.name(), Const.SYSTEM_USER_ID); return rows.stream().collect( Collectors.groupingBy( DataGroupRelCacheDTO::getGroupId, @@ -81,7 +82,7 @@ public class DataGroupRelApiImpl implements DataGroupRelApi { @Override @Async("asyncExecutor") public Future> getGroupIdByRelIdAsync(DataGroupTypeEnum type, Long relId) { - Set groupIdList = dataGroupRelService.getGroupRelByRelId(type.name(), relId) + Set groupIdList = dataGroupRelService.getGroupRelByRelId(type.name(), Const.SYSTEM_USER_ID, relId) .stream() .map(DataGroupRelDO::getGroupId) .collect(Collectors.toSet()); @@ -90,17 +91,17 @@ public class DataGroupRelApiImpl implements DataGroupRelApi { @Override public Integer deleteByRelId(DataGroupTypeEnum type, Long relId) { - return dataGroupRelService.deleteByRelId(type.name(), relId); + return dataGroupRelService.deleteByRelId(type.name(), Const.SYSTEM_USER_ID, relId); } @Override public Integer deleteByRelIdList(DataGroupTypeEnum type, List relIdList) { - return dataGroupRelService.deleteByRelIdList(type.name(), relIdList); + return dataGroupRelService.deleteByRelIdList(type.name(), Const.SYSTEM_USER_ID, relIdList); } @Override public Integer deleteByGroupIdList(DataGroupTypeEnum type, List groupIdList) { - return dataGroupRelService.deleteByGroupIdList(type.name(), groupIdList); + return dataGroupRelService.deleteByGroupIdList(type.name(), Const.SYSTEM_USER_ID, groupIdList); } } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupUserApiImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupUserApiImpl.java new file mode 100644 index 00000000..50cb08d5 --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupUserApiImpl.java @@ -0,0 +1,53 @@ +package com.orion.ops.module.infra.api.impl; + +import com.orion.ops.framework.common.utils.Valid; +import com.orion.ops.module.infra.api.DataGroupUserApi; +import com.orion.ops.module.infra.convert.DataGroupProviderConvert; +import com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupCreateDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO; +import com.orion.ops.module.infra.entity.request.data.DataGroupCreateRequest; +import com.orion.ops.module.infra.enums.DataGroupTypeEnum; +import com.orion.ops.module.infra.service.DataGroupService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 数据分组 对外服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-11-7 18:44 + */ +@Slf4j +@Service +public class DataGroupUserApiImpl implements DataGroupUserApi { + + @Resource + private DataGroupService dataGroupService; + + @Override + public Long createDataGroup(DataGroupTypeEnum type, Long userId, DataGroupCreateDTO dto) { + Valid.valid(dto); + DataGroupCreateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto); + request.setType(type.name()); + request.setUserId(userId); + return dataGroupService.createDataGroup(request); + } + + @Override + public List getDataGroupList(DataGroupTypeEnum type, Long userId) { + List rows = dataGroupService.getDataGroupListByCache(type.name(), userId); + return DataGroupProviderConvert.MAPPER.toList(rows); + } + + @Override + public List getDataGroupTree(DataGroupTypeEnum type, Long userId) { + List rows = dataGroupService.getDataGroupTreeByCache(type.name(), userId); + 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/api/impl/DataGroupUserRelApiImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupUserRelApiImpl.java new file mode 100644 index 00000000..70aa3720 --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/api/impl/DataGroupUserRelApiImpl.java @@ -0,0 +1,100 @@ +package com.orion.ops.module.infra.api.impl; + +import com.orion.ops.framework.common.utils.Valid; +import com.orion.ops.module.infra.api.DataGroupUserRelApi; +import com.orion.ops.module.infra.convert.DataGroupRelProviderConvert; +import com.orion.ops.module.infra.entity.domain.DataGroupRelDO; +import com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO; +import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest; +import com.orion.ops.module.infra.enums.DataGroupTypeEnum; +import com.orion.ops.module.infra.service.DataGroupRelService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; +import java.util.stream.Collectors; + +/** + * 数据分组关联 对外服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-11-7 18:44 + */ +@Slf4j +@Service +public class DataGroupUserRelApiImpl implements DataGroupUserRelApi { + + @Resource + private DataGroupRelService dataGroupRelService; + + @Override + public void updateGroupRel(DataGroupTypeEnum type, Long userId, List groupIdList, Long relId) { + Valid.notNull(relId); + dataGroupRelService.updateRelGroup(type.name(), userId, groupIdList, relId); + } + + @Override + public void addGroupRel(DataGroupTypeEnum type, Long userId, Long groupId, Long relId) { + Valid.notNull(groupId); + Valid.notNull(relId); + dataGroupRelService.addGroupRel(type.name(), userId, groupId, relId); + } + + @Override + public void addGroupRel(DataGroupTypeEnum type, Long userId, List list) { + Valid.valid(list); + List rows = DataGroupRelProviderConvert.MAPPER.toList(list); + dataGroupRelService.addGroupRel(type.name(), userId, rows); + } + + @Override + public Map> getGroupRelList(DataGroupTypeEnum type, Long userId) { + List rows = dataGroupRelService.getGroupRelListByCache(type.name(), userId); + return rows.stream().collect( + Collectors.groupingBy( + DataGroupRelCacheDTO::getGroupId, + Collectors.mapping(DataGroupRelCacheDTO::getRelId, Collectors.toSet()) + )); + } + + @Override + public Set getGroupRelIdByGroupId(DataGroupTypeEnum type, Long userId, Long groupId) { + List rows = dataGroupRelService.getGroupRelIdListByCache(type.name(), groupId); + return new HashSet<>(rows); + } + + @Override + @Async("asyncExecutor") + public Future> getGroupIdByRelIdAsync(DataGroupTypeEnum type, Long userId, Long relId) { + Set groupIdList = dataGroupRelService.getGroupRelByRelId(type.name(), userId, relId) + .stream() + .map(DataGroupRelDO::getGroupId) + .collect(Collectors.toSet()); + return CompletableFuture.completedFuture(groupIdList); + } + + @Override + public Integer deleteByRelId(DataGroupTypeEnum type, Long userId, Long relId) { + return dataGroupRelService.deleteByRelId(type.name(), userId, relId); + } + + @Override + public Integer deleteByRelIdList(DataGroupTypeEnum type, Long userId, List relIdList) { + return dataGroupRelService.deleteByRelIdList(type.name(), userId, relIdList); + } + + @Override + public Integer deleteByGroupIdList(DataGroupTypeEnum type, Long userId, List groupIdList) { + return dataGroupRelService.deleteByGroupIdList(type.name(), userId, groupIdList); + } + +} 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 27905062..dbc45094 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}") + .key("data:group-list:{}:{}") + .desc("数据分组列表结构 ${type} ${userId}") .type(DataGroupCacheDTO.class) .struct(RedisCacheStruct.STRING) .timeout(1, TimeUnit.DAYS) .build(); CacheKeyDefine DATA_GROUP_TREE = new CacheKeyBuilder() - .key("data:group-tree:{}") - .desc("数据分组树结构 ${type}") + .key("data:group-tree:{}:{}") + .desc("数据分组树结构 ${type} ${userId}") .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}") + .key("data:group-rel:type:{}:{}") + .desc("数据分组数据关联-类型 ${type} ${userId}") .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 b6febf5b..3cf96218 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 @@ -42,6 +42,10 @@ public class DataGroupDO extends BaseDO { @TableField("type") private String type; + @Schema(description = "用户id") + @TableField("user_id") + private Long userId; + @Schema(description = "排序") @TableField("sort") private Integer sort; 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 ddc42b17..41a32044 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 @@ -42,4 +42,8 @@ public class DataGroupRelDO extends BaseDO { @TableField("type") private String type; + @Schema(description = "用户id") + @TableField("user_id") + private Long userId; + } 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 aba4bd6e..ec9ceba3 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,6 +25,15 @@ import java.io.Serializable; @Schema(name = "DataGroupCreateRequest", description = "数据分组 创建请求对象") public class DataGroupCreateRequest implements Serializable { + @NotBlank + @Size(max = 16) + @Schema(description = "组类型") + private String type; + + @NotNull + @Schema(description = "用户id") + private Long userId; + @NotNull @Schema(description = "父id") private Long parentId; @@ -34,9 +43,4 @@ public class DataGroupCreateRequest implements Serializable { @Schema(description = "组名称") private String name; - @NotBlank - @Size(max = 16) - @Schema(description = "组类型") - private String type; - } 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 f8b6c7a4..765f0d68 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 @@ -16,7 +16,7 @@ import java.util.List; public interface DataGroupRelService { /** - * 设置关联 + * 设置分组关联 * * @param groupId groupId * @param relIdList relIdList @@ -24,13 +24,14 @@ public interface DataGroupRelService { void updateGroupRel(Long groupId, List relIdList); /** - * 设置关联 + * 设置关联分组 * * @param type type + * @param userId userId * @param groupIdList groupIdList * @param relId relId */ - void updateGroupRel(String type, List groupIdList, Long relId); + void updateRelGroup(String type, Long userId, List groupIdList, Long relId); /** * 添加关联 @@ -38,22 +39,23 @@ public interface DataGroupRelService { * @param groupId groupId * @param relId relId */ - void addGroupRel(Long groupId, Long relId); + void addGroupRel(String type, Long userId, Long groupId, Long relId); /** * 添加关联 * * @param list list */ - void addGroupRel(List list); + void addGroupRel(String type, Long userId, List list); /** * 通过 type 查询 relId 缓存 * - * @param type type + * @param type type + * @param userId userId * @return rows */ - List getGroupRelListByCache(String type); + List getGroupRelListByCache(String type, Long userId); /** * 通过 groupId 查询 relId 缓存 @@ -67,37 +69,41 @@ public interface DataGroupRelService { /** * 通过 relId 查询 groupRel * - * @param type type - * @param relId relId + * @param type type + * @param userId userId + * @param relId relId * @return rows */ - List getGroupRelByRelId(String type, Long relId); + List getGroupRelByRelId(String type, Long userId, Long relId); /** * 删除数据分组关联 * - * @param type type - * @param relId relId + * @param type type + * @param userId userId + * @param relId relId * @return effect */ - Integer deleteByRelId(String type, Long relId); + Integer deleteByRelId(String type, Long userId, Long relId); /** * 批量删除数据分组关联 * * @param type type + * @param userId userId * @param relIdList relIdList * @return effect */ - Integer deleteByRelIdList(String type, List relIdList); + Integer deleteByRelIdList(String type, Long userId, List relIdList); /** * 批量删除数据分组关联 * + * @param userId userId * @param type type * @param groupIdList groupIdList * @return effect */ - Integer deleteByGroupIdList(String type, List groupIdList); + Integer deleteByGroupIdList(String type, Long userId, List groupIdList); } 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 2dd7dba8..b2d6297d 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,25 +43,35 @@ public interface DataGroupService { /** * 通过缓存查询数据分组 - 列表 * - * @param type type + * @param type type + * @param userId userId * @return rows */ - List getDataGroupListByCache(String type); + List getDataGroupListByCache(String type, Long userId); /** * 通过缓存查询数据分组 - 树结构 * - * @param type type + * @param type type + * @param userId userId * @return rows */ - List getDataGroupTreeByCache(String type); + List getDataGroupTreeByCache(String type, Long userId); /** - * 删除数据分组 + * 通过 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 7cadb6d8..eb4d1000 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 @@ -55,6 +55,7 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { DataGroupDO group = dataGroupDAO.selectById(groupId); Valid.notNull(group, ErrorMessage.GROUP_ABSENT); String type = group.getType(); + Long userId = group.getUserId(); // 设置日志参数 OperatorLogs.add(OperatorLogs.GROUP_NAME, group.getName()); if (Lists.isEmpty(relIdList)) { @@ -76,15 +77,16 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { dataGroupRelDAO.deleteBatchIds(deleteIdList); } // 查询新增的部分 - List persetRelIdList = records.stream() + List presentRelIdList = records.stream() .map(DataGroupRelDO::getRelId) .collect(Collectors.toList()); - relIdList.removeIf(persetRelIdList::contains); + relIdList.removeIf(presentRelIdList::contains); if (!relIdList.isEmpty()) { List insertRecords = relIdList.stream() .map(s -> DataGroupRelDO.builder() - .groupId(groupId) .type(type) + .userId(userId) + .groupId(groupId) .relId(s) .build()) .collect(Collectors.toList()); @@ -92,45 +94,46 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { } } // 删除缓存 - this.deleteCache(type, Lists.of(groupId)); + this.deleteCache(type, userId, Lists.singleton(groupId)); } @Override @Transactional(rollbackFor = Exception.class) - public void updateGroupRel(String type, List groupIdList, Long relId) { + public void updateRelGroup(String type, Long userId, List groupIdList, Long relId) { Valid.notNull(relId); // 删除引用 - this.deleteByRelId(type, relId); + this.deleteByRelId(type, userId, relId); // 插入引用 if (!Lists.isEmpty(groupIdList)) { List relList = groupIdList.stream() .map(s -> DataGroupRelDO.builder() .type(type) + .userId(userId) .groupId(s) .relId(relId) .build()) .collect(Collectors.toList()); dataGroupRelDAO.insertBatch(relList); // 删除缓存 - this.deleteCache(type, groupIdList); + this.deleteCache(type, userId, groupIdList); } } @Override @Transactional(rollbackFor = Exception.class) - public void addGroupRel(Long groupId, Long relId) { + public void addGroupRel(String type, Long userId, Long groupId, Long relId) { DataGroupRelCreateRequest record = DataGroupRelCreateRequest.builder() .groupId(Valid.notNull(groupId)) .relId(Valid.notNull(relId)) .build(); // 插入 SpringHolder.getBean(DataGroupRelService.class) - .addGroupRel(Lists.singleton(record)); + .addGroupRel(type, userId, Lists.singleton(record)); } @Override @Transactional(rollbackFor = Exception.class) - public void addGroupRel(List list) { + public void addGroupRel(String type, Long userId, List list) { if (Lists.isEmpty(list)) { return; } @@ -140,7 +143,6 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { // 查询分组信息 List groups = dataGroupDAO.selectBatchIds(groupMapping.keySet()); Valid.eq(groups.size(), groupMapping.size(), ErrorMessage.GROUP_ABSENT); - String type = groups.get(0).getType(); // 查询关联是否存在 groupMapping.forEach((k, v) -> { List relIdList = v.stream() @@ -167,18 +169,19 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { v.forEach(s -> records.add(DataGroupRelDO.builder() .groupId(k) .type(type) + .userId(userId) .relId(s.getRelId()) .build())); }); // 插入 dataGroupRelDAO.insertBatch(records); // 删除缓存 - this.deleteCache(type, groupMapping.keySet()); + this.deleteCache(type, userId, groupMapping.keySet()); } @Override - public List getGroupRelListByCache(String type) { - String key = DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type); + public List getGroupRelListByCache(String type, Long userId) { + String key = DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type, userId); // 查询缓存 List list = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE); if (Lists.isEmpty(list)) { @@ -186,6 +189,7 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { list = dataGroupRelDAO.of() .createWrapper() .eq(DataGroupRelDO::getType, type) + .eq(DataGroupRelDO::getUserId, userId) .then() .list(DataGroupRelConvert.MAPPER::toCache); // 设置屏障 防止穿透 @@ -224,10 +228,11 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { } @Override - public List getGroupRelByRelId(String type, Long relId) { + public List getGroupRelByRelId(String type, Long userId, Long relId) { return dataGroupRelDAO.of() .createWrapper() .eq(DataGroupRelDO::getType, type) + .eq(DataGroupRelDO::getUserId, userId) .eq(DataGroupRelDO::getRelId, relId) .then() .list(); @@ -235,14 +240,14 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { @Override @Transactional(rollbackFor = Exception.class) - public Integer deleteByRelId(String type, Long relId) { + public Integer deleteByRelId(String type, Long userId, Long relId) { return SpringHolder.getBean(DataGroupRelService.class) - .deleteByRelIdList(type, Lists.singleton(relId)); + .deleteByRelIdList(type, userId, Lists.singleton(relId)); } @Override @Transactional(rollbackFor = Exception.class) - public Integer deleteByRelIdList(String type, List relIdList) { + public Integer deleteByRelIdList(String type, Long userId, List relIdList) { if (Strings.isBlank(type) || Lists.isEmpty(relIdList)) { return 0; } @@ -250,6 +255,7 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { List rows = dataGroupRelDAO.of() .createWrapper() .eq(DataGroupRelDO::getType, type) + .eq(DataGroupRelDO::getUserId, userId) .in(DataGroupRelDO::getRelId, relIdList) .then() .list(); @@ -268,17 +274,17 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { // 删除数据库 int effect = dataGroupRelDAO.deleteBatchIds(idList); // 删除缓存 - this.deleteCache(type, groupIdList); + this.deleteCache(type, userId, groupIdList); return effect; } @Override @Transactional(rollbackFor = Exception.class) - public Integer deleteByGroupIdList(String type, List groupIdList) { + public Integer deleteByGroupIdList(String type, Long userId, List groupIdList) { // 删除数据库 int effect = dataGroupRelDAO.deleteByGroupId(groupIdList); // 删除缓存 - this.deleteCache(type, groupIdList); + this.deleteCache(type, userId, groupIdList); return effect; } @@ -286,11 +292,12 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { * 删除缓存 * * @param type type + * @param userId userId * @param groupIdList groupIdList */ - private void deleteCache(String type, Collection groupIdList) { + private void deleteCache(String type, Long userId, Collection groupIdList) { // 类型缓存 - List keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type)); + List keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type, userId)); // 分组缓存 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 a140ed07..de3981d6 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 @@ -13,8 +13,10 @@ import com.orion.ops.framework.redis.core.utils.RedisStrings; import com.orion.ops.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.ops.module.infra.convert.DataGroupConvert; import com.orion.ops.module.infra.dao.DataGroupDAO; +import com.orion.ops.module.infra.dao.DataGroupRelDAO; import com.orion.ops.module.infra.define.cache.DataGroupCacheKeyDefine; import com.orion.ops.module.infra.entity.domain.DataGroupDO; +import com.orion.ops.module.infra.entity.domain.DataGroupRelDO; import com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO; import com.orion.ops.module.infra.entity.request.data.DataGroupCreateRequest; import com.orion.ops.module.infra.entity.request.data.DataGroupMoveRequest; @@ -43,6 +45,9 @@ public class DataGroupServiceImpl implements DataGroupService { @Resource private DataGroupDAO dataGroupDAO; + @Resource + private DataGroupRelDAO dataGroupRelDAO; + @Resource private DataGroupRelService dataGroupRelService; @@ -61,7 +66,7 @@ public class DataGroupServiceImpl implements DataGroupService { Long id = record.getId(); log.info("DataGroupService-createDataGroup id: {}, effect: {}", id, effect); // 删除缓存 - this.deleteCache(request.getType()); + this.deleteCache(record.getUserId(), request.getType()); return id; } @@ -85,7 +90,7 @@ public class DataGroupServiceImpl implements DataGroupService { // 更新 int effect = dataGroupDAO.updateById(updateRecord); // 删除缓存 - this.deleteCache(record.getType()); + this.deleteCache(record.getUserId(), record.getType()); return effect; } @@ -139,7 +144,7 @@ public class DataGroupServiceImpl implements DataGroupService { effect = dataGroupDAO.updateById(update); } // 删除缓存 - this.deleteCache(type); + this.deleteCache(moveRecord.getUserId(), type); // 添加日志参数 OperatorLogs.add(OperatorLogs.SOURCE, moveRecord.getName()); OperatorLogs.add(OperatorLogs.TARGET, targetRecord.getName()); @@ -148,15 +153,16 @@ public class DataGroupServiceImpl implements DataGroupService { } @Override - public List getDataGroupListByCache(String type) { + public List getDataGroupListByCache(String type, Long userId) { // 查询缓存 - String key = DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type); + String key = DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type, userId); 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); // 设置屏障 防止穿透 @@ -170,13 +176,13 @@ public class DataGroupServiceImpl implements DataGroupService { } @Override - public List getDataGroupTreeByCache(String type) { + public List getDataGroupTreeByCache(String type, Long userId) { // 查询缓存 - String key = DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type); + String key = DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type, userId); List treeData = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_TREE); if (Lists.isEmpty(treeData)) { // 查询列表缓存 - List rows = this.getDataGroupListByCache(type); + List rows = this.getDataGroupListByCache(type, userId); // 设置屏障 防止穿透 CacheBarriers.checkBarrier(rows, DataGroupCacheDTO::new); if (!Lists.isEmpty(rows)) { @@ -210,15 +216,29 @@ public class DataGroupServiceImpl implements DataGroupService { // 删除分组 int effect = dataGroupDAO.deleteBatchIds(deleteIdList); // 删除组内数据 - dataGroupRelService.deleteByGroupIdList(type, deleteIdList); + dataGroupRelService.deleteByGroupIdList(type, record.getUserId(), deleteIdList); log.info("DataGroupService-deleteDataGroupById id: {}, effect: {}", id, effect); // 删除缓存 - this.deleteCache(type); + this.deleteCache(record.getUserId(), type); // 添加日志参数 OperatorLogs.add(OperatorLogs.GROUP_NAME, record.getName()); return effect; } + @Override + public Integer deleteDataGroupByUserId(Long userId) { + // 删除分组 + LambdaQueryWrapper deleteGroup = dataGroupDAO.wrapper() + .eq(DataGroupDO::getUserId, userId); + int effect = dataGroupDAO.delete(deleteGroup); + // 删除分组引用 + LambdaQueryWrapper deleteRel = dataGroupRelDAO.wrapper() + .eq(DataGroupRelDO::getUserId, userId); + effect += dataGroupRelDAO.delete(deleteRel); + // 不删除缓存 自动过期 + return effect; + } + /** * 获取所有子节点 id * @@ -252,8 +272,9 @@ public class DataGroupServiceImpl implements DataGroupService { .ne(DataGroupDO::getId, domain.getId()) // 用其他字段做重复校验 .eq(DataGroupDO::getParentId, domain.getParentId()) - .eq(DataGroupDO::getName, domain.getName()) - .eq(DataGroupDO::getType, domain.getType()); + .eq(DataGroupDO::getType, domain.getType()) + .eq(DataGroupDO::getUserId, domain.getUserId()) + .eq(DataGroupDO::getName, domain.getName()); // 检查是否存在 boolean present = dataGroupDAO.of(wrapper).present(); Valid.isFalse(present, ErrorMessage.DATA_PRESENT); @@ -262,11 +283,12 @@ public class DataGroupServiceImpl implements DataGroupService { /** * 删除缓存 * - * @param type type + * @param userId userId + * @param type type */ - private void deleteCache(String type) { - RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type), - DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type)); + private void deleteCache(Long userId, String type) { + RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type, userId), + DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type, userId)); } } 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 b3828d36..c300c462 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 @@ -14,7 +14,6 @@ import com.orion.ops.framework.redis.core.utils.RedisStrings; import com.orion.ops.framework.redis.core.utils.RedisUtils; import com.orion.ops.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.ops.framework.security.core.utils.SecurityUtils; -import com.orion.ops.module.infra.define.config.AppAuthenticationConfig; import com.orion.ops.module.infra.convert.SystemUserConvert; import com.orion.ops.module.infra.dao.OperatorLogDAO; import com.orion.ops.module.infra.dao.SystemRoleDAO; @@ -23,6 +22,7 @@ import com.orion.ops.module.infra.dao.SystemUserRoleDAO; import com.orion.ops.module.infra.define.RoleDefine; import com.orion.ops.module.infra.define.cache.TipsCacheKeyDefine; import com.orion.ops.module.infra.define.cache.UserCacheKeyDefine; +import com.orion.ops.module.infra.define.config.AppAuthenticationConfig; import com.orion.ops.module.infra.entity.domain.SystemUserDO; import com.orion.ops.module.infra.entity.dto.UserInfoDTO; import com.orion.ops.module.infra.entity.request.user.*; @@ -77,6 +77,9 @@ public class SystemUserServiceImpl implements SystemUserService { @Resource private DataExtraService dataExtraService; + @Resource + private DataGroupService dataGroupService; + @Override public Long createSystemUser(SystemUserCreateRequest request) { // 转换 @@ -253,6 +256,8 @@ public class SystemUserServiceImpl implements SystemUserService { dataPermissionService.deleteByUserId(id); // 删除用户拓展数据 dataExtraService.deleteByUserId(id); + // 删除分组数据 + dataGroupService.deleteDataGroupByUserId(id); } @Override 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 cea2ba06..68a63394 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,8 +6,9 @@ - + + @@ -18,7 +19,7 @@ - id, parent_id, name, type, sort, create_time, update_time, creator, updater, deleted + id, parent_id, type, user_id, name, sort, create_time, update_time, creator, updater, deleted diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupRelMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupRelMapper.xml index a0666b89..bb6d2639 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupRelMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataGroupRelMapper.xml @@ -5,9 +5,10 @@ + + - @@ -17,7 +18,7 @@ - id, group_id, rel_id, type, create_time, update_time, creator, updater, deleted + id, type, user_id, group_id, rel_id, create_time, update_time, creator, updater, deleted diff --git a/orion-ops-ui/src/components/asset/host-group/tree/index.vue b/orion-ops-ui/src/components/asset/host-group/tree/index.vue index 199eb528..8159aff4 100644 --- a/orion-ops-ui/src/components/asset/host-group/tree/index.vue +++ b/orion-ops-ui/src/components/asset/host-group/tree/index.vue @@ -136,6 +136,7 @@ return; } node.editable = true; + node.originTitle = node.title; nextTick(() => { renameInput.value?.focus(); }); @@ -267,10 +268,17 @@ } } } + } else { + // 修改为空则设置为之前的值 + node.title = node.originTitle; } node.editable = false; } - node.modCount = 0; + // 重置 modCount + setTimeout(() => { + node.modCount = 0; + node.originTitle = undefined; + }, 50); }; // 移动分组