From f648e1855797a8192075dbcb5183e7ae325fbe78 Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Fri, 17 Oct 2025 14:12:14 +0800 Subject: [PATCH] =?UTF-8?q?:hammer:=20=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=86=E7=BB=84=E9=80=BB=E8=BE=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visor/module/infra/dao/DataGroupDAO.java | 9 +++++- .../service/impl/DataGroupServiceImpl.java | 29 ++++++++++++------- .../main/resources/mapper/DataGroupMapper.xml | 26 +++++++++++------ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/dao/DataGroupDAO.java b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/dao/DataGroupDAO.java index f265e2db..05e43dd8 100644 --- a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/dao/DataGroupDAO.java +++ b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/dao/DataGroupDAO.java @@ -45,20 +45,27 @@ public interface DataGroupDAO extends IMapper { * * @param parentId parentId * @param type type + * @param userId userId * @return max(sort) */ - Integer selectMaxSort(@Param("parentId") Long parentId, @Param("type") String type); + Integer selectMaxSort(@Param("parentId") Long parentId, + @Param("type") String type, + @Param("userId") Long userId); /** * 修改排序 * * @param parentId parentId + * @param type type + * @param userId userId * @param condition 条件 * @param referSort 对比值 * @param addition 自增步长 * @return effect */ Integer updateSort(@Param("parentId") Long parentId, + @Param("type") String type, + @Param("userId") Long userId, @Param("condition") String condition, @Param("referSort") Integer referSort, @Param("addition") Integer addition); diff --git a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/service/impl/DataGroupServiceImpl.java b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/service/impl/DataGroupServiceImpl.java index 6af63e03..5f776efe 100644 --- a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/service/impl/DataGroupServiceImpl.java +++ b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/org/dromara/visor/module/infra/service/impl/DataGroupServiceImpl.java @@ -82,7 +82,7 @@ public class DataGroupServiceImpl implements DataGroupService { // 查询数据是否冲突 this.checkDataGroupPresent(record); // 查询最大排序 - Integer sort = dataGroupDAO.selectMaxSort(request.getParentId(), request.getType()); + Integer sort = dataGroupDAO.selectMaxSort(request.getParentId(), request.getType(), request.getUserId()); record.setSort(sort + Const.DEFAULT_SORT); // 插入 int effect = dataGroupDAO.insert(record); @@ -130,14 +130,19 @@ public class DataGroupServiceImpl implements DataGroupService { Assert.notNull(targetRecord, ErrorMessage.GROUP_ABSENT); // 更新 String type = moveRecord.getType(); + Long userId = moveRecord.getUserId(); Long targetParentId = targetRecord.getParentId(); int effect = 0; // 修改排序 if (MovePosition.TOP.equals(position)) { // 移动到元素上 将大于等于 targetRecord 的排序都加 10 - dataGroupDAO.updateSort(targetParentId, ">=", - targetRecord.getSort(), Const.DEFAULT_SORT); - // 修改 parentId sort + dataGroupDAO.updateSort(targetParentId, + type, + userId, + ">=", + targetRecord.getSort(), + Const.DEFAULT_SORT); + // 修改关联以及排序 DataGroupDO update = DataGroupDO.builder() .id(id) .parentId(targetParentId) @@ -146,8 +151,8 @@ public class DataGroupServiceImpl implements DataGroupService { effect = dataGroupDAO.updateById(update); } else if (MovePosition.IN.equals(position)) { // 移动到元素中 获取最大排序 - Integer newSort = dataGroupDAO.selectMaxSort(targetId, type) + Const.DEFAULT_SORT; - // 修改 parentId sort + Integer newSort = dataGroupDAO.selectMaxSort(targetId, type, userId) + Const.DEFAULT_SORT; + // 修改关联以及排序 DataGroupDO update = DataGroupDO.builder() .id(id) .parentId(targetId) @@ -156,9 +161,13 @@ public class DataGroupServiceImpl implements DataGroupService { effect = dataGroupDAO.updateById(update); } else if (MovePosition.BOTTOM.equals(position)) { // 移动到元素下 将大于 targetRecord 的排序都加 10 - dataGroupDAO.updateSort(targetParentId, ">", - targetRecord.getSort(), Const.DEFAULT_SORT); - // 修改 parentId sort + dataGroupDAO.updateSort(targetParentId, + type, + userId, + ">", + targetRecord.getSort(), + Const.DEFAULT_SORT); + // 修改关联以及排序 DataGroupDO update = DataGroupDO.builder() .id(id) .parentId(targetParentId) @@ -167,7 +176,7 @@ public class DataGroupServiceImpl implements DataGroupService { effect = dataGroupDAO.updateById(update); } // 删除缓存 - this.deleteCache(type, moveRecord.getUserId()); + this.deleteCache(type, userId); // 添加日志参数 OperatorLogs.add(OperatorLogs.SOURCE, moveRecord.getName()); OperatorLogs.add(OperatorLogs.TARGET, targetRecord.getName()); diff --git a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml index 4a2b5289..c39baafc 100644 --- a/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml +++ b/orion-visor-modules/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataGroupMapper.xml @@ -22,19 +22,27 @@ id, parent_id, type, user_id, name, sort, create_time, update_time, creator, updater, deleted - - UPDATE data_group - SET sort = sort + #{addition} - WHERE parent_id = #{parentId} - AND sort ${condition} #{referSort} - - + + UPDATE data_group + SET sort = sort + #{addition} + WHERE deleted = 0 + AND type = #{type} + AND parent_id = #{parentId} + AND sort ${condition} #{referSort} + + AND user_id = #{userId} + + +