Commit 67310d3ff387df20294bb5355cdb845ddee05dfc
1 parent
9a6d072f
Exists in
master
fix a bug
Showing
1 changed file
with
10 additions
and
9 deletions
Show diff stats
src/main/java/com/taover/codegenerate/bazhuayun/GenerateCode.java
... | ... | @@ -27,7 +27,7 @@ public class GenerateCode { |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | - public static Connection getConnection(String host, String port, String user, String password, String dbName) { | |
30 | + private static Connection getConnection(String host, String port, String user, String password, String dbName) { | |
31 | 31 | Connection conn = null; |
32 | 32 | try { |
33 | 33 | Class.forName("com.mysql.jdbc.Driver"); |
... | ... | @@ -91,9 +91,10 @@ public class GenerateCode { |
91 | 91 | generateService(srcPath, apiModel); |
92 | 92 | generateVo(srcPath, apiModel); |
93 | 93 | } |
94 | + System.out.println("处理完成"); | |
94 | 95 | } |
95 | 96 | |
96 | - public static String renderByTemplate(String templateName, ApiModel apiModel) throws Exception{ | |
97 | + private static String renderByTemplate(String templateName, ApiModel apiModel) throws Exception{ | |
97 | 98 | Configuration cfg = new Configuration(); |
98 | 99 | //String comPath = GenerateCode.class.getResource("/").getPath(); |
99 | 100 | //File f = new File(comPath+File.separator+"com"+File.separator+"taover"+File.separator+"codegenerate"+File.separator+"bazhuayun"+File.separator+"template"); |
... | ... | @@ -105,37 +106,37 @@ public class GenerateCode { |
105 | 106 | return out.toString(); |
106 | 107 | } |
107 | 108 | |
108 | - public static void generateDto(String srcPath, ApiModel apiModel) throws Exception{ | |
109 | + private static void generateDto(String srcPath, ApiModel apiModel) throws Exception{ | |
109 | 110 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
110 | 111 | String filePath = srcPath+File.separator+modelPath+File.separator+"bean"+File.separator+"dto"; |
111 | 112 | Tools.createFile(filePath, apiModel.getDtoClassSimpleName()+".java", renderByTemplate("DtoTemplate.ftl", apiModel), false); |
112 | 113 | } |
113 | 114 | |
114 | - public static void generateEntity(String srcPath, ApiModel apiModel) throws Exception{ | |
115 | + private static void generateEntity(String srcPath, ApiModel apiModel) throws Exception{ | |
115 | 116 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
116 | 117 | String filePath = srcPath+File.separator+modelPath+File.separator+"bean"+File.separator+"entity"; |
117 | 118 | Tools.createFile(filePath, apiModel.getEntityClassSimpleName()+".java", renderByTemplate("EntityTemplate.ftl", apiModel), false); |
118 | 119 | } |
119 | 120 | |
120 | - public static void generateManageController(String srcPath, ApiModel apiModel) throws Exception{ | |
121 | + private static void generateManageController(String srcPath, ApiModel apiModel) throws Exception{ | |
121 | 122 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
122 | 123 | String filePath = srcPath+File.separator+modelPath+File.separator+"controller"+File.separator+"manage"; |
123 | 124 | Tools.createFile(filePath, apiModel.getControllerClassName()+".java", renderByTemplate("ManageControllerTemplate.ftl", apiModel), false); |
124 | 125 | } |
125 | 126 | |
126 | - public static void generateV1Controller(String srcPath, ApiModel apiModel) throws Exception{ | |
127 | + private static void generateV1Controller(String srcPath, ApiModel apiModel) throws Exception{ | |
127 | 128 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
128 | 129 | String filePath = srcPath+File.separator+modelPath+File.separator+"controller"+File.separator+"v1"; |
129 | 130 | Tools.createFile(filePath, apiModel.getControllerClassName()+".java", renderByTemplate("V1ControllerTemplate.ftl", apiModel), false); |
130 | 131 | } |
131 | 132 | |
132 | - public static void generateRepository(String srcPath, ApiModel apiModel) throws Exception{ | |
133 | + private static void generateRepository(String srcPath, ApiModel apiModel) throws Exception{ | |
133 | 134 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
134 | 135 | String filePath = srcPath+File.separator+modelPath+File.separator+"repository"; |
135 | 136 | Tools.createFile(filePath, apiModel.getRepositoryClassSimpleName()+".java", renderByTemplate("RepositoryTemplate.ftl", apiModel), false); |
136 | 137 | } |
137 | 138 | |
138 | - public static void generateService(String srcPath, ApiModel apiModel) throws Exception{ | |
139 | + private static void generateService(String srcPath, ApiModel apiModel) throws Exception{ | |
139 | 140 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
140 | 141 | String filePath = srcPath+File.separator+modelPath+File.separator+"service"; |
141 | 142 | Tools.createFile(filePath, apiModel.getServiceClassSimpleName()+".java", renderByTemplate("ServiceTemplate.ftl", apiModel), false); |
... | ... | @@ -144,7 +145,7 @@ public class GenerateCode { |
144 | 145 | Tools.createFile(fileImplPath, apiModel.getServiceImplClassSimpleName()+".java", renderByTemplate("ServiceImplTemplate.ftl", apiModel), false); |
145 | 146 | } |
146 | 147 | |
147 | - public static void generateVo(String srcPath, ApiModel apiModel) throws Exception{ | |
148 | + private static void generateVo(String srcPath, ApiModel apiModel) throws Exception{ | |
148 | 149 | String modelPath = apiModel.getBasePackage().replace(".", File.separator); |
149 | 150 | String filePath = srcPath+File.separator+modelPath+File.separator+"bean"+File.separator+"vo"; |
150 | 151 | Tools.createFile(filePath, apiModel.getVoClassSimpleName()+".java", renderByTemplate("VoTemplate.ftl", apiModel), false); | ... | ... |