提交 8ddae51c 编写于 作者: Skyeye云's avatar Skyeye云

代码生成器完成

上级 e9ee4c71
......@@ -214,7 +214,11 @@ public class CommonServiceImpl implements CommonService{
JSONObject object = (JSONObject) array.get(i);
//加入压缩包
ByteArrayInputStream stream = new ByteArrayInputStream(object.getString("content").getBytes());
out.putNextEntry(new ZipEntry(object.getString("fileName") + "." + object.getString("modelType").toLowerCase()));
if("javascript".equals(object.getString("modelType").toLowerCase())){
out.putNextEntry(new ZipEntry(object.getString("fileName") + ".js"));
}else{
out.putNextEntry(new ZipEntry(object.getString("fileName") + "." + object.getString("modelType").toLowerCase()));
}
int len;
// 读入需要下载的文件的内容,打包到zip文件
while ((len = stream.read(buffer)) > 0) {
......@@ -229,7 +233,11 @@ public class CommonServiceImpl implements CommonService{
bean.put("content", object.getString("content"));
bean.put("createId", user.get("id"));
bean.put("fileName", object.getString("fileName"));
bean.put("fileType", object.getString("modelType").toLowerCase());
if("javascript".equals(object.getString("modelType").toLowerCase())){
bean.put("fileType", "js");
}else{
bean.put("fileType", object.getString("modelType").toLowerCase());
}
bean.put("filePath", zipName);
bean.put("createTime", ToolUtil.getTimeAndToString());
inBeans.add(bean);
......
......@@ -41,6 +41,8 @@ layui.config({
var subData = list;
if(subData.length == 0){
top.winui.window.msg('请先生成转换结果', {icon: 2,time: 2000});
}else if($('#modelList').find('li').length > subData.length){
top.winui.window.msg('您有模板未生成代码文件,请检查。', {icon: 2,time: 2000});
}else{
for(var i = 0; i < subData.length; i++){
subData[i].modelContent = "";
......@@ -94,6 +96,45 @@ layui.config({
}
});
var showCreateHtmlMation = CodeMirror.fromTextArea(document.getElementById("showCreateHtmlMation"), {
mode : "xml", // 模式
theme : "eclipse", // CSS样式选择
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : false, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
});
var showCreateRequireMation = CodeMirror.fromTextArea(document.getElementById("showCreateRequireMation"), {
mode : "xml", // 模式
theme : "eclipse", // CSS样式选择
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : false, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
});
var showCreateJsMation = CodeMirror.fromTextArea(document.getElementById("showCreateJsMation"), {
mode : "text/javascript", // 模式
theme : "eclipse", // CSS样式选择
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : false, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
});
//加载模块
showGrid({
id: "modelList",
......@@ -197,7 +238,9 @@ layui.config({
pageId: "addcontenttohtmlorjs",
callBack: function(refreshCode){
if (refreshCode == '0') {
console.log(result);
showCreateHtmlMation.setValue(result.htmlContent);
showCreateRequireMation.setValue("前端限制参数:" + result.formermation + "\n后端限制参数:" + result.aftermation);
showCreateJsMation.setValue(result.jsContent);
} else if (refreshCode == '-9999') {
top.winui.window.msg("操作失败", {icon: 2,time: 2000});
}
......
......@@ -96,7 +96,7 @@
<div class="winui-toolbar">
<div class="winui-tool">参数设置(最终保存内容)<button type="button" class="layui-btn layui-btn-xs" style="float: right;" id="addContentToHTMLorJS">添加参数</button></div>
</div>
<div class="layui-row" style="height: 100%">
<div class="layui-row" style="height: calc(100vh - 75px);">
<textarea id="textContent"></textarea>
</div>
</div>
......@@ -111,11 +111,31 @@
</table>
</div>
</div>
<div class="layui-row" style="height: 120px">
<div class="winui-toolbar">
<div class="winui-tool">请求链接</div>
</div>
<div class="layui-row" style="height: 150px">
<div class="layui-col-xs3 left-menu">
<div class="winui-toolbar">
<div class="winui-tool">限制条件</div>
</div>
<div class="layui-row" style="height: calc(42vh - 85px);">
<textarea id="showCreateRequireMation"></textarea>
</div>
</div>
<div class="layui-col-xs6 center-content">
<div class="winui-toolbar">
<div class="winui-tool">html代码</div>
</div>
<div class="layui-row" style="height: calc(42vh - 85px);">
<textarea id="showCreateHtmlMation"></textarea>
</div>
</div>
<div class="layui-col-xs3 right-menu">
<div class="winui-toolbar">
<div class="winui-tool">js代码</div>
</div>
<div class="layui-row" style="height: calc(42vh - 85px);">
<textarea id="showCreateJsMation"></textarea>
</div>
</div>
</div>
<div class="layui-row" style="height: 50px;text-align: center;">
<div class="layui-inline">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册