提交 53b98034 编写于 作者: Skyeye云's avatar Skyeye云

添加表备注

上级 30889047
......@@ -27,4 +27,6 @@ public interface CodeModelGroupDao {
public List<Map<String, Object>> queryCodeModelListByGroupId(Map<String, Object> map) throws Exception;
public Map<String, Object> queryTableBzByTableName(Map<String, Object> map) throws Exception;
}
......@@ -172,10 +172,16 @@ public class CodeModelGroupServiceImpl implements CodeModelGroupService{
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = new HashMap<>();
String tableName = ToolUtil.replaceUnderLineAndUpperCase(map.get("tableName").toString());
map.put("dbName", dbName);
Map<String, Object> tableBz = codeModelGroupDao.queryTableBzByTableName(map);
//表备注
bean.put("tableBzName", tableBz.get("tableComment"));
//将表名转化为Controller名
bean.put("tableName", tableName);
//表名首字母小写
bean.put("tableFirstISlowerName", ToolUtil.toLowerCaseFirstOne(tableName));
//表名全部小写
bean.put("tableISlowerName", tableName.toLowerCase());
//包名
bean.put("ControllerPackageName", "com.skyeye." + tableName.toLowerCase() + ".controller" );
bean.put("ServicePackageName", "com.skyeye." + tableName.toLowerCase() + ".service" );
......
......@@ -121,4 +121,26 @@
ORDER BY a.create_time DESC
</select>
<select id="queryTableBzByTableName" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.TABLE_SCHEMA AS tableSchema,
a.TABLE_NAME AS tableName,
a.COLUMN_NAME AS columnName,
a.ORDINAL_POSITION AS ordinalPosition,
a.COLUMN_DEFAULT AS columnDefault,
a.IS_NULLABLE AS isNullable,
a.COLUMN_TYPE AS columnType,
a.COLUMN_COMMENT AS columnComment,
a.COLUMN_KEY AS columnKey,
a.EXTRA AS extra,
b.TABLE_COMMENT AS tableComment
FROM
information_schema.COLUMNS a
LEFT JOIN information_schema.TABLES b ON a.TABLE_NAME = b.TABLE_NAME
WHERE
a.TABLE_SCHEMA = #{dbName}
AND a.TABLE_NAME = #{tableName}
GROUP BY a.TABLE_NAME
</select>
</mapper>
\ No newline at end of file
......@@ -911,5 +911,21 @@ function returnModel(lang){
return mode;
}
/**
* 替换代码生成器模板内容
* @param str
*/
function replaceModelContent(str, ControllerPackageName, ServicePackageName, ServiceImplPackageName,
DaoPackageName, tableZhName, tableFirstISlowerName, tableISlowerName, tableBzName){
str = str.replace(/[$]{{controllerPackage}}/g, ControllerPackageName);
str = str.replace(/[$]{{servicePackage}}/g, ServicePackageName);
str = str.replace(/[$]{{serviceImplPackage}}/g, ServiceImplPackageName);
str = str.replace(/[$]{{daoPackage}}/g, DaoPackageName);
str = str.replace(/[$]{{tableName}}/g, tableZhName);
str = str.replace(/[$]{{objectName}}/g, tableFirstISlowerName);
str = str.replace(/[$]{{urlName}}/g, tableISlowerName);
str = str.replace(/[$]{{notesName}}/g, tableBzName);
return str;
}
......@@ -41,7 +41,7 @@ layui.config({
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : false, // 是否只读,默认false
readOnly : true, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
......
......@@ -12,6 +12,18 @@ layui.config({
form = layui.form,
table = layui.table;
var jsCreateClick = false;//是否检索生成
var list = [];//存储模板生成集合
//集合内容
//var s = {
// modelId:模板id,
// content:当前内容,
// tableName:表名,
// groupId:模板所属分组id
// modelName:模板别名
//}
form.render();
form.on('submit(formSearch)', function (data) {
//表单验证
......@@ -27,7 +39,20 @@ layui.config({
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : false, // 是否只读,默认false
readOnly : true, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
});
var textEditor = CodeMirror.fromTextArea(document.getElementById("textContent"), {
mode : "text/x-java", // 模式
theme : "eclipse", // CSS样式选择
indentUnit : 2, // 缩进单位,默认2
smartIndent : true, // 是否智能缩进
tabSize : 4, // Tab缩进,默认4
readOnly : true, // 是否只读,默认false
showCursorWhenSelecting : true,
lineNumbers : true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
......@@ -47,7 +72,7 @@ layui.config({
'click .selModel':function(index, row){//查看模板
var mode = returnModel(row.modelType);
if (!isNull(mode.length)) {
editor.setOption('mode', mode)
editor.setOption('mode', mode);
}
editor.setValue(row.modelContent);
layer.open({
......@@ -60,8 +85,36 @@ layui.config({
});
},
'click .selResult':function(index, row){//查看转换结果
if(jsCreateClick){
var mode = returnModel(row.modelType);
if (!isNull(mode.length)) {
textEditor.setOption('mode', mode);
}
textEditor.setOption('readOnly', false);
textEditor.setValue(row.modelContent);
}else{
top.winui.window.msg('请先选择数据库表名检索生成', {icon: 2,time: 2000});
}
},
'click .createResult':function(index, row){//转换结果
if(jsCreateClick){
var content = replaceModelContent(row.modelContent, $("#ControllerPackageName").val(), $("#ServicePackageName").val(),
$("#ServiceImplPackageName").val(), $("#DaoPackageName").val(), $("#tableZhName").val(),
$("#tableFirstISlowerName").val(), $("#tableISlowerName").val(), $("#tableBzName").val());
var s = {
modelId: row.id,
content: content,
tableName: $("#tableName").val(),
groupId: parent.rowId,
modelName: row.modelName
};
insertListIn(list, s);
top.winui.window.msg('转换成功', {icon: 1,time: 2000});
console.log(list);
}else{
top.winui.window.msg('请先选择数据库表名检索生成', {icon: 2,time: 2000});
}
}
},
ajaxSendAfter:function(json){
}
......@@ -81,6 +134,13 @@ layui.config({
}
});
//转换结果效果切换
$("body").on("click", ".createResult", function(e){
if(jsCreateClick){
$(this).addClass("layui-btn-normal");
}
});
//检索生成
$("body").on("click", "#jsCreate", function(e){
showGrid({
......@@ -94,18 +154,23 @@ layui.config({
ajaxSendAfter:function(json){
AjaxPostUtil.request({url:reqBasePath + "codemodel012", params:{tableName: $("#tableName").val()}, type:'json', callback:function(json){
if(json.returnCode == 0){
$(".createResult").removeClass("layui-btn-normal");
jsCreateClick = true;
list = [];
$("#tableZhName").val(json.bean.tableName);
$("#tableFirstISlowerName").val(json.bean.tableFirstISlowerName);
$("#ControllerPackageName").val(json.bean.ControllerPackageName);
$("#ServicePackageName").val(json.bean.ServicePackageName);
$("#ServiceImplPackageName").val(json.bean.ServiceImplPackageName);
$("#DaoPackageName").val(json.bean.DaoPackageName);
$("#tableISlowerName").val(json.bean.tableISlowerName);
$("#tableBzName").val(json.bean.tableBzName);
//遍历模板
$('#modelList').find('li').each(function() {
var label = $(this).find("label");
$("#" + label.attr("relation")).val(json.bean.tableName + label.attr("thiscontent"));
});
top.winui.window.msg('检索成功', {icon: 1,time: 2000});
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
......@@ -114,5 +179,22 @@ layui.config({
});
});
/**
* 向集合中添加新元素
*/
function insertListIn(list, s){
var isIn = false;
for(var i = 0; i < list.length; i++){
if(list[i].modelId == s.modelId){
list[i].content = s.content;
isIn = true;
break;
}
}
if(!isIn){//不存在
list.push(s);
}
}
exports('usemodelgroup', {});
});
......@@ -85,6 +85,7 @@
5.${{tableName}}为Controller、Service等层的类名,类方法。<br>
6.${{objectName}}为对象名<br>
7.${{notesName}}为注释对象名<br>
8.${{urlName}}为请求链接对象名<br>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
......
......@@ -26,6 +26,7 @@
5.${{tableName}}为Controller、Service等层的类名,类方法。<br>
6.${{objectName}}为对象名<br>
7.${{notesName}}为注释对象名<br>
8.${{urlName}}为请求链接对象名<br>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
......
......@@ -25,7 +25,7 @@
</div>
</div>
</div>
<div class="txtcenter" style="width:1200px;margin:0 auto;">
<div class="txtcenter" style="width:1500px;margin:0 auto;">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">类、方法名</label>
......@@ -39,6 +39,18 @@
<input type="text" id="tableFirstISlowerName" name="tableFirstISlowerName" win-verify="required" placeholder="请选择数据库表检所生成" class="layui-input" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">URL请求对象名</label>
<div class="layui-input-inline">
<input type="text" id="tableISlowerName" name="tableISlowerName" win-verify="required" placeholder="请选择数据库表检所生成" class="layui-input" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">表备注</label>
<div class="layui-input-inline">
<input type="text" id="tableBzName" name="tableBzName" win-verify="required" placeholder="请选择数据库表检所生成" class="layui-input" />
</div>
</div>
</div>
</div>
<div class="txtcenter" style="width:1500px;margin:0 auto;">
......@@ -84,7 +96,9 @@
<div class="winui-toolbar">
<div class="winui-tool">参数设置</div>
</div>
<div class="layui-row" style="height: 100%">
<textarea id="textContent"></textarea>
</div>
</div>
<div class="layui-col-xs3 right-menu">
<div class="winui-toolbar">
......
{{#each rows}}
<li class="page-li">
<div class="weui-flex js_category layui-col-xs8 padd-le-ri">
<div class="weui-flex js_category layui-col-xs7 padd-le-ri">
<div>
<label class="layui-form-label" relation="{{id}}" thiscontent="{{modelName}}">{{modelName}}<i class="red">*</i></label>
<div class="layui-input-block">
......@@ -8,9 +8,10 @@
</div>
</div>
</div>
<div class="weui-flex js_category layui-col-xs4 right">
<div class="weui-flex js_category layui-col-xs5 right">
<button class="layui-btn layui-btn-sm tab-btn-mar-left-3 selModel" title="查看模板" type="button"><i class="fa fa-files-o"></i></button>
<button class="layui-btn layui-btn-sm tab-btn-mar-left-3 selResult" title="查看转换结果" type="button"><i class="fa fa-pencil-square-o"></i></button>
<button class="layui-btn layui-btn-sm tab-btn-mar-left-3 createResult" title="转换结果" type="button"><i class="fa fa-clipboard"></i></button>
</div>
</li>
{{/each}}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册