tanghc 3 years ago
parent
commit
d52f42c77f
34 changed files with 333 additions and 109 deletions
  1. 18 9
      build.sh
  2. 11 6
      changelog.md
  3. 7 2
      front/package.json
  4. 1 1
      front/src/components/Breadcrumb/index.vue
  5. 5 5
      front/src/router/index.js
  6. 1 0
      front/src/styles/index.scss
  7. 12 0
      front/src/utils/global.js
  8. 0 7
      front/src/views/dashboard/index.vue
  9. 47 13
      front/src/views/generate/result.vue
  10. 16 2
      gen/pom.xml
  11. 2 0
      gen/src/main/java/com/gitee/gen/GenApplication.java
  12. 27 0
      gen/src/main/java/com/gitee/gen/config/RequestListener.java
  13. 0 2
      gen/src/main/java/com/gitee/gen/gen/ColumnSelector.java
  14. 85 0
      gen/src/main/java/com/gitee/gen/gen/DataSourceManager.java
  15. 1 1
      gen/src/main/java/com/gitee/gen/gen/GeneratorConfig.java
  16. 46 22
      gen/src/main/java/com/gitee/gen/util/SqlHelper.java
  17. 15 17
      gen/src/main/java/com/gitee/gen/gen/TableSelector.java
  18. 1 1
      gen/src/main/resources/public/index.html
  19. 1 1
      gen/src/main/resources/public/static/css/app.383d4ba1.css
  20. 1 0
      gen/src/main/resources/public/static/css/chunk-0a388286.2864c242.css
  21. 0 1
      gen/src/main/resources/public/static/css/chunk-0d59783a.e3d1a31a.css
  22. 0 0
      gen/src/main/resources/public/static/css/chunk-53ca05b2.dfbde295.css
  23. 0 1
      gen/src/main/resources/public/static/js/app.0adbc62f.js
  24. 1 0
      gen/src/main/resources/public/static/js/app.f72ba3b3.js
  25. 1 0
      gen/src/main/resources/public/static/js/chunk-0a388286.be225d9f.js
  26. 0 1
      gen/src/main/resources/public/static/js/chunk-0d59783a.47e3b34b.js
  27. 0 1
      gen/src/main/resources/public/static/js/chunk-2d0efd67.32ec87ab.js
  28. 1 0
      gen/src/main/resources/public/static/js/chunk-2d0efd67.e30e7295.js
  29. 8 0
      gen/src/main/resources/public/static/js/chunk-53ca05b2.2b9ec4ce.js
  30. 0 1
      gen/src/main/resources/public/static/js/chunk-734ead8e.0204998e.js
  31. 5 2
      pom.xml
  32. 13 6
      readme.md
  33. 3 3
      script/shutdown.sh
  34. 4 4
      script/startup.sh

+ 18 - 9
build.sh

@@ -1,9 +1,17 @@
 #!/bin/sh
 
+# 版本号
+version="gen-1.1.0"
+# 构建目录
+dist_dir="dist"
+# 输出目录
+target_dir="$dist_dir/$version"
+
 echo "开始构建..."
 
 cd front
 
+rm -rf dist/*
 npm run build:prod
 echo "复制dist文件内容到gen/src/main/resources/public"
 rm -rf ../gen/src/main/resources/public/*
@@ -11,20 +19,21 @@ cp -r dist/* ../gen/src/main/resources/public
 
 cd ..
 
+
 mvn clean package
 
-echo "复制文件到bin目录"
+echo "复制文件到$target_dir"
 
-dist_mkdir="bin"
+rm -rf $dist_dir
+mkdir -p $target_dir
 
-if [ ! -d "$dist_mkdir" ]; then
-  mkdir $dist_mkdir
-fi
+cp -r gen/target/*.jar $target_dir/gen.jar
+cp -r script/* $target_dir
+cp -r db/gen.db $target_dir/gen.db
 
-rm -rf build/*
+echo "打成zip包"
 
-cp -r gen/target/*.jar $dist_mkdir
-cp -r script/* $dist_mkdir
-cp -r db/gen.db $dist_mkdir/gen.db
+cd $dist_dir
+zip -r -q "$version.zip" $version
 
 echo "构建完毕"

+ 11 - 6
changelog.md

@@ -1,15 +1,20 @@
 # changelog
 
-## 1.0.0
+## 1.1.0
 
-- 重构前端页面,采用elementUI
-- 优化了生成步骤
-- 优化了模板编辑页面
+- 结果页面可下载代码
+- 优化Connection连接数
+
+## 1.0.2
+
+- 优化交互
 
 ## 1.0.1
 
 - 新增复制代码功能
 
-## 1.0.2
+## 1.0.0
 
-- 优化交互
+- 重构前端页面,采用elementUI
+- 优化了生成步骤
+- 优化了模板编辑页面

+ 7 - 2
front/package.json

@@ -16,18 +16,23 @@
   },
   "dependencies": {
     "axios": "0.18.0",
+    "clipboard": "^2.0.6",
     "element-ui": "2.9.1",
+    "file-saver": "^2.0.2",
+    "install": "^0.13.0",
     "js-cookie": "2.2.0",
     "js-md5": "^0.7.3",
+    "jszip": "^3.5.0",
     "mavon-editor": "2.7.7",
     "normalize.css": "7.0.0",
+    "npm": "^6.14.7",
     "nprogress": "0.2.0",
+    "or": "^0.2.0",
     "path-to-regexp": "2.4.0",
     "vue": "2.6.10",
     "vue-codemirror": "^4.0.6",
     "vue-router": "3.0.6",
-    "vuex": "3.1.0",
-    "clipboard": "^2.0.6"
+    "vuex": "3.1.0"
   },
   "devDependencies": {
     "@babel/core": "7.0.0",

+ 1 - 1
front/src/components/Breadcrumb/index.vue

@@ -33,7 +33,7 @@ export default {
       const first = matched[0]
 
       if (!this.isDashboard(first)) {
-        matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched)
+        matched = [{ path: '/dashboard', meta: { title: '首页' }}].concat(matched)
       }
 
       this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)

+ 5 - 5
front/src/router/index.js

@@ -52,14 +52,14 @@ export const constantRoutes = [
   {
     path: '/generate',
     component: Layout,
-    name: 'Generate',
     meta: { title: '生成代码', icon: 'form' },
+    redirect: '/generate/config',
     children: [
       {
-        path: 'code',
-        name: 'Code',
+        path: 'config',
+        name: 'Config',
         component: () => import('@/views/generate/index'),
-        meta: { title: '生成代码' }
+        meta: { title: '生成代码' },
       },
       {
         path: 'result/:config',
@@ -73,8 +73,8 @@ export const constantRoutes = [
   {
     path: '/template',
     component: Layout,
-    name: 'Generate',
     meta: { title: '模板管理', icon: 'table' },
+    redirect: '/template/list',
     children: [
       {
         path: 'list',

+ 1 - 0
front/src/styles/index.scss

@@ -78,3 +78,4 @@ div:focus {
 
 .el-aside {  border-right: 1px solid #eee;padding-right: 10px;}
 .el-main {padding-top: 0;}
+.el-backtop { z-index: 99999 }

+ 12 - 0
front/src/utils/global.js

@@ -112,4 +112,16 @@ Object.assign(Vue.prototype, {
       this.clipboard.destroy()
     }
   },
+  downloadText(filename, text) {
+    const element = document.createElement('a')
+    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
+    element.setAttribute('download', filename)
+
+    element.style.display = 'none'
+    document.body.appendChild(element)
+
+    element.click()
+
+    document.body.removeChild(element);
+  }
 })

+ 0 - 7
front/src/views/dashboard/index.vue

@@ -4,13 +4,6 @@
   </div>
 </template>
 
-<script>
-export default {
-  created() {
-  }
-}
-</script>
-
 <style lang="scss" scoped>
 .dashboard {
   &-container {

+ 47 - 13
front/src/views/generate/result.vue

@@ -3,9 +3,13 @@
     <el-backtop />
     <div v-if="loading">生成中...</div>
     <div v-else>
-      <el-button type="text" icon="el-icon-back" @click="goRoute('/generate/code')">返回</el-button>
       <el-container>
         <el-aside>
+          <el-button
+            icon="el-icon-download"
+            type="text"
+            @click="downloadAll"
+          >下载全部</el-button>
           <el-input
             v-show="treeData.length > 0"
             v-model="filterText"
@@ -26,14 +30,19 @@
             @current-change="onTreeSelect"
           />
         </el-aside>
-        <el-main>
+        <el-main v-show="fileInfo.content.length > 0">
           <el-button
-            v-show="content.length > 0"
             type="text"
-            :data-clipboard-text="content"
+            icon="el-icon-document-copy"
+            :data-clipboard-text="fileInfo.content"
             class="copyBtn">复制代码</el-button>
+          <el-button
+            icon="el-icon-download"
+            type="text"
+            @click="downloadText(fileInfo.filename, fileInfo.content)"
+          >下载当前文件</el-button>
           <codemirror
-            v-model="content"
+            v-model="fileInfo.content"
             :options="cmOptions"
           />
         </el-main>
@@ -43,6 +52,8 @@
 </template>
 
 <script>
+import JSZip from 'jszip'
+import { saveAs } from 'file-saver'
 import { codemirror } from 'vue-codemirror'
 import 'codemirror/theme/neat.css'
 require('codemirror/mode/javascript/javascript')
@@ -73,9 +84,13 @@ export default {
       filterText: '',
       defaultProps: {
         children: 'children',
-        label: 'text'
+        label: 'filename'
       },
       content: '',
+      fileInfo: {
+        content: '',
+        filename: ''
+      },
       cmOptions: {
         value: '',
         mode: 'text/x-java',
@@ -140,7 +155,7 @@ export default {
       for (const tableName in codeMap) {
         const codeFileArr = codeMap[tableName]
         const treeElement = {
-          text: tableName,
+          filename: tableName,
           children: this.buildChildren(codeFileArr)
         }
 
@@ -153,10 +168,8 @@ export default {
       for (let i = 0, len = codeFileArr.length; i < len; i++) {
         const codeFile = codeFileArr[i]
         const child = {
-          text: codeFile.templateName,
-          attributes: {
-            content: codeFile.content
-          }
+          filename: codeFile.templateName,
+          content: codeFile.content
         }
         children.push(child)
       }
@@ -166,8 +179,8 @@ export default {
       if (data.children && data.children.length > 0) {
         return
       }
-      this.content = data.attributes.content
-      this.changeMod(data.text)
+      this.fileInfo = data
+      this.changeMod(data.filename)
     },
     changeMod(fileName) {
       const suffix = this.getSuffix(fileName)
@@ -179,6 +192,27 @@ export default {
         return 'js'
       }
       return fileName.substring(index + 1, fileName.length)
+    },
+    downloadAll() {
+      const data = this.treeData
+      const zip = new JSZip()
+      data.forEach(row => {
+        const children = row.children
+        const isFolder = children.length > 0
+        if (isFolder) {
+          // 创建文件夹
+          const folderZip = zip.folder(row.filename)
+          children.forEach(child => {
+            // 文件放入文件夹中
+            folderZip.file(child.filename, child.content)
+          })
+        }
+      })
+      // 下载
+      zip.generateAsync({ type: 'blob' }).then(function(content) {
+        // see FileSaver.js
+        saveAs(content, `code-${new Date().getTime()}.zip`);
+      })
     }
   }
 }

+ 16 - 2
gen/pom.xml

@@ -5,12 +5,12 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.1.RELEASE</version>
+        <version>2.3.2.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.gitee.codegen</groupId>
     <artifactId>gen</artifactId>
-    <version>1.0.2-SNAPSHOT</version>
+    <version>1.1.0</version>
     <description>一款代码生成器</description>
 
     <properties>
@@ -28,6 +28,20 @@
             <version>2.1.3</version>
         </dependency>
 
+        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-dbcp2</artifactId>
+            <version>2.7.0</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.velocity</groupId>
             <artifactId>velocity</artifactId>

+ 2 - 0
gen/src/main/java/com/gitee/gen/GenApplication.java

@@ -2,7 +2,9 @@ package com.gitee.gen;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletComponentScan;
 
+@ServletComponentScan
 @SpringBootApplication
 public class GenApplication {
 

+ 27 - 0
gen/src/main/java/com/gitee/gen/config/RequestListener.java

@@ -0,0 +1,27 @@
+package com.gitee.gen.config;
+
+import com.gitee.gen.gen.DataSourceManager;
+
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.annotation.WebListener;
+
+/**
+ * 监听器
+ *
+ * @author thc
+ */
+@WebListener
+public class RequestListener implements ServletRequestListener {
+
+	@Override
+	public void requestDestroyed(ServletRequestEvent sre) {
+		DataSourceManager.closeConnection();
+	}
+
+	@Override
+	public void requestInitialized(ServletRequestEvent sre) {
+	}
+
+}
+

+ 0 - 2
gen/src/main/java/com/gitee/gen/gen/ColumnSelector.java

@@ -1,7 +1,5 @@
 package com.gitee.gen.gen;
 
-import com.gitee.gen.util.SqlHelper;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;

+ 85 - 0
gen/src/main/java/com/gitee/gen/gen/DataSourceManager.java

@@ -0,0 +1,85 @@
+package com.gitee.gen.gen;
+
+import org.apache.commons.dbcp2.BasicDataSourceFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author tanghc
+ */
+public class DataSourceManager {
+
+    private static final Logger logger = LoggerFactory.getLogger(DataSourceManager.class);
+
+
+    private static final Map<String, DataSource> DATA_SOURCE_MAP = new ConcurrentHashMap<>(16);
+    private static final ThreadLocal<Connection> CONNECTION_LOCAL = new ThreadLocal<>();
+
+    public static Connection getConnection(GeneratorConfig generatorConfig) {
+        Connection connection = CONNECTION_LOCAL.get();
+        if (connection == null) {
+            try {
+                connection = getDataSource(generatorConfig).getConnection();
+                CONNECTION_LOCAL.set(connection);
+            } catch (SQLException e) {
+                logger.error("获取Connection失败, jdbcUrl:{}", generatorConfig.getJdbcUrl(), e);
+                throw new RuntimeException("获取Connection失败", e);
+            }
+        }
+        return connection;
+    }
+
+    public static void closeConnection() {
+        Connection connection = CONNECTION_LOCAL.get();
+        if (connection != null) {
+            try {
+                connection.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        CONNECTION_LOCAL.remove();
+    }
+
+    public static DataSource getDataSource(GeneratorConfig generatorConfig) {
+        String jdbcUrl = generatorConfig.getJdbcUrl();
+        DataSource dataSource = DATA_SOURCE_MAP.computeIfAbsent(jdbcUrl, key -> {
+            Properties properties = new Properties();
+            properties.put("driverClassName", generatorConfig.getDriverClass());
+            properties.put("url", generatorConfig.getJdbcUrl());
+            properties.put("username", generatorConfig.getUsername());
+            properties.put("password", generatorConfig.getPassword());
+            // 初始连接数
+            properties.put("initialSize", 1);
+            // 最大活跃数
+            properties.put("maxTotal", 30);
+            properties.put("minIdle", 5);
+            properties.put("maxIdle", 10);
+            // 最长等待时间(毫秒)
+            properties.put("maxWaitMillis", 1000);
+            // 程序中的连接不使用后是否被连接池回收
+            properties.put("removeAbandonedOnMaintenance", true);
+            properties.put("removeAbandonedOnBorrow", true);
+            // 连接在所指定的秒数内未使用才会被删除(秒)
+            properties.put("removeAbandonedTimeout", 5);
+            try {
+                return BasicDataSourceFactory.createDataSource(properties);
+            } catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        });
+        if (dataSource == null) {
+            throw new RuntimeException("连接数据库失败");
+        }
+        return dataSource;
+    }
+
+}

+ 1 - 1
gen/src/main/java/com/gitee/gen/gen/GeneratorConfig.java

@@ -11,7 +11,7 @@ public class GeneratorConfig {
     private static final Map<String, String> JDBC_URL_MAP = new HashMap<String, String>();
 
     static {
-        JDBC_URL_MAP.put("com.mysql.jdbc.Driver", "jdbc:mysql://%s:%s/%s?useUnicode=true&characterEncoding=UTF-8");
+        JDBC_URL_MAP.put("com.mysql.jdbc.Driver", "jdbc:mysql://%s:%s/%s?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true");
         JDBC_URL_MAP.put("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@%s:%s:%s");
         JDBC_URL_MAP.put("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://%s:%s;databaseName=%s");
     }

+ 46 - 22
gen/src/main/java/com/gitee/gen/util/SqlHelper.java

@@ -1,6 +1,5 @@
-package com.gitee.gen.util;
+package com.gitee.gen.gen;
 
-import com.gitee.gen.gen.GeneratorConfig;
 import org.apache.ibatis.datasource.pooled.PooledDataSourceFactory;
 import org.apache.ibatis.jdbc.SqlRunner;
 import org.apache.ibatis.mapping.BoundSql;
@@ -19,6 +18,7 @@ import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * 执行SQL语句的帮助类
@@ -33,6 +33,9 @@ public class SqlHelper {
     private static final String USERNAME = "username";
     private static final String PASSWORD = "password";
 
+    private static final Map<String, DataSource> dataSourceMap = new ConcurrentHashMap<>(16);
+    private static final ThreadLocal<Connection> connectionLocal = new ThreadLocal<>();
+
     /**
      * <pre>
      * String sql = "SELECT * FROM datasource_config WHERE dc_id=${id}";
@@ -57,14 +60,12 @@ public class SqlHelper {
     public static List<Map<String, Object>> runSql(GeneratorConfig generatorConfig, String sql,
                                                    Map<String, Object> params) {
 
-        DataSource dataSource = buildDataSource(generatorConfig);
-
+        DataSource dataSource = DataSourceManager.getDataSource(generatorConfig);
         String runSql = buildSqlWithParams(dataSource, sql, params);
         String[] sqls = runSql.split(";");
-        logger.info("执行SQL:" + runSql);
         Connection conn = null;
         try {
-            conn = dataSource.getConnection();
+            conn = DataSourceManager.getConnection(generatorConfig);
             SqlRunner runner = buildSqlRunner(conn);
             int sqlCount = sqls.length;
             if (sqlCount == 1) {
@@ -78,15 +79,34 @@ public class SqlHelper {
         } catch (SQLException e1) {
             logger.error("生成代码错误", e1);
             throw new RuntimeException("生成代码错误");
-        } finally {
-            if (conn != null) {
-                try {
-                    conn.close();
-                } catch (SQLException e) {
-                    logger.error("close connection error", e);
-                }
+        }
+    }
+
+
+    public static Connection getConnection(GeneratorConfig generatorConfig) {
+        Connection connection = connectionLocal.get();
+        if (connection == null) {
+            try {
+                connection = getDataSource(generatorConfig).getConnection();
+                connectionLocal.set(connection);
+            } catch (SQLException e) {
+                logger.error("获取Connection失败, jdbcUrl:{}", generatorConfig.getJdbcUrl(), e);
+                throw new RuntimeException("获取Connection失败", e);
+            }
+        }
+        return connection;
+    }
+
+    public static void closeConnection() {
+        Connection connection = connectionLocal.get();
+        if (connection != null) {
+            try {
+                connection.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
             }
         }
+        connectionLocal.remove();
     }
 
     // 参数绑定
@@ -106,15 +126,19 @@ public class SqlHelper {
         return new SqlRunner(connection);
     }
 
-    private static DataSource buildDataSource(GeneratorConfig dataBaseConfig) {
-        Properties properties = new Properties();
-        properties.setProperty(DRIVER, dataBaseConfig.getDriverClass());
-        properties.setProperty(URL, dataBaseConfig.getJdbcUrl());
-        properties.setProperty(USERNAME, dataBaseConfig.getUsername());
-        properties.setProperty(PASSWORD, dataBaseConfig.getPassword());
-        PooledDataSourceFactory pooledDataSourceFactory = new PooledDataSourceFactory();
-        pooledDataSourceFactory.setProperties(properties);
-        return pooledDataSourceFactory.getDataSource();
+
+    private static DataSource getDataSource(GeneratorConfig generatorConfig) {
+        String jdbcUrl = generatorConfig.getJdbcUrl();
+        return dataSourceMap.computeIfAbsent(jdbcUrl, key -> {
+            Properties properties = new Properties();
+            properties.setProperty(DRIVER, generatorConfig.getDriverClass());
+            properties.setProperty(URL, jdbcUrl);
+            properties.setProperty(USERNAME, generatorConfig.getUsername());
+            properties.setProperty(PASSWORD, generatorConfig.getPassword());
+            PooledDataSourceFactory pooledDataSourceFactory = new PooledDataSourceFactory();
+            pooledDataSourceFactory.setProperties(properties);
+            return pooledDataSourceFactory.getDataSource();
+        });
     }
 
     private static Configuration buildConfiguration(DataSource dataSource) {

+ 15 - 17
gen/src/main/java/com/gitee/gen/gen/TableSelector.java

@@ -1,7 +1,5 @@
 package com.gitee.gen.gen;
 
-import com.gitee.gen.util.SqlHelper;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -9,11 +7,11 @@ import java.util.Map;
 public abstract class TableSelector {
 
     private ColumnSelector columnSelector;
-    private GeneratorConfig dataBaseConfig;
+    private GeneratorConfig generatorConfig;
     private List<String> schTableNames;
 
-    public TableSelector(ColumnSelector columnSelector, GeneratorConfig dataBaseConfig) {
-        this.dataBaseConfig = dataBaseConfig;
+    public TableSelector(ColumnSelector columnSelector, GeneratorConfig generatorConfig) {
+        this.generatorConfig = generatorConfig;
         this.columnSelector = columnSelector;
     }
 
@@ -29,12 +27,12 @@ public abstract class TableSelector {
     protected abstract TableDefinition buildTableDefinition(Map<String, Object> tableMap);
 
     public List<TableDefinition> getTableDefinitions() {
-        String showParam = dataBaseConfig.getDbName();
+        String showParam = generatorConfig.getDbName();
         // 如果是oracle数据库则传oracle数据库用户大写
-        if (dataBaseConfig.getDriverClass().contains("oracle")) {
-            showParam = dataBaseConfig.getUsername().toUpperCase();
+        if (generatorConfig.getDriverClass().contains("oracle")) {
+            showParam = generatorConfig.getUsername().toUpperCase();
         }
-        List<Map<String, Object>> resultList = SqlHelper.runSql(getDataBaseConfig(), getShowTablesSQL(showParam));
+        List<Map<String, Object>> resultList = SqlHelper.runSql(getGeneratorConfig(), getShowTablesSQL(showParam));
         List<TableDefinition> tablesList = new ArrayList<TableDefinition>(resultList.size());
 
         for (Map<String, Object> rowMap : resultList) {
@@ -48,12 +46,12 @@ public abstract class TableSelector {
     }
 
     public List<TableDefinition> getSimpleTableDefinitions() {
-        String showParam = dataBaseConfig.getDbName();
+        String showParam = generatorConfig.getDbName();
         // 如果是oracle数据库则传oracle数据库用户大写
-        if (dataBaseConfig.getDriverClass().contains("oracle")) {
-            showParam = dataBaseConfig.getUsername().toUpperCase();
+        if (generatorConfig.getDriverClass().contains("oracle")) {
+            showParam = generatorConfig.getUsername().toUpperCase();
         }
-        List<Map<String, Object>> resultList = SqlHelper.runSql(getDataBaseConfig(), getShowTablesSQL(showParam));
+        List<Map<String, Object>> resultList = SqlHelper.runSql(getGeneratorConfig(), getShowTablesSQL(showParam));
         List<TableDefinition> tablesList = new ArrayList<TableDefinition>(resultList.size());
 
         for (Map<String, Object> rowMap : resultList) {
@@ -63,12 +61,12 @@ public abstract class TableSelector {
         return tablesList;
     }
 
-    public GeneratorConfig getDataBaseConfig() {
-        return dataBaseConfig;
+    public GeneratorConfig getGeneratorConfig() {
+        return generatorConfig;
     }
 
-    public void setDataBaseConfig(GeneratorConfig dataBaseConfig) {
-        this.dataBaseConfig = dataBaseConfig;
+    public void setGeneratorConfig(GeneratorConfig generatorConfig) {
+        this.generatorConfig = generatorConfig;
     }
 
     public ColumnSelector getColumnSelector() {

File diff suppressed because it is too large
+ 1 - 1
gen/src/main/resources/public/index.html


File diff suppressed because it is too large
+ 1 - 1
gen/src/main/resources/public/static/css/app.383d4ba1.css


+ 1 - 0
gen/src/main/resources/public/static/css/chunk-0a388286.2864c242.css

@@ -0,0 +1 @@
+.dashboard-container[data-v-22edc0ee]{margin:30px}.dashboard-text[data-v-22edc0ee]{font-size:18px;line-height:46px}

+ 0 - 1
gen/src/main/resources/public/static/css/chunk-0d59783a.e3d1a31a.css

@@ -1 +0,0 @@
-.dashboard-container[data-v-135837b3]{margin:30px}.dashboard-text[data-v-135837b3]{font-size:18px;line-height:46px}

gen/src/main/resources/public/static/css/chunk-734ead8e.dfbde295.css → gen/src/main/resources/public/static/css/chunk-53ca05b2.dfbde295.css


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/app.0adbc62f.js


File diff suppressed because it is too large
+ 1 - 0
gen/src/main/resources/public/static/js/app.f72ba3b3.js


File diff suppressed because it is too large
+ 1 - 0
gen/src/main/resources/public/static/js/chunk-0a388286.be225d9f.js


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/chunk-0d59783a.47e3b34b.js


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/chunk-2d0efd67.32ec87ab.js


File diff suppressed because it is too large
+ 1 - 0
gen/src/main/resources/public/static/js/chunk-2d0efd67.e30e7295.js


File diff suppressed because it is too large
+ 8 - 0
gen/src/main/resources/public/static/js/chunk-53ca05b2.2b9ec4ce.js


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/chunk-734ead8e.0204998e.js


+ 5 - 2
pom.xml

@@ -3,12 +3,15 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
-
     <groupId>com.giee.codegen</groupId>
     <artifactId>code-gen</artifactId>
-    <version>1.0.2-SNAPSHOT</version>
+    <version>1.1.0</version>
     <packaging>pom</packaging>
 
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
     <modules>
         <module>gen</module>
     </modules>

+ 13 - 6
readme.md

@@ -9,10 +9,10 @@
 ## 使用步骤
 
 - 前往[发行版页面](https://gitee.com/durcframework/code-gen/releases),下载最新版本zip文件
-- 解压zip,如果是Mac/Linux操作系统,可执行运行`startup.sh`,或者在命令行输入`java -jar gen-xx-SNAPSHOT.jar`(xx表示版本号)
+- 解压zip,如果是Mac/Linux操作系统,可执行运行`startup.sh`,或者在命令行输入`java -jar gen.jar`
 - 浏览器访问`http://localhost:6969/`
 
-默认端口是6969,更改端口号可执行:`java -jar gen-xx-SNAPSHOT.jar --server.port=端口号`
+默认端口是6969,更改端口号可执行:`java -jar gen.jar --server.port=端口号`
 
 ## 工程说明
 
@@ -25,13 +25,20 @@
 
 > 需要安装Maven3,Java8
 
-- 自动构建:
+- 自动构建[推荐]
 
-Mac/Linux系统可直接执行`build.sh`进行构建,构建结果在build文件夹下。
+Mac/Linux系统可直接执行`build.sh`进行构建,构建结果在`dist`文件夹下。
 
 - 手动构建:
-
-    -  在工程根目录执行`mvn clean package`,在code-gen/gen/target下会生成一个`gen-xx-SNAPSHOT.jar`(xx表示本号)
+    
+    `cd front`
+    
+    - 执行`npm run build:prod`进行打包,结果在dist下
+    - 把dist中的所有文件,放到`gen/src/main/resources/public`下
+    
+    `cd ..`
+    
+    - 执行`mvn clean package`,在`gen/target`下会生成一个`gen-xx-SNAPSHOT.jar`(xx表示本号)
     - 将`gen-xx-SNAPSHOT.jar`和db下的`gen.db`放在同一个文件夹下
     - 执行`java -jar gen-xx-SNAPSHOT.jar`
     - 浏览器访问`http://localhost:6969/`

+ 3 - 3
script/shutdown.sh

@@ -1,8 +1,8 @@
-echo "Stopping gen-1.0.2-SNAPSHOT.jar"
-pid=`ps -ef | grep gen-1.0.2-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
+echo "Stopping gen.jar"
+pid=`ps -ef | grep gen.jar | grep -v grep | awk '{print $2}'`
 if [ -n "$pid" ]
 then
-   echo "kill -9 的id:" $pid
+   echo "stop pid:" $pid
    kill -9 $pid
 fi
 

+ 4 - 4
script/startup.sh

@@ -1,9 +1,9 @@
-echo "Stopping gen-1.0.2-SNAPSHOT.jar"
-pid=`ps -ef | grep gen-1.0.2-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
+echo "Stopping gen.jar"
+pid=`ps -ef | grep gen.jar | grep -v grep | awk '{print $2}'`
 if [ -n "$pid" ]
 then
-   echo "kill -9 的id:" $pid
+   echo "stop pid:" $pid
    kill -9 $pid
 fi
-nohup java -jar -Xms128m -Xmx128m gen-1.0.2-SNAPSHOT.jar &
+nohup java -jar -Xms128m -Xmx128m gen.jar &