瀏覽代碼

优化逻辑

zhouhao 7 年之前
父節點
當前提交
32795a86a5

+ 4 - 2
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java

@@ -92,7 +92,8 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
         applyPath(entity);
         List<E> childrenList = new ArrayList<>();
         TreeSupportEntity.expandTree2List(entity, childrenList, getIDGenerator());
-        super.insert(entity);
+//        super.insert(entity);
+//        childrenList.remove(entity);
         childrenList.forEach(this::saveOrUpdateForSingle);
         return entity.getId();
     }
@@ -115,7 +116,8 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
         assertNotNull(entity);
         List<E> childrenList = new ArrayList<>();
         TreeSupportEntity.expandTree2List(entity, childrenList, getIDGenerator());
-        this.saveOrUpdateForSingle(entity);
+//        this.saveOrUpdateForSingle(entity);
+//        childrenList.remove(entity);
         childrenList.forEach(this::saveOrUpdateForSingle);
         return childrenList.size() + 1;
     }

+ 1 - 1
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLQueryService.java

@@ -79,7 +79,7 @@ public interface DefaultDSLQueryService<E, PK>
         query.setSingleExecutor((param) -> {
             param.doPaging(0, 1);
             List<PO> list = dao.query(param);
-            if (null == list || list.size() == 0) {
+            if (null == list || list.isEmpty()) {
                 return null;
             } else {
                 return list.get(0);

+ 1 - 1
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java

@@ -110,7 +110,7 @@ public interface DefaultQueryByEntityService<E>
             ((QueryParamEntity) param).doPaging(0, 1);
         }
         List<E> list = this.select(param);
-        if (list.size() == 0) {
+        if (list.isEmpty()) {
             return null;
         } else {
             return list.get(0);

+ 6 - 4
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java

@@ -59,9 +59,10 @@ public abstract class GenericEntityService<E extends GenericEntity<PK>, PK>
     @Override
     public int deleteByPk(PK pk) {
         Assert.notNull(pk, "parameter can not be null");
-        return createDelete()
-                .where(GenericEntity.id, pk)
-                .exec();
+       return  getDao().deleteByPk(pk);
+//        return createDelete()
+//                .where(GenericEntity.id, pk)
+//                .exec();
     }
 
     @Override
@@ -108,7 +109,8 @@ public abstract class GenericEntityService<E extends GenericEntity<PK>, PK>
             }
             tryValidateProperty(selectByPk(entity.getId()) == null, "id", entity.getId() + "已存在");
         }
-        if (entity.getId() == null) {
+
+        if (entity.getId() == null && getIDGenerator() != null) {
             entity.setId(getIDGenerator().generate());
         }
         tryValidate(entity, CreateGroup.class);