1、API升级

Former-commit-id: 080f1e7b87c8d3dfcf1ff28914fde3d027265c38
master
wangbing 6 years ago
parent 2c7407312b
commit aca5fd93f5

@ -5,7 +5,11 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import xyz.wbsite.dbtool.web.frame.utils.ResourceUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -17,7 +21,7 @@ public class Application extends SpringBootServletInitializer {
return application.sources(Application.class); return application.sources(Application.class);
} }
public static void main(String[] args) { public static void main(String[] args) throws FileNotFoundException {
ExecutorService executorService = Executors.newFixedThreadPool(2); ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.execute(new Runnable() { executorService.execute(new Runnable() {
@Override @Override

@ -27,7 +27,7 @@ public class OptionMainController {
public String getDataBase() { public String getDataBase() {
RadioButton value = (RadioButton) db.selectedToggleProperty().getValue(); RadioButton value = (RadioButton) db.selectedToggleProperty().getValue();
String name = value.textProperty().getValue(); String name = value.textProperty().getValue();
return name.toUpperCase(); return name;
} }
public GenerateOptionListener getListener() { public GenerateOptionListener getListener() {

@ -2,6 +2,7 @@ package xyz.wbsite.dbtool.javafx.enums;
public enum DataBase { public enum DataBase {
ORACLE, MySQL,
MYSQL Oracle,
SQLite
} }

@ -3,16 +3,40 @@ package xyz.wbsite.dbtool.javafx.manger;
import org.springframework.boot.system.ApplicationHome; import org.springframework.boot.system.ApplicationHome;
import xyz.wbsite.dbtool.javafx.enums.DataBase; import xyz.wbsite.dbtool.javafx.enums.DataBase;
import xyz.wbsite.dbtool.javafx.enums.FieldType; import xyz.wbsite.dbtool.javafx.enums.FieldType;
import xyz.wbsite.dbtool.javafx.manger.callable.*; import xyz.wbsite.dbtool.javafx.manger.callable.AndroidCallable;
import xyz.wbsite.dbtool.javafx.po.*; import xyz.wbsite.dbtool.javafx.manger.callable.ApiCallable;
import xyz.wbsite.dbtool.javafx.manger.callable.SBMDBCallable;
import xyz.wbsite.dbtool.javafx.manger.callable.SpringBootCallable;
import xyz.wbsite.dbtool.javafx.manger.callable.SpringMVCCallable;
import xyz.wbsite.dbtool.javafx.manger.callable.VueCallable;
import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
import xyz.wbsite.dbtool.javafx.po.AndroidOption;
import xyz.wbsite.dbtool.javafx.po.Api;
import xyz.wbsite.dbtool.javafx.po.Field;
import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.MySQLDBmapper;
import xyz.wbsite.dbtool.javafx.po.OracleDBmapper;
import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.SBMDBOption;
import xyz.wbsite.dbtool.javafx.po.SQLiteDBmapper;
import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.javafx.po.VueOption;
import xyz.wbsite.dbtool.javafx.tool.Dialog; import xyz.wbsite.dbtool.javafx.tool.Dialog;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.*; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class ProjectManager { public class ProjectManager {
@ -219,10 +243,12 @@ public class ProjectManager {
private static ExecutorService service = Executors.newFixedThreadPool(1); private static ExecutorService service = Executors.newFixedThreadPool(1);
public void tryGetDBmapper(DataBase dataBase) { public void tryGetDBmapper(DataBase dataBase) {
if (dataBase.name().equals(DataBase.MYSQL.name())) { if (dataBase.name().toUpperCase().equals(DataBase.MySQL.name().toUpperCase())) {
dBmapper = new MySqlDBmapper(dataBase); dBmapper = new MySQLDBmapper(dataBase);
} else if (dataBase.name().equals(DataBase.ORACLE.name())) { } else if (dataBase.name().toUpperCase().equals(DataBase.Oracle.name().toUpperCase())) {
dBmapper = new OracleDBmapper(dataBase); dBmapper = new OracleDBmapper(dataBase);
} else if (dataBase.name().toUpperCase().equals(DataBase.SQLite.name().toUpperCase())) {
dBmapper = new SQLiteDBmapper(dataBase);
} }
} }
@ -278,7 +304,7 @@ public class ProjectManager {
@Override @Override
public void run() { public void run() {
boolean mkdirs = api.mkdirs(); boolean mkdirs = api.mkdirs();
ApiCallable apiCallable = new ApiCallable(module,api,domainList, apis); ApiCallable apiCallable = new ApiCallable(module, api, domainList, apis);
Future submit = service.submit(apiCallable); Future submit = service.submit(apiCallable);
try { try {
Boolean b = (Boolean) submit.get(); Boolean b = (Boolean) submit.get();
@ -402,7 +428,7 @@ public class ProjectManager {
String driverClassName = properties.get("driverClassName"); String driverClassName = properties.get("driverClassName");
try { try {
//加载MySql的驱动类 //加载MySQL的驱动类
Class.forName(driverClassName); Class.forName(driverClassName);
Connection cn = DriverManager.getConnection(url, username, password); Connection cn = DriverManager.getConnection(url, username, password);
@ -425,7 +451,7 @@ public class ProjectManager {
if ("Orcale".equals(type)) { if ("Orcale".equals(type)) {
try { try {
dBmapper = new OracleDBmapper(DataBase.ORACLE); dBmapper = new OracleDBmapper(DataBase.Oracle);
//加载驱动类 //加载驱动类
Class.forName(driverClassName); Class.forName(driverClassName);
@ -497,7 +523,7 @@ public class ProjectManager {
} }
} else if ("Mysql".equals(type)) { } else if ("Mysql".equals(type)) {
try { try {
dBmapper = new MySqlDBmapper(DataBase.MYSQL); dBmapper = new MySQLDBmapper(DataBase.MySQL);
//加载驱动类 //加载驱动类
Class.forName(driverClassName); Class.forName(driverClassName);

@ -88,7 +88,7 @@ public class SpringBootCallable implements Callable {
generateMapper(Tool.createPath(moduleDir.getAbsolutePath(), "mpr"), module, dataBase, option); generateMapper(Tool.createPath(moduleDir.getAbsolutePath(), "mpr"), module, dataBase, option);
System.out.println("生成模块:Manager"); System.out.println("生成模块:Manager");
generateManager(Tool.createPath(moduleDir.getAbsolutePath(), "mgr"), module, dataBase, option); generateManager(Tool.createPath(moduleDir.getAbsolutePath(), "mgr"), module, dataBase, option);
System.out.println("生成模块:Requset"); System.out.println("生成模块:Request");
generateRequest(Tool.createPath(moduleDir.getAbsolutePath(), "req"), module, dataBase, option); generateRequest(Tool.createPath(moduleDir.getAbsolutePath(), "req"), module, dataBase, option);
System.out.println("生成模块:Response"); System.out.println("生成模块:Response");
generateResponse(Tool.createPath(moduleDir.getAbsolutePath(), "rsp"), module, dataBase, option); generateResponse(Tool.createPath(moduleDir.getAbsolutePath(), "rsp"), module, dataBase, option);
@ -664,7 +664,7 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "application-prod.properties"), option + "/resources/application-prod.ftl", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "application-prod.properties"), option + "/resources/application-prod.ftl", ctx);
Tool.outputResource(option + "/resources/logback-spring.xml", Tool.createFile(root.getAbsolutePath(), "logback-spring.xml")); Tool.outputResource(option + "/resources/logback-spring.xml", Tool.createFile(root.getAbsolutePath(), "logback-spring.xml"));
if (DataBase.ORACLE == dataBase) { if (DataBase.Oracle == dataBase) {
File lib = Tool.createPath(root.getAbsolutePath(), "lib"); File lib = Tool.createPath(root.getAbsolutePath(), "lib");
Tool.outputResource(option + "/resources/lib/ojdbc7-12.1.0.2.jar", Tool.createFile(lib.getAbsolutePath(), "ojdbc7-12.1.0.2.jar")); Tool.outputResource(option + "/resources/lib/ojdbc7-12.1.0.2.jar", Tool.createFile(lib.getAbsolutePath(), "ojdbc7-12.1.0.2.jar"));
} }

@ -3,9 +3,9 @@ package xyz.wbsite.dbtool.javafx.po;
import xyz.wbsite.dbtool.javafx.enums.DataBase; import xyz.wbsite.dbtool.javafx.enums.DataBase;
import xyz.wbsite.dbtool.javafx.enums.FieldType; import xyz.wbsite.dbtool.javafx.enums.FieldType;
public class MySqlDBmapper extends AbstractDBmapper { public class MySQLDBmapper extends AbstractDBmapper {
public MySqlDBmapper(DataBase mDataBase) { public MySQLDBmapper(DataBase mDataBase) {
super(mDataBase); super(mDataBase);
} }

@ -0,0 +1,236 @@
package xyz.wbsite.dbtool.javafx.po;
import xyz.wbsite.dbtool.javafx.enums.DataBase;
import xyz.wbsite.dbtool.javafx.enums.FieldType;
public class SQLiteDBmapper extends AbstractDBmapper {
public SQLiteDBmapper(DataBase mDataBase) {
super(mDataBase);
}
@Override
public String getDataBaseType(FieldType type, int lenght) {
if (FieldType.Boolean.name().equals(type.name())) {
return "BIT";
} else if (FieldType.Byte.name().equals(type.name())) {
return "TINYINT";
} else if (FieldType.Short.name().equals(type.name())) {
return "SMALLINT";
} else if (FieldType.Integer.name().equals(type.name())) {
return "INTEGER";
} else if (FieldType.Long.name().equals(type.name())) {
return "NUMERIC";
} else if (FieldType.Float.name().equals(type.name())) {
return "REAL";
} else if (FieldType.Double.name().equals(type.name())) {
return "FLOAT";
} else if (FieldType.Character.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_1.name().equals(type.name())) {
return "CAHR";
} else if (FieldType.String_10.name().equals(type.name())) {
return "CAHR";
} else if (FieldType.String_var.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var50.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var100.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var255.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var500.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var2500.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var4000.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.Date.name().equals(type.name())) {
return "DATE";
} else if (FieldType.Bytes.name().equals(type.name())) {
return "BLOB";
} else {
return "";
}
}
@Override
public String getFieldSql(Field field) {
StringBuffer sb = new StringBuffer("");
sb.append("`").append(field.getFieldName()).append("` ");
FieldType type = field.getFieldType();
if (FieldType.Boolean.name().equals(type.name())) {
sb.append("TINYINT(1)");
} else if (FieldType.Dict.name().equals(type.name())) {
sb.append("VARCHAR(10)");
} else if (FieldType.Byte.name().equals(type.name())) {
sb.append("TINYINT(3)");
} else if (FieldType.Short.name().equals(type.name())) {
sb.append("SMALLINT(5)");
} else if (FieldType.Integer.name().equals(type.name())) {
sb.append("INTEGER(10)");
} else if (FieldType.Long.name().equals(type.name())) {
sb.append("BIGINT(20)");
} else if (FieldType.Float.name().equals(type.name())) {
sb.append("FLOAT");
} else if (FieldType.Double.name().equals(type.name())) {
sb.append("DOUBLE");
} else if (FieldType.Date.name().equals(type.name())) {
sb.append("DATETIME");
} else if (FieldType.Bytes.name().equals(type.name())) {
sb.append("BLOB");
} else if (FieldType.Character.name().equals(type.name())) {
sb.append("CHAR(1)");
} else if (FieldType.String_1.name().equals(type.name())) {
sb.append("CHAR(1)");
} else if (FieldType.String_10.name().equals(type.name())) {
sb.append("CHAR(10)");
} else if (FieldType.String_var.name().equals(type.name())) {
Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.String_var50.name().equals(type.name())) {
sb.append("VARCHAR(50)");
} else if (FieldType.String_var100.name().equals(type.name())) {
sb.append("VARCHAR(100)");
} else if (FieldType.String_var255.name().equals(type.name())) {
sb.append("VARCHAR(250)");
} else if (FieldType.String_var500.name().equals(type.name())) {
sb.append("VARCHAR(500)");
} else if (FieldType.String_var2500.name().equals(type.name())) {
sb.append("VARCHAR(2500)");
} else if (FieldType.String_var4000.name().equals(type.name())) {
sb.append("VARCHAR(4000)");
} else if (FieldType.String_super.name().equals(type.name())) {
sb.append("TEXT");
}
if (!field.getIsSystem() && field.getIsMust() && (field.getDefaultValue() == null || field.getDefaultValue().toUpperCase().equals("NULL"))) {
sb.append(" NOT NULL");
} else if (!field.getIsSystem() && field.getIsMust() && field.getDefaultValue() != null && !field.getDefaultValue().toUpperCase().equals("NULL")) {
if (field.getFieldType().name().contains("String")) {//默认字符
sb.append(" NOT NULL").append(" DEFAULT '" + field.getDefaultValue() + "'");
} else {//不是字符就是数字,目前只考虑两张情况
sb.append(" NOT NULL").append(" DEFAULT " + field.getDefaultValue() + "");
}
} else if (field.getIsSystem() && field.getFieldName().equals("ID")) {
sb.append(" NOT NULL");
} else if (field.getIsSystem() && field.getFieldName().equals("ROW_VERSION")) {
sb.append(" NOT NULL").append(" DEFAULT 0");
} else if (field.getIsSystem() && field.getFieldName().equals("IS_DELETED")) {
sb.append(" NOT NULL").append(" DEFAULT 0");
} else if (field.getIsSystem() && field.getFieldName().equals("CREATE_BY")) {
sb.append(" NOT NULL");
} else if (field.getIsSystem() && field.getFieldName().equals("CREATE_TIME")) {
sb.append(" NOT NULL");
} else if (field.getIsSystem() && field.getFieldName().equals("LAST_UPDATE_BY")) {
sb.append(" DEFAULT NULL");
} else if (field.getIsSystem() && field.getFieldName().equals("LAST_UPDATE_TIME")) {
sb.append(" DEFAULT NULL");
}
if (field.getFieldComment() != null) {
sb.append(" COMMENT '" + field.getFieldComment() + "'");
}
return sb.toString();
}
@Override
DataBase getDataBase() {
return super.getDataBase();
}
@Override
public String getDataBaseType(FieldType type) {
if (FieldType.Boolean.name().equals(type.name())) {
return "TINYINT";
} else if (FieldType.Byte.name().equals(type.name())) {
return "TINYINT";
} else if (FieldType.Short.name().equals(type.name())) {
return "SMALLINT";
} else if (FieldType.Integer.name().equals(type.name())) {
return "INTEGER";
} else if (FieldType.Long.name().equals(type.name())) {
return "NUMERIC";
} else if (FieldType.Float.name().equals(type.name())) {
return "REAL";
} else if (FieldType.Double.name().equals(type.name())) {
return "FLOAT";
} else if (FieldType.Character.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_1.name().equals(type.name())) {
return "CHAR";
} else if (FieldType.String_10.name().equals(type.name())) {
return "CHAR";
} else if (FieldType.String_var.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var50.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var100.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var255.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var500.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var2500.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_var4000.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.Date.name().equals(type.name())) {
return "DATETIME";
} else if (FieldType.Bytes.name().equals(type.name())) {
return "BLOB";
} else {
return "";
}
}
@Override
public FieldType getType(String type, int lenght, int precision, int scale) {
if ("bigint".equals(type)) {
return FieldType.Long;
} else if ("varchar".equals(type) && lenght == 50) {
return FieldType.String_var50;
} else if ("varchar".equals(type) && lenght == 100) {
return FieldType.String_var100;
} else if ("varchar".equals(type) && lenght == 255) {
return FieldType.String_var255;
} else if ("varchar".equals(type) && lenght == 500) {
return FieldType.String_var500;
} else if ("varchar".equals(type) && lenght == 2500) {
return FieldType.String_var2500;
} else if ("varchar".equals(type) && lenght == 4000) {
return FieldType.String_var4000;
} else if ("varchar".equals(type)) {
return FieldType.String_var;
} else if ("date".equals(type)) {
return FieldType.Date;
} else if ("datetime".equals(type)) {
return FieldType.Date;
} else if ("timestamp".equals(type)) {
return FieldType.Date;
} else if ("char".equals(type) && lenght == 1) {
return FieldType.String_1;
} else if ("char".equals(type) && lenght == 10) {
return FieldType.String_10;
} else if ("char".equals(type)) {
return FieldType.String_var;
} else if ("tinyint".equals(type)) {
return FieldType.Integer;
} else if ("smallint".equals(type)) {
return FieldType.Integer;
} else if ("mediumint".equals(type)) {
return FieldType.Integer;
} else if ("int".equals(type)) {
return FieldType.Integer;
} else if ("bigint".equals(type)) {
return FieldType.Long;
} else if ("float".equals(type)) {
return FieldType.Float;
} else if ("double".equals(type)) {
return FieldType.Double;
}
return FieldType.String_var50;
}
}

@ -219,7 +219,7 @@ public class Dialog {
controller.getOk().setOnAction(new EventHandler<ActionEvent>() { controller.getOk().setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
listener.onGenerate(controller.getType(), DataBase.valueOf(controller.getDataBase().toUpperCase())); listener.onGenerate(controller.getType(), DataBase.valueOf(controller.getDataBase()));
} }
}); });

@ -0,0 +1,114 @@
package xyz.wbsite.dbtool.web.frame.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
/**
* ClassUtil
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ClassUtil {
/**
*
*
* @param clazz
* @param parentFirst
* @return
*/
public static Field[] getFields(Class clazz, boolean parentFirst) {
Field[] fields = clazz.getDeclaredFields();
if (parentFirst) {
Field[] parentFields = getParentFields(clazz.getSuperclass());
return concat(fields, parentFields);
}
return fields;
}
/**
*
*
* @param clazz
* @return
*/
public static boolean isCollection(Class<?> clazz) {
return Collection.class.isAssignableFrom(clazz);
}
/**
* GET
*
* @param name
* @param pojoClass POJO
* @return
*/
public static Method getMethod(String name, Class<?> pojoClass) throws RuntimeException {
String getMethodName = "get" + StringUtil.upperFirstWord(name);
try {
return pojoClass.getMethod(getMethodName);
} catch (Exception e) {
getMethodName = "is" + StringUtil.upperFirstWord(name);
try {
return pojoClass.getMethod(getMethodName);
} catch (NoSuchMethodException e1) {
throw new RuntimeException("can not find[" + name + "]method");
}
}
}
/**
* SET
*
* @param name
* @param pojoClass POJO
* @return
*/
public static Method setMethod(String name, Class<?> pojoClass, Class<?> type) {
String setMethodName = "set" + StringUtil.upperFirstWord(name);
try {
return pojoClass.getMethod(setMethodName, type);
} catch (Exception e) {
return null;
}
}
public static boolean isJavaClass(Field field) {
Class<?> fieldType = field.getType();
boolean isBaseClass = false;
if (fieldType.isArray()) {
isBaseClass = false;
} else if (fieldType.isPrimitive() || fieldType.getPackage() == null
|| fieldType.getPackage().getName().equals("java.lang")
|| fieldType.getPackage().getName().equals("java.math")
|| fieldType.getPackage().getName().equals("java.sql")
|| fieldType.getPackage().getName().equals("java.util")) {
isBaseClass = true;
}
return isBaseClass;
}
public static Field[] getFields(Class clazz) {
return getFields(clazz, false);
}
private static Field[] getParentFields(Class parentClazz) {
if (parentClazz != null) {
Field[] fields = parentClazz.getDeclaredFields();
Field[] parentFields = getParentFields(parentClazz.getSuperclass());
return concat(fields, parentFields);
}
return new Field[0];
}
private static Field[] concat(Field[] f1, Field[] f2) {
Field[] fields = new Field[f1.length + f2.length];
System.arraycopy(f1, 0, fields, 0, f1.length);
System.arraycopy(f2, 0, fields, f1.length, f2.length);
return fields;
}
}

@ -55,6 +55,28 @@ public class FileUtil {
} }
} }
public static byte[] toByteArray(InputStream input, int size) throws IOException {
if(size < 0) {
throw new IllegalArgumentException("Size must be equal or greater than zero: " + size);
} else if(size == 0) {
return new byte[0];
} else {
byte[] data = new byte[size];
int offset;
int read;
for(offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) {
;
}
if(offset != size) {
throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size);
} else {
return data;
}
}
}
public static byte[] toByteArray(InputStream input) throws IOException { public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();
Throwable var2 = null; Throwable var2 = null;

@ -0,0 +1,78 @@
package xyz.wbsite.dbtool.web.frame.utils;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class ResourceUtil extends ResourceUtils {
/**
* jar
*
* @return jar
*/
public static File getApplicationHome() {
ApplicationHome home = new ApplicationHome(ResourceUtil.class);
return home.getSource();
}
/**
* resource
*
* @return
*/
public static InputStream getResourceInput(String resource) {
try {
ClassPathResource classPathResource = new ClassPathResource(resource);
return classPathResource.getInputStream();
} catch (IOException e) {
return null;
}
}
public static boolean copyResource2File(String resource, File file) {
InputStream resourceInput = getResourceInput(resource);
FileOutputStream fileOutputStream = null;
try {
if (!file.exists()) {
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
FileUtil.copy(resourceInput, fileOutputStream);
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (fileOutputStream != null) fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
public static byte[] getResourceBytes(String resource) {
InputStream is = null;
byte[] result = null;
try {
is = getResourceInput(resource);
result = new byte[is.available()];
is.read(result);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
}

@ -0,0 +1,38 @@
package xyz.wbsite.dbtool.web.frame.utils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* Base64Util
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ResponseUtil {
/**
* ResponseEntity
*
* @param bytes
* @param fileName
* @return
*/
public static ResponseEntity<byte[]> apply(byte[] bytes, String fileName) {
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", URLEncoder.encode(fileName, "utf-8"));
return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
} catch (UnsupportedEncodingException e) {
return null;
}
}
}

@ -0,0 +1,87 @@
package xyz.wbsite.dbtool.web.frame.utils;
public class StringUtil {
public static int getByteLength(String str) {
int length = str.replaceAll("[^\\x00-\\xff]", "**").length();
return length;
}
public static String upperFirstWord(String str) {
String temp = str.substring(0, 1);
return temp.toUpperCase() + str.substring(1);
}
public static boolean isEmpty(String value) {
int strLen;
if (value == null || (strLen = value.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(value.charAt(i)) == false)) {
return false;
}
}
return true;
}
public static boolean isNotEmpty(String value) {
return !isEmpty(value);
}
/**
* ,
*/
public static boolean isNumeric(Object obj) {
if (obj == null) {
return false;
}
char[] chars = obj.toString().toCharArray();
int length = chars.length;
if (length < 1)
return false;
int i = 0;
if (length > 1 && chars[0] == '-')
i = 1;
for (; i < length; i++) {
if (!Character.isDigit(chars[i])) {
return false;
}
}
return true;
}
/**
*
*/
public static String unicodeToChinese(String unicode) {
StringBuilder out = new StringBuilder();
if (!isEmpty(unicode)) {
for (int i = 0; i < unicode.length(); i++) {
out.append(unicode.charAt(i));
}
}
return out.toString();
}
public static String toUnderlineStyle(String name) {
StringBuilder newName = new StringBuilder();
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (Character.isUpperCase(c)) {
if (i > 0) {
newName.append("_");
}
newName.append(Character.toLowerCase(c));
} else {
newName.append(c);
}
}
return newName.toString();
}
}

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.Button?>
<?import javafx.scene.layout.*?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<BorderPane fx:controller="xyz.wbsite.dbtool.javafx.ctrl.OptionMainController" prefHeight="199.0" prefWidth="468.0" <BorderPane fx:controller="xyz.wbsite.dbtool.javafx.ctrl.OptionMainController" prefHeight="199.0" prefWidth="468.0"
xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<center> <center>
@ -34,12 +40,13 @@
</padding> </padding>
</Label> </Label>
<HBox prefHeight="40.0" prefWidth="600.0"> <HBox prefHeight="40.0" prefWidth="600.0">
<RadioButton mnemonicParsing="false" text="Oracle"> <RadioButton mnemonicParsing="false" text="MySQL" selected="true">
<toggleGroup> <toggleGroup>
<ToggleGroup fx:id="db"/> <ToggleGroup fx:id="db"/>
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton mnemonicParsing="false" text="MySql" selected="true" toggleGroup="$db"/> <RadioButton mnemonicParsing="false" text="Oracle" toggleGroup="$db"/>
<RadioButton mnemonicParsing="false" text="SQLite" toggleGroup="$db"/>
<padding> <padding>
<Insets bottom="3.0" left="20.0" right="10.0" top="3.0"/> <Insets bottom="3.0" left="20.0" right="10.0" top="3.0"/>
</padding> </padding>

@ -1,8 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.Button?>
<?import javafx.scene.layout.*?> <?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.control.TreeView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="xyz.wbsite.dbtool.javafx.ctrl.MainController"> fx:controller="xyz.wbsite.dbtool.javafx.ctrl.MainController">
@ -22,10 +33,10 @@
</Menu> </Menu>
<Menu mnemonicParsing="false" text="其他模型"> <Menu mnemonicParsing="false" text="其他模型">
<items> <items>
<MenuItem mnemonicParsing="false" onAction="#generateVue" text="生成Vue"/>
<MenuItem mnemonicParsing="false" onAction="#generateApi" text="生成Api"/> <MenuItem mnemonicParsing="false" onAction="#generateApi" text="生成Api"/>
<MenuItem mnemonicParsing="false" onAction="#generateVue" text="生成Vue"/>
<MenuItem mnemonicParsing="false" onAction="#generateAndroid" text="生成Android"/> <MenuItem mnemonicParsing="false" onAction="#generateAndroid" text="生成Android"/>
<MenuItem mnemonicParsing="false" onAction="#generateSBMDB" text="生成SB多库"/> <MenuItem mnemonicParsing="false" onAction="#generateSBMDB" text="生成多库方案"/>
</items> </items>
</Menu> </Menu>
<Menu mnemonicParsing="false" text="Help"> <Menu mnemonicParsing="false" text="Help">

@ -0,0 +1,95 @@
package ${basePackage}.frame.utils;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* Resource
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ResourceUtil extends ResourceUtils {
/**
* jar
*
* @return jar
*/
public static File getApplicationHome() {
ApplicationHome home = new ApplicationHome(ResourceUtil.class);
return home.getSource();
}
/**
* resource
*
* @return
*/
public static InputStream getResourceInput(String resource) {
try {
ClassPathResource classPathResource = new ClassPathResource(resource);
return classPathResource.getInputStream();
} catch (IOException e) {
return null;
}
}
/**
* jar
*
* @return
*/
public static boolean copyResource2File(String resource, File file) {
InputStream resourceInput = getResourceInput(resource);
FileOutputStream fileOutputStream = null;
try {
if (!file.exists()) {
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
FileUtil.copy(resourceInput, fileOutputStream);
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (fileOutputStream != null) fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
/**
*
*
* @return
*/
public static byte[] getResourceBytes(String resource) {
InputStream is = null;
byte[] result = null;
try {
is = getResourceInput(resource);
result = new byte[is.available()];
is.read(result);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
}

@ -4,16 +4,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePackage}.module.${moduleName}.mpr.${table.getCName()}Mapper"> <mapper namespace="${basePackage}.module.${moduleName}.mpr.${table.getCName()}Mapper">
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<sql id="table">"${module.modulePrefix?default("")}${table.tableName}"</sql> <sql id="table">"${module.modulePrefix?default("")}${table.tableName}"</sql>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<sql id="table">`${module.modulePrefix?default("")}${table.tableName}`</sql> <sql id="table">`${module.modulePrefix?default("")}${table.tableName}`</sql>
</#if> </#if>
<sql id="entityColumnList"> <sql id="entityColumnList">
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#list table.fields as f>"${f.fieldName}"<#if f_has_next>,</#if></#list> <#list table.fields as f>"${f.fieldName}"<#if f_has_next>,</#if></#list>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#list table.fields as f>`${f.fieldName}`<#if f_has_next>,</#if></#list> <#list table.fields as f>`${f.fieldName}`<#if f_has_next>,</#if></#list>
</#if> </#if>
</sql> </sql>
@ -30,14 +30,14 @@
FROM FROM
<include refid="table"/> <include refid="table"/>
WHERE WHERE
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
"IS_DELETED" = 0 "IS_DELETED" = 0
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
`IS_DELETED` = 0 `IS_DELETED` = 0
</#if> </#if>
<#list table.fields as f> <#list table.fields as f>
<#if f.isQuery> <#if f.isQuery>
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#if f.fieldType.javaType() == "Boolean"> <#if f.fieldType.javaType() == "Boolean">
<if test="request.${f.getFName()} != null"> <if test="request.${f.getFName()} != null">
AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}} AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}}
@ -88,7 +88,7 @@
AND to_char("${f.fieldName}",'yyyy-MM-dd HH24:mi:ss') = to_char(${r"#{"}request.${f.getFName()}},'yyyy-MM-dd HH24:mi:ss') AND to_char("${f.fieldName}",'yyyy-MM-dd HH24:mi:ss') = to_char(${r"#{"}request.${f.getFName()}},'yyyy-MM-dd HH24:mi:ss')
</if> </if>
</#if> </#if>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#if f.fieldType.javaType() == "Boolean"> <#if f.fieldType.javaType() == "Boolean">
<if test="request.${f.getFName()} != null"> <if test="request.${f.getFName()} != null">
AND `${f.fieldName}` = ${r"#{"}request.${f.getFName()}} AND `${f.fieldName}` = ${r"#{"}request.${f.getFName()}}
@ -150,18 +150,18 @@
FROM FROM
<include refid="table"/> <include refid="table"/>
WHERE WHERE
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
"IS_DELETED" = 0 "IS_DELETED" = 0
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
`IS_DELETED` = 0 `IS_DELETED` = 0
</#if> </#if>
<if test="request.keyword != null and request.keyword != ''"> <if test="request.keyword != null and request.keyword != ''">
1 = 2 1 = 2
<#list table.fields as f> <#list table.fields as f>
<#if f.isSearch> <#if f.isSearch>
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
OR "${f.fieldName}" LIKE CONCAT(CONCAT('%',${r"#{"}request.keyword}),'%') OR "${f.fieldName}" LIKE CONCAT(CONCAT('%',${r"#{"}request.keyword}),'%')
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
OR `${f.fieldName}` LIKE CONCAT('%',${r"#{request.keyword}"},'%') OR `${f.fieldName}` LIKE CONCAT('%',${r"#{request.keyword}"},'%')
</#if> </#if>
</#if> </#if>
@ -186,7 +186,7 @@
0, 0,
0, 0,
${r"#{"}token.userId,jdbcType=NUMERIC}, ${r"#{"}token.userId,jdbcType=NUMERIC},
<#if dataBase == 'ORACLE'>sysdate<#elseif dataBase == 'MYSQL'>sysdate()</#if>, <#if dataBase == 'Oracle'>sysdate<#elseif dataBase == 'MySQL'>sysdate()</#if>,
NULL, NULL,
NULL NULL
) )
@ -210,7 +210,7 @@
0, 0,
0, 0,
${r"#{"}token.userId,jdbcType=NUMERIC}, ${r"#{"}token.userId,jdbcType=NUMERIC},
<#if dataBase == 'ORACLE'>sysdate<#elseif dataBase == 'MYSQL'>sysdate()</#if>, <#if dataBase == 'Oracle'>sysdate<#elseif dataBase == 'MySQL'>sysdate()</#if>,
NULL, NULL,
NULL NULL
) )
@ -220,11 +220,11 @@
<update id="delete"> <update id="delete">
UPDATE UPDATE
<include refid="table"/> <include refid="table"/>
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
SET "IS_DELETED" = 1 SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0 WHERE "IS_DELETED" = 0
AND "ID" = ${r"#{"}request.id} AND "ID" = ${r"#{"}request.id}
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
SET `IS_DELETED` = 1 SET `IS_DELETED` = 1
WHERE `IS_DELETED` = 0 WHERE `IS_DELETED` = 0
AND `ID` = ${r"#{"}request.id} AND `ID` = ${r"#{"}request.id}
@ -235,7 +235,7 @@
UPDATE UPDATE
<include refid="table"/> <include refid="table"/>
SET SET
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#list table.fields as f> <#list table.fields as f>
<#if !f.isPrimaryKey> <#if !f.isPrimaryKey>
<#if !f.isSystem || f.fieldName == 'ID'> <#if !f.isSystem || f.fieldName == 'ID'>
@ -246,7 +246,7 @@
"ROW_VERSION" = "ROW_VERSION" + 1, "ROW_VERSION" = "ROW_VERSION" + 1,
"LAST_UPDATE_BY" = ${r"#{"}token.userId}, "LAST_UPDATE_BY" = ${r"#{"}token.userId},
"LAST_UPDATE_TIME" = sysdate "LAST_UPDATE_TIME" = sysdate
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#list table.fields as f> <#list table.fields as f>
<#if !f.isPrimaryKey> <#if !f.isPrimaryKey>
<#if !f.isSystem || f.fieldName == 'ID'> <#if !f.isSystem || f.fieldName == 'ID'>
@ -259,11 +259,11 @@
`LAST_UPDATE_TIME` = sysdate() `LAST_UPDATE_TIME` = sysdate()
</#if> </#if>
WHERE WHERE
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
"IS_DELETED" = 0 "IS_DELETED" = 0
AND "ID" = ${r"#{"}request.id} AND "ID" = ${r"#{"}request.id}
AND "ROW_VERSION" = ${r"#{"}request.rowVersion} AND "ROW_VERSION" = ${r"#{"}request.rowVersion}
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
`IS_DELETED` = 0 `IS_DELETED` = 0
AND `ID` = ${r"#{"}request.id} AND `ID` = ${r"#{"}request.id}
AND `ROW_VERSION` = ${r"#{"}request.rowVersion} AND `ROW_VERSION` = ${r"#{"}request.rowVersion}
@ -276,9 +276,9 @@
FROM FROM
<include refid="table"/> <include refid="table"/>
WHERE WHERE
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
"IS_DELETED" = 0 "IS_DELETED" = 0
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
`IS_DELETED` = 0 `IS_DELETED` = 0
</#if> </#if>
</select> </select>
@ -289,10 +289,10 @@
FROM FROM
<include refid="table"/> <include refid="table"/>
WHERE WHERE
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
"IS_DELETED" = 0 "IS_DELETED" = 0
AND "ID" = ${r"#{request.id}"} AND "ID" = ${r"#{request.id}"}
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
`IS_DELETED` = 0 `IS_DELETED` = 0
AND `ID` = ${r"#{request.id}"} AND `ID` = ${r"#{request.id}"}
</#if> </#if>

@ -5,16 +5,16 @@
<mapper namespace="${basePackage}.module.${moduleName}.mpr.${table.getCName()}Mapper"> <mapper namespace="${basePackage}.module.${moduleName}.mpr.${table.getCName()}Mapper">
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<sql id="table">"${module.modulePrefix?default("")}${table.tableName}"</sql> <sql id="table">"${module.modulePrefix?default("")}${table.tableName}"</sql>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<sql id="table">`${module.modulePrefix?default("")}${table.tableName}`</sql> <sql id="table">`${module.modulePrefix?default("")}${table.tableName}`</sql>
</#if> </#if>
<sql id="entityColumnList"> <sql id="entityColumnList">
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#list table.fields as f>"${f.fieldName}"<#if f_has_next>,</#if></#list> <#list table.fields as f>"${f.fieldName}"<#if f_has_next>,</#if></#list>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#list table.fields as f>`${f.fieldName}`<#if f_has_next>,</#if></#list> <#list table.fields as f>`${f.fieldName}`<#if f_has_next>,</#if></#list>
</#if> </#if>
</sql> </sql>
@ -34,7 +34,7 @@
1 = 1 1 = 1
<#list table.fields as f> <#list table.fields as f>
<#if f.isQuery> <#if f.isQuery>
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#if f.fieldType.javaType() == "String"> <#if f.fieldType.javaType() == "String">
<if test="request.${f.getFName()} != null and request.${f.getFName()} != ''"> <if test="request.${f.getFName()} != null and request.${f.getFName()} != ''">
AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}} AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}}
@ -45,7 +45,7 @@
AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}} AND "${f.fieldName}" = ${r"#{"}request.${f.getFName()}}
</if> </if>
</#if> </#if>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#if f.fieldType.javaType() == "String"> <#if f.fieldType.javaType() == "String">
<if test="request.${f.getFName()} != null and request.${f.getFName()} != ''"> <if test="request.${f.getFName()} != null and request.${f.getFName()} != ''">
AND `${f.fieldName}` = ${r"#{"}request.${f.getFName()}} AND `${f.fieldName}` = ${r"#{"}request.${f.getFName()}}
@ -86,11 +86,11 @@
UPDATE UPDATE
<include refid="table"/> <include refid="table"/>
SET SET
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
<#list table.fields as f> <#list table.fields as f>
"${f.fieldName}" = ${r"#{"}request.${f.getFName()},jdbcType=${f.fieldType.jdbcType()}}<#if f_has_next>,</#if> "${f.fieldName}" = ${r"#{"}request.${f.getFName()},jdbcType=${f.fieldType.jdbcType()}}<#if f_has_next>,</#if>
</#list> </#list>
<#elseif dataBase='MYSQL'> <#elseif dataBase='MySQL'>
<#list table.fields as f> <#list table.fields as f>
`${f.fieldName}` = ${r"#{"}request.${f.getFName()},jdbcType=${f.fieldType.jdbcType()}}<#if f_has_next>,</#if> `${f.fieldName}` = ${r"#{"}request.${f.getFName()},jdbcType=${f.fieldType.jdbcType()}}<#if f_has_next>,</#if>
</#list> </#list>

@ -115,6 +115,14 @@
</dependency> </dependency>
</#if> </#if>
<#if dataBase == 'SQLite'>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0.1</version>
</dependency>
</#if>
<#if dataBase == 'ORACLE'> <#if dataBase == 'ORACLE'>
<dependency> <dependency>
<groupId>com.example</groupId> <groupId>com.example</groupId>

@ -17,23 +17,36 @@ server.tomcat.uri-encoding=UTF-8
# 日志配置 # 日志配置
logging.path=D:// logging.path=D://
logging.levels=DEBUG logging.levels=DEBUG
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
# oracle # Oracle
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
spring.datasource.username=TEST spring.datasource.username=TEST
spring.datasource.password=123456 spring.datasource.password=123456
# mybatis
mybatis.mapper-locations=classpath:**/mpr/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
</#if> </#if>
<#if dataBase == 'MYSQL'> <#if dataBase == 'MySQL'>
# mysql # MySQL
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.31.81:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.url=jdbc:mysql://192.168.31.81:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=test spring.datasource.username=test
spring.datasource.password=123456 spring.datasource.password=123456# mybatis
# mybatis
mybatis.mapper-locations=classpath:**/mpr/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
</#if> </#if>
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite::resource:example.db
spring.datasource.username=test
spring.datasource.password=123456
# mybatis # mybatis
mybatis.mapper-locations=classpath:**/mpr/*.xml mybatis.mapper-locations=classpath:**/mpr/*.xml
mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.map-underscore-to-camel-case=true
</#if>
# pagehelper # pagehelper
pagehelper.autoRuntimeDialect=true pagehelper.autoRuntimeDialect=true
pagehelper.reasonable=false pagehelper.reasonable=false

@ -17,23 +17,26 @@ server.tomcat.uri-encoding=UTF-8
# 日志配置 # 日志配置
logging.path=/root/ logging.path=/root/
logging.levels=INFO logging.levels=INFO
<#if dataBase == 'ORACLE'> <#if dataBase == 'Oracle'>
# oracle # oracle
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
spring.datasource.username=TEST spring.datasource.username=TEST
spring.datasource.password=123456 spring.datasource.password=123456
# mybatis
mybatis.mapper-locations=classpath:**/mpr/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
</#if> </#if>
<#if dataBase == 'MYSQL'> <#if dataBase == 'MySQL'>
# mysql # mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=test spring.datasource.username=test
spring.datasource.password=123456 spring.datasource.password=123456
</#if>
# mybatis # mybatis
mybatis.mapper-locations=classpath:**/mpr/*.xml mybatis.mapper-locations=classpath:**/mpr/*.xml
mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.map-underscore-to-camel-case=true
</#if>
# pagehelper # pagehelper
pagehelper.autoRuntimeDialect=true pagehelper.autoRuntimeDialect=true
pagehelper.reasonable=false pagehelper.reasonable=false

Loading…
Cancel
Save

Powered by TurnKey Linux.