提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.generator.service; |
X |
2 |
|
|
3 |
import cn.hutool.core.collection.CollUtil; |
|
4 |
import cn.hutool.core.io.IoUtil; |
|
5 |
import cn.hutool.core.lang.Dict; |
|
6 |
import cn.hutool.core.util.ObjectUtil; |
|
7 |
import com.baomidou.dynamic.datasource.annotation.DS; |
|
8 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
9 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
10 |
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; |
|
11 |
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
12 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
13 |
import com.dl.common.constant.Constants; |
|
14 |
import com.dl.common.constant.GenConstants; |
|
15 |
import com.dl.common.core.domain.PageQuery; |
|
16 |
import com.dl.common.core.page.TableDataInfo; |
|
17 |
import com.dl.common.exception.ServiceException; |
|
18 |
import com.dl.common.helper.LoginHelper; |
|
19 |
import com.dl.common.utils.JsonUtils; |
|
20 |
import com.dl.common.utils.StreamUtils; |
|
21 |
import com.dl.common.utils.StringUtils; |
|
22 |
import com.dl.common.utils.file.FileUtils; |
|
23 |
import com.dl.generator.domain.GenTable; |
|
24 |
import com.dl.generator.domain.GenTableColumn; |
|
25 |
import com.dl.generator.mapper.GenTableColumnMapper; |
|
26 |
import com.dl.generator.mapper.GenTableMapper; |
|
27 |
import com.dl.generator.util.GenUtils; |
|
28 |
import com.dl.generator.util.VelocityInitializer; |
|
29 |
import com.dl.generator.util.VelocityUtils; |
|
30 |
import lombok.RequiredArgsConstructor; |
|
31 |
import lombok.extern.slf4j.Slf4j; |
|
32 |
import org.apache.velocity.Template; |
|
33 |
import org.apache.velocity.VelocityContext; |
|
34 |
import org.apache.velocity.app.Velocity; |
|
35 |
import org.springframework.stereotype.Service; |
|
36 |
import org.springframework.transaction.annotation.Transactional; |
|
37 |
|
|
38 |
import java.io.ByteArrayOutputStream; |
|
39 |
import java.io.File; |
|
40 |
import java.io.IOException; |
|
41 |
import java.io.StringWriter; |
|
42 |
import java.nio.charset.StandardCharsets; |
|
43 |
import java.util.*; |
|
44 |
import java.util.zip.ZipEntry; |
|
45 |
import java.util.zip.ZipOutputStream; |
|
46 |
|
|
47 |
/** |
|
48 |
* 业务 服务层实现 |
|
49 |
* |
|
50 |
* @author Lion Li |
|
51 |
*/ |
|
52 |
@DS("#header.datasource") |
|
53 |
@Slf4j |
|
54 |
@RequiredArgsConstructor |
|
55 |
@Service |
|
56 |
public class GenTableServiceImpl implements IGenTableService { |
|
57 |
|
|
58 |
private final GenTableMapper baseMapper; |
|
59 |
private final GenTableColumnMapper genTableColumnMapper; |
|
60 |
private final IdentifierGenerator identifierGenerator; |
|
61 |
|
|
62 |
/** |
|
63 |
* 查询业务字段列表 |
|
64 |
* |
|
65 |
* @param tableId 业务字段编号 |
|
66 |
* @return 业务字段集合 |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) { |
|
70 |
return genTableColumnMapper.selectList(new LambdaQueryWrapper<GenTableColumn>() |
|
71 |
.eq(GenTableColumn::getTableId, tableId) |
|
72 |
.orderByAsc(GenTableColumn::getSort)); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* 查询业务信息 |
|
77 |
* |
|
78 |
* @param id 业务ID |
|
79 |
* @return 业务信息 |
|
80 |
*/ |
|
81 |
@Override |
|
82 |
public GenTable selectGenTableById(Long id) { |
|
83 |
GenTable genTable = baseMapper.selectGenTableById(id); |
|
84 |
setTableFromOptions(genTable); |
|
85 |
return genTable; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) { |
|
90 |
Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable)); |
|
91 |
return TableDataInfo.build(page); |
|
92 |
} |
|
93 |
|
|
94 |
private QueryWrapper<GenTable> buildGenTableQueryWrapper(GenTable genTable) { |
|
95 |
Map<String, Object> params = genTable.getParams(); |
|
96 |
QueryWrapper<GenTable> wrapper = Wrappers.query(); |
|
97 |
wrapper.like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName())) |
|
98 |
.like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment())) |
|
99 |
.between(params.get("beginTime") != null && params.get("endTime") != null, |
|
100 |
"create_time", params.get("beginTime"), params.get("endTime")); |
|
101 |
return wrapper; |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
@Override |
|
106 |
public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) { |
|
107 |
Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable); |
|
108 |
return TableDataInfo.build(page); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* 查询据库列表 |
|
113 |
* |
|
114 |
* @param tableNames 表名称组 |
|
115 |
* @return 数据库表集合 |
|
116 |
*/ |
|
117 |
@Override |
|
118 |
public List<GenTable> selectDbTableListByNames(String[] tableNames) { |
|
119 |
return baseMapper.selectDbTableListByNames(tableNames); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* 查询所有表信息 |
|
124 |
* |
|
125 |
* @return 表信息集合 |
|
126 |
*/ |
|
127 |
@Override |
|
128 |
public List<GenTable> selectGenTableAll() { |
|
129 |
return baseMapper.selectGenTableAll(); |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* 修改业务 |
|
134 |
* |
|
135 |
* @param genTable 业务信息 |
|
136 |
* @return 结果 |
|
137 |
*/ |
|
138 |
@Transactional(rollbackFor = Exception.class) |
|
139 |
@Override |
|
140 |
public void updateGenTable(GenTable genTable) { |
|
141 |
String options = JsonUtils.toJsonString(genTable.getParams()); |
|
142 |
genTable.setOptions(options); |
|
143 |
int row = baseMapper.updateById(genTable); |
|
144 |
if (row > 0) { |
|
145 |
for (GenTableColumn cenTableColumn : genTable.getColumns()) { |
|
146 |
genTableColumnMapper.updateById(cenTableColumn); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* 删除业务对象 |
|
153 |
* |
|
154 |
* @param tableIds 需要删除的数据ID |
|
155 |
* @return 结果 |
|
156 |
*/ |
|
157 |
@Transactional(rollbackFor = Exception.class) |
|
158 |
@Override |
|
159 |
public void deleteGenTableByIds(Long[] tableIds) { |
|
160 |
List<Long> ids = Arrays.asList(tableIds); |
|
161 |
baseMapper.deleteBatchIds(ids); |
|
162 |
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids)); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* 导入表结构 |
|
167 |
* |
|
168 |
* @param tableList 导入表列表 |
|
169 |
*/ |
|
170 |
@Transactional(rollbackFor = Exception.class) |
|
171 |
@Override |
|
172 |
public void importGenTable(List<GenTable> tableList) { |
|
173 |
String operName = LoginHelper.getUsername(); |
|
174 |
try { |
|
175 |
for (GenTable table : tableList) { |
|
176 |
String tableName = table.getTableName(); |
|
177 |
GenUtils.initTable(table, operName); |
|
178 |
int row = baseMapper.insert(table); |
|
179 |
if (row > 0) { |
|
180 |
// 保存列信息 |
|
181 |
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
|
182 |
List<GenTableColumn> saveColumns = new ArrayList<>(); |
|
183 |
for (GenTableColumn column : genTableColumns) { |
|
184 |
GenUtils.initColumnField(column, table); |
|
185 |
saveColumns.add(column); |
|
186 |
} |
|
187 |
if (CollUtil.isNotEmpty(saveColumns)) { |
|
188 |
genTableColumnMapper.insertBatch(saveColumns); |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
} catch (Exception e) { |
|
193 |
throw new ServiceException("导入失败:" + e.getMessage()); |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* 预览代码 |
|
199 |
* |
|
200 |
* @param tableId 表编号 |
|
201 |
* @return 预览数据列表 |
|
202 |
*/ |
|
203 |
@Override |
|
204 |
public Map<String, String> previewCode(Long tableId) { |
|
205 |
Map<String, String> dataMap = new LinkedHashMap<>(); |
|
206 |
// 查询表信息 |
|
207 |
GenTable table = baseMapper.selectGenTableById(tableId); |
|
208 |
List<Long> menuIds = new ArrayList<>(); |
|
209 |
for (int i = 0; i < 6; i++) { |
|
210 |
menuIds.add(identifierGenerator.nextId(null).longValue()); |
|
211 |
} |
|
212 |
table.setMenuIds(menuIds); |
|
213 |
// 设置主子表信息 |
|
214 |
setSubTable(table); |
|
215 |
// 设置主键列信息 |
|
216 |
setPkColumn(table); |
|
217 |
VelocityInitializer.initVelocity(); |
|
218 |
|
|
219 |
VelocityContext context = VelocityUtils.prepareContext(table); |
|
220 |
|
|
221 |
// 获取模板列表 |
|
222 |
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
|
223 |
for (String template : templates) { |
|
224 |
// 渲染模板 |
|
225 |
StringWriter sw = new StringWriter(); |
|
226 |
Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
|
227 |
tpl.merge(context, sw); |
|
228 |
dataMap.put(template, sw.toString()); |
|
229 |
} |
|
230 |
return dataMap; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* 生成代码(下载方式) |
|
235 |
* |
|
236 |
* @param tableName 表名称 |
|
237 |
* @return 数据 |
|
238 |
*/ |
|
239 |
@Override |
|
240 |
public byte[] downloadCode(String tableName) { |
|
241 |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
242 |
ZipOutputStream zip = new ZipOutputStream(outputStream); |
|
243 |
generatorCode(tableName, zip); |
|
244 |
IoUtil.close(zip); |
|
245 |
return outputStream.toByteArray(); |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* 生成代码(自定义路径) |
|
250 |
* |
|
251 |
* @param tableName 表名称 |
|
252 |
*/ |
|
253 |
@Override |
|
254 |
public void generatorCode(String tableName) { |
|
255 |
// 查询表信息 |
|
256 |
GenTable table = baseMapper.selectGenTableByName(tableName); |
|
257 |
// 设置主子表信息 |
|
258 |
setSubTable(table); |
|
259 |
// 设置主键列信息 |
|
260 |
setPkColumn(table); |
|
261 |
|
|
262 |
VelocityInitializer.initVelocity(); |
|
263 |
|
|
264 |
VelocityContext context = VelocityUtils.prepareContext(table); |
|
265 |
|
|
266 |
// 获取模板列表 |
|
267 |
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
|
268 |
for (String template : templates) { |
|
269 |
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { |
|
270 |
// 渲染模板 |
|
271 |
StringWriter sw = new StringWriter(); |
|
272 |
Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
|
273 |
tpl.merge(context, sw); |
|
274 |
try { |
|
275 |
String path = getGenPath(table, template); |
|
276 |
FileUtils.writeUtf8String(sw.toString(), path); |
|
277 |
} catch (Exception e) { |
|
278 |
throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); |
|
279 |
} |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
/** |
|
285 |
* 同步数据库 |
|
286 |
* |
|
287 |
* @param tableName 表名称 |
|
288 |
*/ |
|
289 |
@Transactional(rollbackFor = Exception.class) |
|
290 |
@Override |
|
291 |
public void synchDb(String tableName) { |
|
292 |
GenTable table = baseMapper.selectGenTableByName(tableName); |
|
293 |
List<GenTableColumn> tableColumns = table.getColumns(); |
|
294 |
Map<String, GenTableColumn> tableColumnMap = StreamUtils.toIdentityMap(tableColumns, GenTableColumn::getColumnName); |
|
295 |
|
|
296 |
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
|
297 |
if (CollUtil.isEmpty(dbTableColumns)) { |
|
298 |
throw new ServiceException("同步数据失败,原表结构不存在"); |
|
299 |
} |
|
300 |
List<String> dbTableColumnNames = StreamUtils.toList(dbTableColumns, GenTableColumn::getColumnName); |
|
301 |
|
|
302 |
List<GenTableColumn> saveColumns = new ArrayList<>(); |
|
303 |
dbTableColumns.forEach(column -> { |
|
304 |
GenUtils.initColumnField(column, table); |
|
305 |
if (tableColumnMap.containsKey(column.getColumnName())) { |
|
306 |
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); |
|
307 |
column.setColumnId(prevColumn.getColumnId()); |
|
308 |
if (column.isList()) { |
|
309 |
// 如果是列表,继续保留查询方式/字典类型选项 |
|
310 |
column.setDictType(prevColumn.getDictType()); |
|
311 |
column.setQueryType(prevColumn.getQueryType()); |
|
312 |
} |
|
313 |
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk() |
|
314 |
&& (column.isInsert() || column.isEdit()) |
|
315 |
&& ((column.isUsableColumn()) || (!column.isSuperColumn()))) { |
|
316 |
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项 |
|
317 |
column.setIsRequired(prevColumn.getIsRequired()); |
|
318 |
column.setHtmlType(prevColumn.getHtmlType()); |
|
319 |
} |
|
320 |
} |
|
321 |
saveColumns.add(column); |
|
322 |
}); |
|
323 |
if (CollUtil.isNotEmpty(saveColumns)) { |
|
324 |
genTableColumnMapper.insertOrUpdateBatch(saveColumns); |
|
325 |
} |
|
326 |
List<GenTableColumn> delColumns = StreamUtils.filter(tableColumns, column -> !dbTableColumnNames.contains(column.getColumnName())); |
|
327 |
if (CollUtil.isNotEmpty(delColumns)) { |
|
328 |
List<Long> ids = StreamUtils.toList(delColumns, GenTableColumn::getColumnId); |
|
329 |
genTableColumnMapper.deleteBatchIds(ids); |
|
330 |
} |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* 批量生成代码(下载方式) |
|
335 |
* |
|
336 |
* @param tableNames 表数组 |
|
337 |
* @return 数据 |
|
338 |
*/ |
|
339 |
@Override |
|
340 |
public byte[] downloadCode(String[] tableNames) { |
|
341 |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
342 |
ZipOutputStream zip = new ZipOutputStream(outputStream); |
|
343 |
for (String tableName : tableNames) { |
|
344 |
generatorCode(tableName, zip); |
|
345 |
} |
|
346 |
IoUtil.close(zip); |
|
347 |
return outputStream.toByteArray(); |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* 查询表信息并生成代码 |
|
352 |
*/ |
|
353 |
private void generatorCode(String tableName, ZipOutputStream zip) { |
|
354 |
// 查询表信息 |
|
355 |
GenTable table = baseMapper.selectGenTableByName(tableName); |
|
356 |
List<Long> menuIds = new ArrayList<>(); |
|
357 |
for (int i = 0; i < 6; i++) { |
|
358 |
menuIds.add(identifierGenerator.nextId(null).longValue()); |
|
359 |
} |
|
360 |
table.setMenuIds(menuIds); |
|
361 |
// 设置主子表信息 |
|
362 |
setSubTable(table); |
|
363 |
// 设置主键列信息 |
|
364 |
setPkColumn(table); |
|
365 |
|
|
366 |
VelocityInitializer.initVelocity(); |
|
367 |
|
|
368 |
VelocityContext context = VelocityUtils.prepareContext(table); |
|
369 |
|
|
370 |
// 获取模板列表 |
|
371 |
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
|
372 |
for (String template : templates) { |
|
373 |
// 渲染模板 |
|
374 |
StringWriter sw = new StringWriter(); |
|
375 |
Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
|
376 |
tpl.merge(context, sw); |
|
377 |
try { |
|
378 |
// 添加到zip |
|
379 |
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); |
|
380 |
IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); |
|
381 |
IoUtil.close(sw); |
|
382 |
zip.flush(); |
|
383 |
zip.closeEntry(); |
|
384 |
} catch (IOException e) { |
|
385 |
log.error("渲染模板失败,表名:" + table.getTableName(), e); |
|
386 |
} |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
/** |
|
391 |
* 修改保存参数校验 |
|
392 |
* |
|
393 |
* @param genTable 业务信息 |
|
394 |
*/ |
|
395 |
@Override |
|
396 |
public void validateEdit(GenTable genTable) { |
|
397 |
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { |
|
398 |
String options = JsonUtils.toJsonString(genTable.getParams()); |
|
399 |
Dict paramsObj = JsonUtils.parseMap(options); |
|
400 |
if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_CODE))) { |
|
401 |
throw new ServiceException("树编码字段不能为空"); |
|
402 |
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_PARENT_CODE))) { |
|
403 |
throw new ServiceException("树父编码字段不能为空"); |
|
404 |
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_NAME))) { |
|
405 |
throw new ServiceException("树名称字段不能为空"); |
|
406 |
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { |
|
407 |
if (StringUtils.isEmpty(genTable.getSubTableName())) { |
|
408 |
throw new ServiceException("关联子表的表名不能为空"); |
|
409 |
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { |
|
410 |
throw new ServiceException("子表关联的外键名不能为空"); |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* 设置主键列信息 |
|
418 |
* |
|
419 |
* @param table 业务表信息 |
|
420 |
*/ |
|
421 |
public void setPkColumn(GenTable table) { |
|
422 |
for (GenTableColumn column : table.getColumns()) { |
|
423 |
if (column.isPk()) { |
|
424 |
table.setPkColumn(column); |
|
425 |
break; |
|
426 |
} |
|
427 |
} |
|
428 |
if (ObjectUtil.isNull(table.getPkColumn())) { |
|
429 |
table.setPkColumn(table.getColumns().get(0)); |
|
430 |
} |
|
431 |
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) { |
|
432 |
for (GenTableColumn column : table.getSubTable().getColumns()) { |
|
433 |
if (column.isPk()) { |
|
434 |
table.getSubTable().setPkColumn(column); |
|
435 |
break; |
|
436 |
} |
|
437 |
} |
|
438 |
if (ObjectUtil.isNull(table.getSubTable().getPkColumn())) { |
|
439 |
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); |
|
440 |
} |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
444 |
/** |
|
445 |
* 设置主子表信息 |
|
446 |
* |
|
447 |
* @param table 业务表信息 |
|
448 |
*/ |
|
449 |
public void setSubTable(GenTable table) { |
|
450 |
String subTableName = table.getSubTableName(); |
|
451 |
if (StringUtils.isNotEmpty(subTableName)) { |
|
452 |
table.setSubTable(baseMapper.selectGenTableByName(subTableName)); |
|
453 |
} |
|
454 |
} |
|
455 |
|
|
456 |
/** |
|
457 |
* 设置代码生成其他选项值 |
|
458 |
* |
|
459 |
* @param genTable 设置后的生成对象 |
|
460 |
*/ |
|
461 |
public void setTableFromOptions(GenTable genTable) { |
|
462 |
Dict paramsObj = JsonUtils.parseMap(genTable.getOptions()); |
|
463 |
if (ObjectUtil.isNotNull(paramsObj)) { |
|
464 |
String treeCode = paramsObj.getStr(GenConstants.TREE_CODE); |
|
465 |
String treeParentCode = paramsObj.getStr(GenConstants.TREE_PARENT_CODE); |
|
466 |
String treeName = paramsObj.getStr(GenConstants.TREE_NAME); |
|
467 |
String parentMenuId = paramsObj.getStr(GenConstants.PARENT_MENU_ID); |
|
468 |
String parentMenuName = paramsObj.getStr(GenConstants.PARENT_MENU_NAME); |
|
469 |
|
|
470 |
genTable.setTreeCode(treeCode); |
|
471 |
genTable.setTreeParentCode(treeParentCode); |
|
472 |
genTable.setTreeName(treeName); |
|
473 |
genTable.setParentMenuId(parentMenuId); |
|
474 |
genTable.setParentMenuName(parentMenuName); |
|
475 |
} |
|
476 |
} |
|
477 |
|
|
478 |
/** |
|
479 |
* 获取代码生成地址 |
|
480 |
* |
|
481 |
* @param table 业务表信息 |
|
482 |
* @param template 模板文件路径 |
|
483 |
* @return 生成地址 |
|
484 |
*/ |
|
485 |
public static String getGenPath(GenTable table, String template) { |
|
486 |
String genPath = table.getGenPath(); |
|
487 |
if (StringUtils.equals(genPath, "/")) { |
|
488 |
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); |
|
489 |
} |
|
490 |
return genPath + File.separator + VelocityUtils.getFileName(template, table); |
|
491 |
} |
|
492 |
} |
|
493 |
|