瀏覽代碼

删除表单同时删除列

zhouhao 7 年之前
父節點
當前提交
bacb314541

+ 16 - 0
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-simple/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormService.java

@@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
+import org.springframework.cache.annotation.Caching;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
@@ -252,6 +253,21 @@ public class SimpleDynamicFormService extends GenericEntityService<DynamicFormEn
         return oldColumn;
     }
 
+    @Override
+    @Caching(
+            evict = {
+                    @CacheEvict(key = "'form-columns:'+#id"),
+                    @CacheEvict(key = "'form_id:'+#id")
+            })
+    public int deleteByPk(String id) {
+        Objects.requireNonNull(id, "id can not be null");
+
+        DefaultDSLDeleteService.createDelete(formColumnDao)
+                .where(DynamicFormColumnEntity.formId, id)
+                .exec();
+        return super.deleteByPk(id);
+    }
+
     @Override
     @CacheEvict(allEntries = true)
     public List<DynamicFormColumnEntity> deleteColumn(List<String> ids) {