Commit 978bedb1 authored by xiandafu's avatar xiandafu
Browse files

codeapi

parent 22fd034d
......@@ -10,6 +10,8 @@ public class MavenProjectTarget extends BaseTarget {
Entity entity;
String basePackage;
String basePackagePath = null;
String targetPath = null;
public MavenProjectTarget(Entity entity,String basePackage) {
this.entity = entity;
this.basePackage = basePackage;
......@@ -77,24 +79,42 @@ public class MavenProjectTarget extends BaseTarget {
}
private static String getSrcPath() {
public String getTargetPath() {
return targetPath;
}
public void setTargetPath(String targetPath) {
this.targetPath = targetPath;
}
private String getSrcPath() {
return getRootPath() + File.separator + "src/main/java";
}
private static String getResourcePath() {
private String getResourcePath() {
return getRootPath() + File.separator + "src/main/resources";
}
private static String getRootPath() {
String srcPath;
String userDir = System.getProperty("user.dir");
if (userDir == null) {
throw new NullPointerException("用户目录未找到");
}
public String getRootPath() {
if(targetPath!=null) {
return targetPath;
}else {
return detectRootPath();
}
}
public static String detectRootPath() {
String srcPath;
String userDir = System.getProperty("user.dir");
if (userDir == null) {
throw new NullPointerException("用户目录未找到");
}
return userDir;
return userDir;
}
}
......@@ -72,7 +72,7 @@ public class CoreCodeGenController {
@PostMapping(MODEL + "/gen.json")
@ResponseBody
public JsonResult gen(EntityInfo data) {
public JsonResult gen(EntityInfo data,String path) {
Entity info = data.getEntity();
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
......@@ -89,6 +89,8 @@ public class CoreCodeGenController {
return JsonResult.failMessage("code,system不能为空");
}
MavenProjectTarget target = new MavenProjectTarget(entity, basePackage);
//生成到path目录下,按照maven工程解构生成
target.setTargetPath(path);
target.setUrlBase(urlBase);
JSGen jsGen = new JSGen();
......@@ -105,6 +107,13 @@ public class CoreCodeGenController {
return JsonResult.success();
}
@PostMapping(MODEL + "/getPath.json")
@ResponseBody
public JsonResult<String> getPath() {
String path = MavenProjectTarget.detectRootPath();
return JsonResult.success(path);
}
@PostMapping(MODEL + "/html.json")
@ResponseBody
......
......@@ -5,16 +5,6 @@ Date.prototype.format=function(format){var d=this,o={"M+":d.getMonth()+1,"d+":d.
var Common = {
ctxPath: "",
version:"",
confirm: function (tip, ensure) {
parent.layer.confirm(tip, {
btn: ['确定', '取消']
}, function (index) {
ensure();
parent.layer.close(index);
}, function (index) {
parent.layer.close(index);
});
},
log: function (info) {
console.log(info);
},
......@@ -97,6 +87,12 @@ var Common = {
});
},
openPrompt:function(title,defaultValue,callback){
layer.prompt({title: title, formType: 0,value:defaultValue}, function(value, index,elem){
layer.close(index);
callback(value);
});
},
concatBatchId:function(data,idField){
var ids = ""
var name=idField==null?"id":idField;
......
......@@ -2,7 +2,12 @@
layui.define([], function(exports) {
var api={
gen:function(callback){
Lib.submitForm($('#updateForm'),{},callback)
Common.post("/core/codeGen/getPath.json", {}, function(path){
Common.openPrompt("代码保存路径?",path,function(){
var url ="/core/codeGen/gen.json"
Lib.submitForm(url,$('#updateForm'),{path:path},callback)
})
});
},
previewHtml:function(callback){
var form = $('#updateForm');
......@@ -24,6 +29,7 @@ layui.define([], function(exports) {
var formPara = form.serializeJson();
Common.post("/core/codeGen/sql.json", formPara, callback);
}
};
......
......@@ -192,18 +192,13 @@ var Lib = {
var index = parent.layer.getFrameIndex(window.name); // 先得到当前iframe层的索引
parent.layer.close(index); // 再执行关闭
},
/*不再使用,因为没有提供url*/
submitForm : function(form, paras, callBack) {
var url = form.attr("action");
var formPara = form.serializeJson();
Common.post(url, formPara, callBack);
},
submitForm : function(url,form, paras, callBack) {
var formPara = form.serializeJson();
for (var key in paras) {
formPara[key]=paras[key];
}
Common.post(url, formPara, callBack);
},
getTableHeight : function(queryLine) {
// 表格相对高度
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment