AE86 5 éve
szülő
commit
366047df67

+ 8 - 7
dbsyncer-biz/src/main/java/org/dbsyncer/biz/checker/impl/tablegroup/TableGroupChecker.java

@@ -159,33 +159,34 @@ public class TableGroupChecker extends AbstractChecker {
         String eventFieldName = mapping.getListener().getEventFieldName();
         if (StringUtils.isNotBlank(eventFieldName)) {
             Map<String, Field> fields = convert2Map(group.getSourceTable().getColumn());
-            addFieldMapping(fieldMapping, eventFieldName, fields);
+            addFieldMapping(fieldMapping, eventFieldName, fields, true);
         }
 
         // 检查过滤条件是否在映射关系中
         List<Filter> filter = group.getFilter();
         if (!CollectionUtils.isEmpty(filter)) {
             Map<String, Field> fields = convert2Map(group.getSourceTable().getColumn());
-            filter.forEach(f -> addFieldMapping(fieldMapping, f.getName(), fields));
+            filter.forEach(f -> addFieldMapping(fieldMapping, f.getName(), fields, true));
         }
 
     }
 
-    private void addFieldMapping(List<FieldMapping> fieldMapping, String name, Map<String, Field> fields) {
+    private void addFieldMapping(List<FieldMapping> fieldMapping, String name, Map<String, Field> fields, boolean checkSource) {
         if (StringUtils.isNotBlank(name)) {
             boolean exist = false;
             for (FieldMapping m : fieldMapping) {
-                Field source = m.getSource();
-                if (null == source) {
+                Field f = checkSource ? m.getSource() : m.getTarget();
+                if (null == f) {
                     continue;
                 }
-                if (StringUtils.equals(source.getName(), name)) {
+                if (StringUtils.equals(f.getName(), name)) {
                     exist = true;
                     break;
                 }
             }
             if (!exist && null != fields.get(name)) {
-                fieldMapping.add(new FieldMapping(fields.get(name), null));
+                FieldMapping fm = checkSource ? new FieldMapping(fields.get(name), null) : new FieldMapping(null, fields.get(name));
+                fieldMapping.add(fm);
             }
         }
     }

+ 18 - 26
dbsyncer-parser/src/main/java/org/dbsyncer/parser/util/PickerUtil.java

@@ -16,7 +16,7 @@ public abstract class PickerUtil {
     }
 
     public static void pickFields(Picker picker, List<FieldMapping> fieldMapping) {
-        if(!CollectionUtils.isEmpty(fieldMapping)){
+        if (!CollectionUtils.isEmpty(fieldMapping)) {
             List<Field> sFields = new ArrayList<>();
             List<Field> tFields = new ArrayList<>();
             fieldMapping.forEach(m -> {
@@ -29,29 +29,19 @@ public abstract class PickerUtil {
     }
 
     public static void pickData(Picker picker, List<Map<String, Object>> data) {
-        if(!CollectionUtils.isEmpty(data)){
+        if (!CollectionUtils.isEmpty(data)) {
             List<Map<String, Object>> target = new ArrayList<>();
             List<Field> sFields = picker.getSourceFields();
             List<Field> tFields = picker.getTargetFields();
 
-            final int kSize = sFields.size();
             final int size = data.size();
+            final int sFieldSize = sFields.size();
             Map<String, Object> row = null;
             Map<String, Object> r = null;
-            String sName = null;
-            String tName = null;
-            Object v = null;
             for (int i = 0; i < size; i++) {
                 row = data.get(i);
                 r = new HashMap<>();
-
-                for (int k = 0; k < kSize; k++) {
-                    sName = sFields.get(k).getName();
-                    v = row.get(sName);
-
-                    tName = tFields.get(k).getName();
-                    r.put(tName, v);
-                }
+                exchange(sFieldSize, sFields, tFields, row, r);
                 target.add(r);
             }
 
@@ -60,24 +50,26 @@ public abstract class PickerUtil {
     }
 
     public static void pickData(Picker picker, Map<String, Object> row) {
-        if(!CollectionUtils.isEmpty(row)){
+        if (!CollectionUtils.isEmpty(row)) {
             Map<String, Object> target = new HashMap<>();
             List<Field> sFields = picker.getSourceFields();
             List<Field> tFields = picker.getTargetFields();
 
-            final int kSize = sFields.size();
-            String sName = null;
-            String tName = null;
-            Object v = null;
-            for (int k = 0; k < kSize; k++) {
-                sName = sFields.get(k).getName();
-                v = row.get(sName);
+            exchange(sFields.size(), sFields, tFields, row, target);
+            picker.setTarget(target);
+        }
+    }
+
+    private static void exchange(int sFieldSize, List<Field> sFields, List<Field> tFields, Map<String, Object> source, Map<String, Object> target) {
+        Field sField = null;
+        Object v = null;
+        for (int k = 0; k < sFieldSize; k++) {
+            sField = sFields.get(k);
+            if (null != sField) {
+                v = source.get(sField.getName());
 
-                tName = tFields.get(k).getName();
-                target.put(tName, v);
+                target.put(tFields.get(k).getName(), v);
             }
-
-            picker.setTarget(target);
         }
     }
 

+ 0 - 4
dbsyncer-plugin/src/main/java/org/dbsyncer/plugin/PluginFactory.java

@@ -17,10 +17,6 @@ public class PluginFactory {
 
     public List<Plugin> getPluginAll() {
         List<Plugin> list = new ArrayList<>();
-        Plugin plugin = new Plugin();
-        plugin.setName("正式知识库插件");
-        plugin.setClassName("com.knowledge.xx.impl");
-        list.add(plugin);
         return list;
     }
 

+ 23 - 23
dbsyncer-web/src/main/java/org/dbsyncer/web/config/WebAppConfig.java

@@ -65,31 +65,31 @@ public class WebAppConfig extends WebSecurityConfigurerAdapter implements Authen
 
     @Override
     protected void configure(HttpSecurity http) throws Exception {
+//        http.csrf().disable()
+//                .authorizeRequests()
+//                .anyRequest().permitAll()
+//                .and().logout().permitAll();
+
         http.csrf().disable()
                 .authorizeRequests()
-                .anyRequest().permitAll()
-                .and().logout().permitAll();
-
-        //http.csrf().disable()
-        //        .authorizeRequests()
-        //        .antMatchers("/css/**", "/js/**", "/img/**", "/config/**", "/plugins/**").permitAll().anyRequest()
-        //        .authenticated()
-        //        .and()
-        //        .formLogin()
-        //        .loginProcessingUrl(LOGIN)
-        //        .loginPage(LOGIN_PAGE)
-        //        .successHandler(loginSuccessHandler())
-        //        .failureHandler(loginFailHandler())
-        //        .permitAll()
-        //        .and()
-        //        .logout()
-        //        .permitAll()
-        //        .invalidateHttpSession(true).deleteCookies("JSESSIONID").logoutSuccessHandler(logoutHandler())
-        //        .and()
-        //        .sessionManagement()
-        //        .sessionFixation()
-        //        .migrateSession()
-        //        .maximumSessions(MAXIMUM_SESSIONS);
+                .antMatchers("/css/**", "/js/**", "/img/**", "/config/**", "/plugins/**").permitAll().anyRequest()
+                .authenticated()
+                .and()
+                .formLogin()
+                .loginProcessingUrl(LOGIN)
+                .loginPage(LOGIN_PAGE)
+                .successHandler(loginSuccessHandler())
+                .failureHandler(loginFailHandler())
+                .permitAll()
+                .and()
+                .logout()
+                .permitAll()
+                .invalidateHttpSession(true).deleteCookies("JSESSIONID").logoutSuccessHandler(logoutHandler())
+                .and()
+                .sessionManagement()
+                .sessionFixation()
+                .migrateSession()
+                .maximumSessions(MAXIMUM_SESSIONS);
     }
 
     /**

+ 0 - 6
dbsyncer-web/src/main/java/org/dbsyncer/web/controller/TestController.java

@@ -27,11 +27,6 @@ public class TestController {
     @Autowired
     private MappingService mappingService;
 
-    @GetMapping("")
-    public String index(HttpServletRequest request, ModelMap model) {
-        return "test.html";
-    }
-
     @RequestMapping("/demo")
     @ResponseBody
     public Object demo(Model model) {
@@ -53,7 +48,6 @@ public class TestController {
             }).start();
         }
 
-
         return "hello";
     }
 

+ 0 - 81
dbsyncer-web/src/main/resources/public/test.html

@@ -1,81 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
-<head>
-    <meta charset="utf-8">
-    <meta http-equiv="pragma" content="no-cache">
-    <meta http-equiv="cache-control" content="no-cache">
-    <meta http-equiv="expires" content="0">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
-    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
-    <meta name="description" content="search">
-    <meta name="author" content="AE86">
-    <title>dbsyncer</title>
-    <link type="image/x-icon" rel="icon" th:href="@{img}"/>
-    <link type="text/css" rel="stylesheet" th:href="@{/plugins/css/bootstrap/bootstrap.min.css}"/>
-    <link type="text/css" rel="stylesheet" th:href="@{/plugins/css/bootstrap-dialog/bootstrap-dialog.min.css}"/>
-    <link type="text/css" rel="stylesheet" th:href="@{/plugins/css/icheck/all.css}"/>
-    <link type="text/css" rel="stylesheet" th:href="@{/plugins/css/font-awesome.min.css}"/>
-    <link type="text/css" rel="stylesheet" th:href="@{/css/common.css}">
-</head>
-<body>
-
-<div class="form-group">
-    <table class="table table-hover">
-        <thead>
-        <tr>
-            <th>数据源字段</th>
-            <th>目标源字段</th>
-            <th>操作</th>
-        </tr>
-        </thead>
-        <tbody id="fieldList">
-        <tr title='转换配置' class='dbsyncer_pointer'>
-            <td>ID</td>
-            <td>ID</td>
-            <td><a class='fa fa-remove fa-2x fieldDelete dbsyncer_pointer' title='删除' ></a></td>
-        </tr>
-        <tr title='转换配置' class='dbsyncer_pointer'>
-            <td>NAME</td>
-            <td>NAME</td>
-            <td><a class='fa fa-remove fa-2x fieldDelete dbsyncer_pointer' title='删除' ></a></td>
-        </tr>
-        </tbody>
-    </table>
-</div>
-
-</body>
-<script th:src="@{/plugins/js/bootstrap/respond.min.js}" ></script>
-<script th:src="@{/plugins/js/bootstrap/html5shiv.min.js}"></script>
-<!-- 上述2个js文件解决IE8以上bootstrap的兼容性问题 -->
-<script th:src="@{/plugins/js/jquery/jquery-1.11.3.min.js}"></script>
-<script th:src="@{/plugins/js/bootstrap/bootstrap.min.js}"></script>
-<script th:src="@{/plugins/js/bootstrap-dialog/bootstrap-dialog.min.js}"></script>
-<script th:src="@{/plugins/js/bootstrap-growl/jquery.bootstrap-growl.min.js}"></script>
-
-<script type="text/javascript">
-    // 全局提示框
-    function bootGrowl(data, type) {
-        $.bootstrapGrowl(data, { // data为提示信息
-            type : type == undefined ? 'success' : type,// type指提示类型
-            delay : 1000,// 提示框显示时间
-            allow_dismiss : true // 显示取消提示框
-        });
-    }
-
-    $(function () {
-        $("#fieldList tr").on("click", function(){
-            bootGrowl("编辑!", "danger");
-        });
-
-        var $del = $(".fieldDelete");
-        $del.bind('click', function(){
-            // 阻止tr触发click事件
-            event.cancelBubble=true;
-            bootGrowl("delete!", "success");
-        });
-    })
-
-</script>
-</html>