فهرست منبع

Support updatePart kanban

sunyj 8 سال پیش
والد
کامیت
7e1d4c44db

+ 0 - 5
kanban-auth/src/main/java/com/uas/kanban/dao/UserDao.java

@@ -26,11 +26,6 @@ public class UserDao extends BaseDao<User> {
     @Autowired
     private PanelInstanceDao panelInstanceDao;
 
-    @Override
-    protected String collectionSimpleName() {
-        return "用户";
-    }
-
     /**
      * 为指定用户分配面板
      *

+ 5 - 0
kanban-auth/src/main/java/com/uas/kanban/model/User.java

@@ -44,6 +44,11 @@ public class User extends BaseEntity {
      */
     private List<String> panelCodes;
 
+    @Override
+    public String collectionSimpleName() {
+        return "用户";
+    }
+
     public String getName() {
         return name;
     }

+ 72 - 124
kanban-common/src/main/java/com/uas/kanban/base/BaseDao.java

@@ -57,6 +57,64 @@ public class BaseDao<T extends BaseEntity> {
         entityClass = (Class<T>) actualTypeArguments[0];
     }
 
+    /**
+     * 对对象的字段进行检查,包括是否为空等,主要关注 {@link FieldProperty} 注解
+     *
+     * @param <K> 要检查的对象的类型
+     * @param k   要检查的对象
+     */
+    public static <K> void checkFields(@NotEmpty("k") K k) throws IllegalArgumentException, IllegalStateException {
+        Class<?> clazz = k.getClass();
+        Field[] declaredFields = clazz.getDeclaredFields();
+        String collectionName;
+        if (k instanceof BaseEntity) {
+            collectionName = ((BaseEntity) k).collectionSimpleName();
+        } else {
+            collectionName = clazz.getSimpleName();
+        }
+        for (Field field : declaredFields) {
+            int modifiers = field.getModifiers();
+            // 不处理static修饰的变量
+            if (Modifier.isStatic(modifiers)) {
+                continue;
+            }
+
+            Embedded embedded = field.getAnnotation(Embedded.class);
+            Reference reference = field.getAnnotation(Reference.class);
+            FieldProperty fieldProperty = field.getAnnotation(FieldProperty.class);
+            // 只有使用 {@link FieldProperty} 指定不可为空,或者是嵌入或引用对象,才处理
+            if ((fieldProperty == null || fieldProperty.nullable()) && embedded == null && reference == null) {
+                continue;
+            }
+            Object value = ObjectUtils.getValue(field, k);
+
+            // 如果使用 {@link FieldProperty} 指定不可为空,但是值为空,则抛出异常
+            if (fieldProperty != null && !fieldProperty.nullable() && ObjectUtils.isEmpty(value)) {
+                throw new IllegalArgumentException(collectionName + "字段为空:" + field.getName());
+            }
+            // 如果是嵌入或引用对象,并且不为空,则递归检测
+            if ((embedded != null || reference != null) && !ObjectUtils.isEmpty(value)) {
+                // 如果是Collection
+                if (value instanceof Collection) {
+                    Collection<?> collection = (Collection<?>) value;
+                    for (Object obj : collection) {
+                        checkFields(obj);
+                    }
+                } else if (value instanceof Map) {
+                    Map<?, ?> map = (Map<?, ?>) value;
+                    for (Object key : map.keySet()) {
+                        checkFields(key);
+                    }
+                    for (Object v : map.values()) {
+                        checkFields(v);
+                    }
+                } else {
+                    checkFields(value);
+                }
+            }
+        }
+    }
+
     /**
      * Returns a new query bound to the collection (a specific {@link DBCollection})
      *
@@ -77,7 +135,6 @@ public class BaseDao<T extends BaseEntity> {
         return datastore.createQuery(entityClass);
     }
 
-
     /**
      * 全局过滤,如有需要,可重写该方法
      *
@@ -147,7 +204,7 @@ public class BaseDao<T extends BaseEntity> {
      * @param ignoreFields 不更新的字段
      * @return the new UpdateOperations instance
      */
-    public UpdateOperations<T> createUpdateOperations(@NotEmpty("t") T t, Set<String> ignoreFields) {
+    private UpdateOperations<T> createUpdateOperations(@NotEmpty("t") T t, Set<String> ignoreFields) {
         UpdateOperations<T> operations = createUpdateOperations();
         Field[] declaredFields = entityClass.getDeclaredFields();
         // 通过反射遍历对象的成员变量,自动构造UpdateOperations
@@ -163,7 +220,7 @@ public class BaseDao<T extends BaseEntity> {
             if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers) || Modifier.isTransient(modifiers)) {
                 continue;
             }
-            Object value = getValue(field, t);
+            Object value = ObjectUtils.getValue(field, t);
             // 如果值为空,则移除文档中的该字段
             if (ObjectUtils.isEmpty(value)) {
                 operations.unset(name);
@@ -174,60 +231,6 @@ public class BaseDao<T extends BaseEntity> {
         return operations;
     }
 
-    /**
-     * 利用反射获取指定对象的指定字段的值
-     *
-     * @param field 指定字段
-     * @param k     指定对象
-     * @return 指定字段的值
-     */
-    private <K> Object getValue(@NotEmpty("field") String field, @NotEmpty("k") K k) throws IllegalStateException, NoSuchFieldException {
-        return getValue(getField(field, k.getClass()), k);
-    }
-
-    /**
-     * 递归获取指定类的指定字段(包括父类的私有字段)
-     *
-     * @param field 指定字段
-     * @param clazz 指定类
-     * @return 指定字段
-     * @throws NoSuchFieldException
-     */
-    private Field getField(@NotEmpty("field") String field, @NotEmpty("clazz") Class<?> clazz) throws NoSuchFieldException {
-        try {
-            return clazz.getDeclaredField(field);
-        } catch (NoSuchFieldException e) {
-            Class<?> superclass = clazz.getSuperclass();
-            if (superclass != null) {
-                return getField(field, superclass);
-            }
-            throw e;
-        }
-    }
-
-    /**
-     * 利用反射获取指定对象的指定字段的值
-     *
-     * @param field 指定字段
-     * @param k     指定对象
-     * @return 指定字段的值
-     */
-    private <K> Object getValue(Field field, @NotEmpty("k") K k) throws IllegalStateException {
-        Object value;
-        try {
-            if (!field.isAccessible()) {
-                field.setAccessible(true);
-                value = field.get(k);
-                field.setAccessible(false);
-            } else {
-                value = field.get(k);
-            }
-        } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
-            throw new IllegalStateException("通过反射取值失败", e);
-        }
-        return value;
-    }
-
     /**
      * Saves an entity (Object) and updates the @Id field
      *
@@ -291,58 +294,6 @@ public class BaseDao<T extends BaseEntity> {
         return "已存在:{" + message.replace(":", "") + "}";
     }
 
-    /**
-     * 对对象的字段进行检查,包括是否为空等,主要关注 {@link FieldProperty} 注解
-     *
-     * @param <K> 要检查的对象的类型,可与 {@link T} 不同
-     * @param k   要检查的对象
-     */
-    public <K> void checkFields(@NotEmpty("k") K k) throws IllegalArgumentException, IllegalStateException {
-        Class<?> clazz = k.getClass();
-        Field[] declaredFields = clazz.getDeclaredFields();
-        for (Field field : declaredFields) {
-            int modifiers = field.getModifiers();
-            // 不处理static修饰的变量
-            if (Modifier.isStatic(modifiers)) {
-                continue;
-            }
-
-            Embedded embedded = field.getAnnotation(Embedded.class);
-            Reference reference = field.getAnnotation(Reference.class);
-            FieldProperty fieldProperty = field.getAnnotation(FieldProperty.class);
-            // 只有使用 {@link FieldProperty} 指定不可为空,或者是嵌入或引用对象,才处理
-            if ((fieldProperty == null || fieldProperty.nullable()) && embedded == null && reference == null) {
-                continue;
-            }
-            Object value = getValue(field, k);
-
-            // 如果使用 {@link FieldProperty} 指定不可为空,但是值为空,则抛出异常
-            if (fieldProperty != null && !fieldProperty.nullable() && ObjectUtils.isEmpty(value)) {
-                throw new IllegalArgumentException("字段为空:" + clazz.getName() + "." + field.getName() + " = " + value);
-            }
-            // 如果是嵌入或引用对象,并且不为空,则递归检测
-            if ((embedded != null || reference != null) && !ObjectUtils.isEmpty(value)) {
-                // 如果是Collection
-                if (value instanceof Collection) {
-                    Collection<?> collection = (Collection<?>) value;
-                    for (Object obj : collection) {
-                        checkFields(obj);
-                    }
-                } else if (value instanceof Map) {
-                    Map<?, ?> map = (Map<?, ?>) value;
-                    for (Object key : map.keySet()) {
-                        checkFields(key);
-                    }
-                    for (Object v : map.values()) {
-                        checkFields(v);
-                    }
-                } else {
-                    checkFields(value);
-                }
-            }
-        }
-    }
-
     /**
      * 删除所有数据
      *
@@ -433,12 +384,16 @@ public class BaseDao<T extends BaseEntity> {
      */
     public int updatePart(@NotEmpty("json") String json) {
         JSONObject jsonObject = JSONObject.parseObject(json);
-        T t = JSONObject.parseObject(json, entityClass);
-        if (t == null) {
-            throw new IllegalArgumentException("解析得到的数据为空");
+        String code = jsonObject.getString("code");
+        if (StringUtils.isEmpty(code)) {
+            throw new IllegalArgumentException("未指定 code");
         }
-        String code = t.codeNotEmpty();
-        jsonObject.remove("code");
+        // 不更新父类中的字段,可能包括 id, code, version 等
+        List<Field> parentFields = ObjectUtils.recursivelyGetParentField(entityClass);
+        for (Field field : parentFields) {
+            jsonObject.remove(field.getName());
+        }
+
         UpdateOperations<T> operations = createUpdateOperations();
         Set<String> keySet = jsonObject.keySet();
         for (String key : keySet) {
@@ -453,7 +408,7 @@ public class BaseDao<T extends BaseEntity> {
             if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers) || Modifier.isTransient(modifiers)) {
                 continue;
             }
-            Object value = getValue(field, t);
+            Object value = jsonObject.getObject(field.getName(), field.getType());
             // 如果值为空,则移除文档中的该字段
             if (ObjectUtils.isEmpty(value)) {
                 operations.unset(key);
@@ -528,18 +483,11 @@ public class BaseDao<T extends BaseEntity> {
     public T checkExist(@NotEmpty("code") String code) throws IllegalStateException {
         T t = findOne(code);
         if (t == null) {
-            throw new IllegalStateException(collectionSimpleName() + "不存在:" + code);
+            throw new IllegalStateException(t.collectionSimpleName() + "不存在:" + code);
         }
         return t;
     }
 
-    /**
-     * @return 集合简称
-     */
-    protected String collectionSimpleName() {
-        return entityClass.getSimpleName();
-    }
-
     /**
      * Find the given entities (by code);
      *
@@ -619,7 +567,7 @@ public class BaseDao<T extends BaseEntity> {
         if (!CollectionUtils.isEmpty(list)) {
             for (T t : list) {
                 try {
-                    Object value = getValue(field, t);
+                    Object value = ObjectUtils.recursivelyGetValue(field, t);
                     if (value != null) {
                         Class<?> valueClass = value.getClass();
                         if (clazz.isAssignableFrom(valueClass)) {

+ 7 - 0
kanban-common/src/main/java/com/uas/kanban/base/BaseEntity.java

@@ -57,6 +57,13 @@ public abstract class BaseEntity extends Coded {
         super.init();
     }
 
+    /**
+     * @return 集合简称
+     */
+    public String collectionSimpleName() {
+        return getClass().getSimpleName();
+    }
+
     public Date getCreateTime() {
         return createTime;
     }

+ 90 - 0
kanban-common/src/main/java/com/uas/kanban/util/ObjectUtils.java

@@ -2,8 +2,10 @@ package com.uas.kanban.util;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.uas.kanban.annotation.NotEmpty;
 
 import java.io.*;
+import java.lang.reflect.Field;
 import java.util.*;
 import java.util.Map.Entry;
 
@@ -179,4 +181,92 @@ public class ObjectUtils {
         }
         return list;
     }
+
+    /**
+     * 利用反射获取指定对象的指定字段的值
+     *
+     * @param field 指定字段
+     * @param k     指定对象
+     * @return 指定字段的值
+     */
+    public static <K> Object getValue(@NotEmpty("field") Field field, @NotEmpty("k") K k) throws IllegalStateException {
+        Object value;
+        try {
+            if (!field.isAccessible()) {
+                field.setAccessible(true);
+                value = field.get(k);
+                field.setAccessible(false);
+            } else {
+                value = field.get(k);
+            }
+        } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
+            throw new IllegalStateException("通过反射取值失败", e);
+        }
+        return value;
+    }
+
+    /**
+     * 利用反射递归获取指定对象的指定字段的值
+     *
+     * @param field 指定字段
+     * @param k     指定对象
+     * @return 指定字段的值
+     */
+    public static <K> Object recursivelyGetValue(@NotEmpty("field") String field, @NotEmpty("k") K k) throws IllegalStateException, NoSuchFieldException {
+        return getValue(recursivelyGetField(field, k.getClass()), k);
+    }
+
+    /**
+     * 递归获取指定类的指定字段(包括父类的私有字段)
+     *
+     * @param field 指定字段
+     * @param clazz 指定类
+     * @return 指定字段
+     * @throws NoSuchFieldException
+     */
+    private static Field recursivelyGetField(@NotEmpty("field") String field, @NotEmpty("clazz") Class<?> clazz) throws NoSuchFieldException {
+        try {
+            return clazz.getDeclaredField(field);
+        } catch (NoSuchFieldException e) {
+            Class<?> superclass = clazz.getSuperclass();
+            if (superclass != null) {
+                return recursivelyGetField(field, superclass);
+            }
+            throw e;
+        }
+    }
+
+    /**
+     * 递归获取父类(包括私有字段)的所有字段
+     *
+     * @param clazz 指定类
+     * @return 所有字段
+     */
+    public static List<Field> recursivelyGetParentField(@NotEmpty("clazz") Class<?> clazz) {
+        List<Field> fields = new ArrayList<>();
+        Class<?> superclass = clazz.getSuperclass();
+        if (superclass != null) {
+            fields.addAll(recursivelyGetField(superclass));
+        }
+        return fields;
+    }
+
+    /**
+     * 递归获取所有字段(包括父类的私有字段)
+     *
+     * @param clazz 指定类
+     * @return 所有字段
+     */
+    private static List<Field> recursivelyGetField(@NotEmpty("clazz") Class<?> clazz) {
+        List<Field> fields = new ArrayList<>();
+        Field[] declaredFields = clazz.getDeclaredFields();
+        if (!ArrayUtils.isEmpty(declaredFields)) {
+            fields.addAll(Arrays.asList(declaredFields));
+        }
+        Class<?> superclass = clazz.getSuperclass();
+        if (superclass != null) {
+            fields.addAll(recursivelyGetField(superclass));
+        }
+        return fields;
+    }
 }

+ 0 - 5
kanban-console/src/main/java/com/uas/kanban/dao/DataSourceDao.java

@@ -13,9 +13,4 @@ import org.springframework.stereotype.Component;
 @Component
 public class DataSourceDao extends BaseDao<DataSource> {
 
-    @Override
-    protected String collectionSimpleName() {
-        return "数据源";
-    }
-
 }

+ 17 - 5
kanban-console/src/main/java/com/uas/kanban/dao/KanbanDao.java

@@ -18,11 +18,6 @@ import java.util.List;
 @Component
 public class KanbanDao extends BaseDao<Kanban> {
 
-    @Override
-    protected String collectionSimpleName() {
-        return "看板";
-    }
-
     /**
      * 获取指定面板的看板
      *
@@ -50,4 +45,21 @@ public class KanbanDao extends BaseDao<Kanban> {
         }
     }
 
+    /**
+     * 获取面板 code
+     *
+     * @param code 看板 code
+     * @return 面板 code
+     */
+    public String findPanelCode(String code) {
+        List<String> panelCodes = findPanelCodes(Collections.singletonList(code));
+        int size = panelCodes.size();
+        if (size < 1) {
+            return null;
+        } else if (size > 1) {
+            throw new IllegalStateException("存在多个值:" + panelCodes);
+        }
+        return panelCodes.get(0);
+    }
+
 }

+ 1 - 6
kanban-console/src/main/java/com/uas/kanban/dao/PanelDao.java

@@ -42,16 +42,11 @@ public class PanelDao extends BaseDao<Panel> {
     public Panel checkExist(@NotEmpty("code") String code) throws IllegalStateException {
         Panel panel = findOne(code);
         if (panel == null) {
-            throw new IllegalStateException(collectionSimpleName() + "不存在或未分配:" + code);
+            throw new IllegalStateException(panel.collectionSimpleName() + "不存在或未分配:" + code);
         }
         return panel;
     }
 
-    @Override
-    protected String collectionSimpleName() {
-        return "面板";
-    }
-
     /**
      * 版本号加 1
      *

+ 0 - 5
kanban-console/src/main/java/com/uas/kanban/dao/PanelInstanceDao.java

@@ -31,11 +31,6 @@ public class PanelInstanceDao extends BaseDao<PanelInstance> {
         return filters;
     }
 
-    @Override
-    protected String collectionSimpleName() {
-        return "面板实例";
-    }
-
     /**
      * 获取指定面板的实例
      *

+ 0 - 5
kanban-console/src/main/java/com/uas/kanban/dao/ParameterDao.java

@@ -18,11 +18,6 @@ import java.util.List;
 @Component
 public class ParameterDao extends BaseDao<Parameter> {
 
-    @Override
-    protected String collectionSimpleName() {
-        return "参数";
-    }
-
     /**
      * 获取指定面板的参数
      *

+ 5 - 0
kanban-console/src/main/java/com/uas/kanban/model/DataSource.java

@@ -50,6 +50,11 @@ public class DataSource extends BaseEntity {
     @FieldProperty(nullable = false)
     private String password;
 
+    @Override
+    public String collectionSimpleName() {
+        return "数据源";
+    }
+
     public String getName() {
         return name;
     }

+ 5 - 0
kanban-console/src/main/java/com/uas/kanban/model/Kanban.java

@@ -52,6 +52,11 @@ public class Kanban extends BaseEntity {
     @FieldProperty(nullable = false)
     private String panelCode;
 
+    @Override
+    public String collectionSimpleName() {
+        return "看板";
+    }
+
     public String getName() {
         return name;
     }

+ 5 - 0
kanban-console/src/main/java/com/uas/kanban/model/Panel.java

@@ -50,6 +50,11 @@ public class Panel extends BaseEntity {
         super.init();
     }
 
+    @Override
+    public String collectionSimpleName() {
+        return "面板";
+    }
+
     public String getName() {
         return name;
     }

+ 7 - 0
kanban-console/src/main/java/com/uas/kanban/model/PanelInstance.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.kanban.annotation.FieldProperty;
 import com.uas.kanban.annotation.NotEmpty;
+import com.uas.kanban.base.BaseDao;
 import com.uas.kanban.base.BaseEntity;
 import com.uas.kanban.util.CollectionUtils;
 import com.uas.kanban.util.ObjectUtils;
@@ -88,6 +89,11 @@ public class PanelInstance extends BaseEntity {
         super.init();
     }
 
+    @Override
+    public String collectionSimpleName() {
+        return "面板实例";
+    }
+
     public Double getSwitchFrequency() {
         return switchFrequency;
     }
@@ -186,6 +192,7 @@ public class PanelInstance extends BaseEntity {
         relatedKanbans = new ArrayList<>();
         for (Kanban kanban : kanbans) {
             if (kanban.getEnabled() != null && kanban.getEnabled()) {
+                BaseDao.checkFields(kanban);
                 RelatedKanban relatedKanban = new RelatedKanban();
                 relatedKanban.setCode(kanban.getCode());
                 relatedKanban.setEnabled(true);

+ 5 - 0
kanban-console/src/main/java/com/uas/kanban/model/Parameter.java

@@ -86,6 +86,11 @@ public class Parameter extends BaseEntity {
         super.init();
     }
 
+    @Override
+    public String collectionSimpleName() {
+        return "参数";
+    }
+
     public String getName() {
         return name;
     }

+ 35 - 10
kanban-console/src/main/java/com/uas/kanban/service/impl/KanbanServiceImpl.java

@@ -1,18 +1,20 @@
 package com.uas.kanban.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.kanban.annotation.NotEmpty;
 import com.uas.kanban.base.BaseService;
 import com.uas.kanban.dao.KanbanDao;
 import com.uas.kanban.dao.PanelDao;
 import com.uas.kanban.exception.OperationException;
 import com.uas.kanban.model.Kanban;
-import com.uas.kanban.model.Panel;
 import com.uas.kanban.service.KanbanService;
+import com.uas.kanban.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 看板
@@ -32,29 +34,52 @@ public class KanbanServiceImpl extends BaseService<Kanban> implements KanbanServ
     @Override
     public Kanban save(@NotEmpty("json") String json) {
         // TODO update related Panel and PanelInstance
-        Kanban kanban = kanbanDao.parse(json);
-        panelDao.checkExist(kanban.getPanelCode());
+        panelDao.checkExist(kanbanDao.parse(json).getPanelCode());
         // 新增时,默认不启用,因此不更新面板的版本
-        return kanbanDao.save(kanban);
+        return super.save(json);
     }
 
     @Override
     public Kanban savePart(@NotEmpty("json") String json) {
-        return save(json);
+        // TODO update related Panel and PanelInstance
+        panelDao.checkExist(kanbanDao.parse(json).getPanelCode());
+        // 新增时,默认不启用,因此不更新面板的版本
+        return super.savePart(json);
     }
 
     @Override
     public int update(@NotEmpty("json") String json) throws IllegalArgumentException, OperationException {
         // TODO update related Panel and PanelInstance (old and new)
-        Kanban kanban = kanbanDao.parse(json);
-        Panel panel = panelDao.checkExist(kanban.getPanelCode());
-        panelDao.incVersion(Collections.singletonList(panel.getCode()));
-        return kanbanDao.update(kanban);
+        processPanel(json);
+        return super.update(json);
     }
 
     @Override
     public int updatePart(@NotEmpty("json") String json) throws IllegalArgumentException, OperationException {
-        return update(json);
+        // TODO update related Panel and PanelInstance (old and new)
+        processPanel(json);
+        return super.updatePart(json);
+    }
+
+    /**
+     * 处理看板关联的面板,包括检查 panelCode 是否被修改,更新面板版本等
+     *
+     * @param json 看板
+     * @throws OperationException panelCode 是否被修改
+     */
+    private void processPanel(@NotEmpty("json") String json) throws OperationException {
+        JSONObject jsonObject = JSONObject.parseObject(json);
+        String code = jsonObject.getString("code");
+        if (StringUtils.isEmpty(code)) {
+            throw new IllegalArgumentException("未指定 code");
+        }
+        String panelCode = jsonObject.getString("panelCode");
+        String oldPanelCode = kanbanDao.findPanelCode(code);
+        if (!StringUtils.isEmpty(panelCode) && !Objects.equals(panelCode, oldPanelCode)) {
+            throw new OperationException("不允许修改看板的 panelCode");
+        }
+        panelDao.checkExist(oldPanelCode);
+        panelDao.incVersion(Collections.singletonList(oldPanelCode));
     }
 
     @Override

+ 2 - 0
kanban-console/src/main/java/com/uas/kanban/service/impl/PanelInstanceServiceImpl.java

@@ -2,6 +2,7 @@ package com.uas.kanban.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.uas.kanban.annotation.NotEmpty;
+import com.uas.kanban.base.BaseDao;
 import com.uas.kanban.base.BaseService;
 import com.uas.kanban.dao.KanbanDao;
 import com.uas.kanban.dao.PanelDao;
@@ -218,6 +219,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
             kanbanCode = enabledKanbanCodes.get(0);
         }
         Kanban kanban = kanbanDao.checkExist(kanbanCode);
+        BaseDao.checkFields(kanban);
         String content = kanban.getContent();
         String title = kanban.getTitle();
         if (StringUtils.isEmpty(content)) {

+ 1 - 1
kanban-console/src/main/java/com/uas/kanban/support/DataSourceManager.java

@@ -49,7 +49,7 @@ public class DataSourceManager {
     private DataSourceCache getCache(@NotEmpty("dataSourceCode") String dataSourceCode) throws SQLException {
         DataSourceCache dataSourceCache = dataSourceCaches.get(dataSourceCode);
         DataSource dataSource = dataSourceDao.checkExist(dataSourceCode);
-        dataSourceDao.checkFields(dataSource);
+        BaseDao.checkFields(dataSource);
         // 存在数据库连接缓存
         if (dataSourceCache != null) {
             // 数据源信息没有更改,则使用缓存