mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
feat(codegen): add generator path check
(cherry picked from commit 11dd892078e9b4f5dabf5df1d2c75d61df6823bd)
This commit is contained in:
1 parent
ace1e560f7
commit
b82721c293
3 files changed
+38
No files matched your search
+10
@@ -96,6 +96,16 @@ public class GeneratorController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测生成路径是否存在
|
||||
* @param path 待检测路径
|
||||
* @return true 表示路径存在且为目录
|
||||
*/
|
||||
@GetMapping("/check-path")
|
||||
public R<Boolean> checkPath(String path) {
|
||||
return R.ok(generatorService.checkPath(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览代码
|
||||
* @param tableId 表ID
|
||||
|
||||
+8
@@ -73,4 +73,12 @@ public interface GeneratorService {
|
||||
* @param tableId 表ID
|
||||
*/
|
||||
void syncRouteAndMenu(Long tableId);
|
||||
|
||||
/**
|
||||
* 检测生成路径是否为已存在目录
|
||||
*
|
||||
* @param path 待检测路径
|
||||
* @return true 表示路径存在且为目录
|
||||
*/
|
||||
boolean checkPath(String path);
|
||||
}
|
||||
+20
@@ -281,6 +281,26 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
syncRoute(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测生成路径是否为已存在目录
|
||||
*
|
||||
* @param path 待检测路径
|
||||
* @return true 表示路径存在且为目录
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPath(String path) {
|
||||
if (StrUtil.isBlank(path)) {
|
||||
throw new CheckedException("路径无效");
|
||||
}
|
||||
|
||||
String normalizedPath = FileUtil.normalize(path);
|
||||
if (StrUtil.isBlank(normalizedPath)) {
|
||||
throw new CheckedException("路径无效");
|
||||
}
|
||||
|
||||
return FileUtil.isDirectory(normalizedPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步菜单,同步按钮
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user