Browse Source

代码优化

woody 11 months ago
parent
commit
8d3127bde6

+ 2 - 2
framework-database/src/main/java/com/chelvc/framework/database/support/DefaultTreeService.java

@@ -165,8 +165,8 @@ public class DefaultTreeService<M extends BaseMapper<T>, T extends TreeEntity<?
 
     @Override
     public boolean save(@NonNull T entity) {
+        entity.setSequence(StringUtils.EMPTY);
         return DatabaseContextHolder.transactional((Supplier<Boolean>) () -> {
-            entity.setSequence(StringUtils.EMPTY);
             boolean success = super.save(entity);
             if (success) {
                 // 更新树形节点序号
@@ -182,8 +182,8 @@ public class DefaultTreeService<M extends BaseMapper<T>, T extends TreeEntity<?
         if (ObjectUtils.isEmpty(entities)) {
             return false;
         }
+        entities.forEach(entity -> entity.setSequence(StringUtils.EMPTY));
         return DatabaseContextHolder.transactional((Supplier<Boolean>) () -> {
-            entities.forEach(entity -> entity.setSequence(StringUtils.EMPTY));
             boolean success = super.saveBatch(entities, batchSize);
             if (success) {
                 // 更新树形节点序号