瀏覽代碼

Merge pull request #8 from juxiaowei/master

pr 跨平台生成路径问题
click33 2 年之前
父節點
當前提交
52757c57da

+ 5 - 3
sp-generate/src/main/java/com/pj/gen/GenUtil.java

@@ -7,6 +7,8 @@ import com.pj.gen.read.FlyRead;
 import com.pj.gen.read.FlyReadMySql;
 import com.pj.gen.read.ReadUtil;
 
+import java.io.File;
+
 /**
  *  操作工具类 
  * @author kong
@@ -41,8 +43,8 @@ public class GenUtil {
 		for (DbTable t : GenCfgManager.cfg.tableList) {
 			
 			// model
-			String modelPath = t.getServerIoPath() + t.getModelName() + ".java";			// 路径
-			String modelContent = FreeMarkerUtil.getResult("mybatis/Model.ftl", "t", t);		// 内容 
+			String modelPath = t.getServerIoPath() + t.getModelName() + ".java";
+			String modelContent = FreeMarkerUtil.getResult("mybatis/Model.ftl", "t", t);		// 内容
 			SUtil.outFile(modelPath, modelContent);
 			System.out.println(t.getModelName() + " 写入成功:\t\t\t" + modelPath);
 			
@@ -146,7 +148,7 @@ public class GenUtil {
 		}
 		
 		// menu-list.js 菜单列表 
-		String menuListPath = GenCfgManager.cfg.getAdminProjectPath() + "sa-frame\\menu-list.js";						// 路径  
+		String menuListPath = GenCfgManager.cfg.getAdminProjectPath() + "sa-frame"+ File.separator+"menu-list.js";						// 路径
 		String menuListContent = FreeMarkerUtil.getResult("admin/menu-list.ftl", "abc", 123);		// 内容 
 		SUtil.outFile(menuListPath, menuListContent);
 		System.out.println("menu-list.js 菜单列表, 写入成功:\t\t" + menuListPath);

+ 1 - 1
sp-generate/src/main/java/com/pj/gen/SUtil.java

@@ -354,7 +354,7 @@ public class SUtil {
 	
 	// 指定包的Spring工厂类
 	public static String SpringBeanFC(String projectPath, String packagePath, String fcName){
-		File wjj = new File(projectPath, packagePath.replace(".", "\\")); // 创建路径
+		File wjj = new File(projectPath, packagePath.replace(".", File.separator)); // 创建路径
 		String[] classNameArray = wjj.list();
 		
 		String _package = "package " + packagePath + ";\r\n\r\n";

+ 13 - 13
sp-generate/src/main/java/com/pj/gen/cfg/GenCfg.java

@@ -85,18 +85,18 @@ public class GenCfg {
 	// ---------------- 项目根路径 
 	// 服务端代码根路径 
 	public String getServerProjectPath() {
-		String path = projectPath + "\\" + serverProjectName + "\\";
-		return new File(path).getAbsolutePath() + "\\";
+		String path = projectPath +  File.separator + serverProjectName + File.separator;
+		return new File(path).getAbsolutePath() + File.separator;
 	}
-	// 后天管理端代码根路径 
+	// 后台管理端代码根路径
 	public String getAdminProjectPath() {
-		String path = projectPath + "\\" + adminProjectName + "\\";
-		return new File(path).getAbsolutePath() + "\\";
+		String path = projectPath + File.separator + adminProjectName + File.separator;
+		return new File(path).getAbsolutePath() + File.separator;
 	}
 	// 接口文档端代码根路径 
 	public String getApidocProjectPath() {
-		String path = projectPath + "\\" + apidocProjectName + "\\";
-		return new File(path).getAbsolutePath() + "\\";
+		String path = projectPath + File.separator + apidocProjectName + File.separator;
+		return new File(path).getAbsolutePath() + File.separator;
 	}
 	
 
@@ -106,18 +106,18 @@ public class GenCfg {
 	
 	// 返会服务端IO的主目录
 	public String getServerIoPath() {
-		String path = getServerProjectPath() + codePath + "\\" + packagePath.replace(".", "\\");
-		return new File(path).getAbsolutePath() + "\\";
+		String path = getServerProjectPath() + codePath + File.separator + packagePath.replace(".", File.separator);
+		return new File(path).getAbsolutePath() + File.separator;
 	}
 	// 返会admin后台管理的IO的主目录
 	public String getAdminIoPath() {
-		String path = getAdminProjectPath() + adminCodePath + "\\";
-		return new File(path).getAbsolutePath() + "\\";
+		String path = getAdminProjectPath() + adminCodePath + File.separator;
+		return new File(path).getAbsolutePath() + File.separator;
 	}
 	// 返会apidoc后台管理的IO的主目录
 	public String getApidocIoPath() {
-		String path = getApidocProjectPath() + apidocCodePath + "\\";
-		return new File(path).getAbsolutePath() + "\\";
+		String path = getApidocProjectPath() + apidocCodePath + File.separator;
+		return new File(path).getAbsolutePath() + File.separator;
 	}
 		
 

+ 3 - 2
sp-generate/src/main/java/com/pj/gen/model/DbTable.java

@@ -1,5 +1,6 @@
 package com.pj.gen.model;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -665,11 +666,11 @@ public class DbTable {
 	// ---------- IO输出相关 
 	// 返回服务端应该写入哪个文件夹
 	public String getServerIoPath() {
-		return GenCfgManager.cfg.getServerIoPath() + this.getPackageModules() + "\\";
+		return GenCfgManager.cfg.getServerIoPath() + this.getPackageModules() + File.separator;
 	}
 	// 返回后台管理应该写入哪个文件夹
 	public String getAdminIoPath() {
-		return GenCfgManager.cfg.getAdminIoPath() + this.getKebabName() + "\\";
+		return GenCfgManager.cfg.getAdminIoPath() + this.getKebabName() + File.separator;
 	}
 	// 返回接口文档应该写入哪个文件夹
 	public String getApidocIoPath() {