Commit a3d6c501b97301d71815abaf35237298b4ed4a4d

Authored by 王彬
1 parent 9cc440ee
Exists in master

1.新提交

src/bazhuaerp.default.properties 0 → 100644
@@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
  1 +#顶层po、dao文件生成总目录
  2 +OutputPath=\\D:\\workproject\\bazhuaerp\\src\\main\\java\\com\\bazhuaerp\\db\\
  3 +#OutputPath=\\C:\\workproject\\printer-taover-com\\src\\com\\taover\\printer\\db\\
  4 +#数据库名
  5 +SchameName=bazhuaerp
  6 +#SchameName=taoverprinter
  7 +CreateSchame=false
  8 +#TableName=erp_shop,erp_warehouse,erp_express_template,erp_goods_express,erp_order,erp_order_goods,erp_order_statistics,erp_orderstat_goods,erp_distribution,erp_delivery,erp_delivery_goods,erp_delivery_statistics,erp_deliverystat_goods
  9 +TableName=ALL
  10 +#数据库库连接信息
  11 +User=tylife
  12 +Password=lexi365
  13 +#Password=qwe123!@#
  14 +DBLikeStr=%
  15 +#数据库驱动类型
  16 +driver=com.mysql.jdbc.Driver
  17 +#数据库连接url
  18 +URL=jdbc\:mysql\://127.0.0.1\:3306/bazhuaerp
  19 +#URL=jdbc\:mysql\://localhost\:3306/taoverprinter
  20 +#数据库类型
  21 +dbtype=mysql
  22 +#数据库顶层包名
  23 +#packageName=com.taover.printer.db
  24 +packageName=com.bazhuaerp.db
  25 +
  26 +#-----------------------------
  27 +# 生成 Controller和Service所需参数 -
  28 +#-----------------------------
  29 +coverWhenFileExists=false
  30 +#模块包全名,controller、service包名都会由此生成
  31 +modulePackageInfo=com.bazhuaerp
  32 +
  33 +#模块本地文件夹路径
  34 +moduleFilePath=\\D:\\workproject\\bazhuaerp\\src\\main\\java\\com\\bazhuaerp\\
  35 +
  36 +#db包,同上面的packageName
  37 +dbPackageInfo=com.bazhuaerp.db
  38 +
  39 +#-----------------------------
  40 +# 生成View的HTML、JS所需参数 -
  41 +#-----------------------------
  42 +#WebRoot的本地路径
  43 +WebRootPath=\\D:\\workproject\\bazhuaerp\\WebContent\\
  44 +#WebRootPath=\\C:\\workproject\\printer-taover-com\\WebRoot\\
src/com/taover/base/template/HtmlLayuiTemplate.ftl
@@ -85,9 +85,9 @@ @@ -85,9 +85,9 @@
85 layui.config({ 85 layui.config({
86 base: '/plugins/layuiadmin/' //静态资源所在路径 86 base: '/plugins/layuiadmin/' //静态资源所在路径
87 }).extend({ 87 }).extend({
88 - index: 'lib/index' //主入口模块  
89 - }).use(['table', 'laydate', 'layer', 'form'], function(){  
90 - var $ = layui.$, form = layui.form, table = layui.table, laydate = layui.laydate; 88 + operationlog: 'modules/operationlog' //操作模块日志
  89 + }).use(['table', 'laydate', 'layer', 'form', 'operationlog'], function(){
  90 + var $ = layui.$, form = layui.form, table = layui.table, laydate = layui.laydate, operationlog=layui.operationlog;
91 91
92 table.render({ 92 table.render({
93 elem: '#table-data-main', 93 elem: '#table-data-main',
@@ -145,31 +145,7 @@ @@ -145,31 +145,7 @@
145 145
146 //表格操作栏动作入口 146 //表格操作栏动作入口
147 if(obj.event === 'operationLog'){ //查看操作日志动作监听入口 147 if(obj.event === 'operationLog'){ //查看操作日志动作监听入口
148 - layer.open({  
149 - type: 1,  
150 - content: '<table id="form-data-operation-table" ></table>',  
151 - btn: null,  
152 - success: function(layero, index){  
153 - table.render({  
154 - elem: '#form-data-operation-table'  
155 - ,url: '/logtableoper/queryRecord.htm?recordId='+data.id  
156 - ,cols: [[  
157 - {field: 'userName', width: 150, title: '操作用户'}  
158 - ,{field: 'logName', width: 100, title: '操作类型'}  
159 - ,{field: 'createTime', width: 150, title: '创建时间'}  
160 - ,{field: 'description', width: 200, title: '备注信息'}  
161 - ]],  
162 - request:{pageName:'page',limitName:'pageSize'},  
163 - response: {statusName: 'resultId',statusCode: 200,msgName: 'resultMessage',countName: 'total',dataName: 'rows'},  
164 - page:true,  
165 - loading:true,  
166 - done: function(data){  
167 - $('#form-data-operation-table').parent('.layui-layer-content').css({marginTop:'-10px',marginBottom:'-10px'});  
168 - layero.resize();  
169 - }  
170 - });  
171 - }  
172 - }); 148 + operationlog.open(data.id, '${tableName}');
173 } else if(obj.event === 'delete'){ //删除按钮操作入口 149 } else if(obj.event === 'delete'){ //删除按钮操作入口
174 if(!data){ 150 if(!data){
175 layer.alert('没有找到需要删除的记录~'); 151 layer.alert('没有找到需要删除的记录~');
src/com/taover/base/template/model/bussiness/ControllerModel.java
@@ -68,7 +68,7 @@ public class ControllerModel { @@ -68,7 +68,7 @@ public class ControllerModel {
68 * @return 68 * @return
69 */ 69 */
70 public static String parseConditionString(String name, String fieldName){ 70 public static String parseConditionString(String name, String fieldName){
71 - String lowName = StringUtil.formatBeanNameFirstLow(name); 71 + String lowName = name;
72 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n" 72 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n"
73 +"\t\tif(StringUtils.isNotEmpty("+lowName+")){ \n" 73 +"\t\tif(StringUtils.isNotEmpty("+lowName+")){ \n"
74 +"\t\t\tarrayCondition.add(new Object[]{\""+fieldName+"\", \"like\", \"%\"+"+lowName+"+\"%\"}); \n" 74 +"\t\t\tarrayCondition.add(new Object[]{\""+fieldName+"\", \"like\", \"%\"+"+lowName+"+\"%\"}); \n"
@@ -86,7 +86,7 @@ public class ControllerModel { @@ -86,7 +86,7 @@ public class ControllerModel {
86 * @return 86 * @return
87 */ 87 */
88 public static String parseConditionNumber(String name, String fieldName){ 88 public static String parseConditionNumber(String name, String fieldName){
89 - String lowName = StringUtil.formatBeanNameFirstLow(name); 89 + String lowName = name;
90 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n" 90 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n"
91 +"\t\tif(StringUtils.isNotEmpty("+lowName+") && StringUtils.isNumeric("+lowName+") ){ \n" 91 +"\t\tif(StringUtils.isNotEmpty("+lowName+") && StringUtils.isNumeric("+lowName+") ){ \n"
92 +"\t\t\tarrayCondition.add(new Object[]{\""+fieldName+"\", \"=\", "+lowName+"}); \n" 92 +"\t\t\tarrayCondition.add(new Object[]{\""+fieldName+"\", \"=\", "+lowName+"}); \n"
@@ -109,7 +109,7 @@ public class ControllerModel { @@ -109,7 +109,7 @@ public class ControllerModel {
109 * @return 109 * @return
110 */ 110 */
111 public static String parseConditionDate(String name, String fieldName){ 111 public static String parseConditionDate(String name, String fieldName){
112 - String lowName = StringUtil.formatBeanNameFirstLow(name); 112 + String lowName = name;
113 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n" 113 String sqlCondition = "String "+lowName+" = request.getParameter(\""+lowName+"\");\n"
114 + "\t\tif(StringUtils.isNotEmpty("+lowName+")){\n" 114 + "\t\tif(StringUtils.isNotEmpty("+lowName+")){\n"
115 + "\t\t\tString[] dateGap = "+lowName+".split(\"+-+\");\n" 115 + "\t\t\tString[] dateGap = "+lowName+".split(\"+-+\");\n"
src/com/taover/base/template/model/bussiness/ViewModel.java
@@ -11,15 +11,17 @@ import com.taover.db.TableColumn; @@ -11,15 +11,17 @@ import com.taover.db.TableColumn;
11 public class ViewModel { 11 public class ViewModel {
12 private String webRootPath; 12 private String webRootPath;
13 private String controllerPathMap; 13 private String controllerPathMap;
  14 + private String tableName;
14 //map结构如下 15 //map结构如下
15 //name:"",easyui:"numberbox|validatebox|datetimebox",required:true|false,precision:0,min:0,max:32767,validType 16 //name:"",easyui:"numberbox|validatebox|datetimebox",required:true|false,precision:0,min:0,max:32767,validType
16 private List<Map<String, String>> fields = new ArrayList<Map<String, String>>(); 17 private List<Map<String, String>> fields = new ArrayList<Map<String, String>>();
17 18
18 private ViewModel(){} 19 private ViewModel(){}
19 - public static ViewModel createViewModel(String controllerPathMap, String webRootPath,Vector<TableColumn> tableColumns){ 20 + public static ViewModel createViewModel(String controllerPathMap, String webRootPath,Vector<TableColumn> tableColumns, String tableName){
20 ViewModel model = new ViewModel(); 21 ViewModel model = new ViewModel();
21 model.controllerPathMap = controllerPathMap; 22 model.controllerPathMap = controllerPathMap;
22 model.webRootPath = webRootPath; 23 model.webRootPath = webRootPath;
  24 + model.tableName = tableName;
23 for(TableColumn column : tableColumns){ 25 for(TableColumn column : tableColumns){
24 String fieldName = column.getColumBeanLName(); 26 String fieldName = column.getColumBeanLName();
25 String fieldType = column.getJAVADataType(); 27 String fieldType = column.getJAVADataType();
@@ -315,7 +317,13 @@ public class ViewModel { @@ -315,7 +317,13 @@ public class ViewModel {
315 String header = "{title:'"+cnName+"', field:'"+name+"', width:100, sort: true},"; 317 String header = "{title:'"+cnName+"', field:'"+name+"', width:100, sort: true},";
316 return header; 318 return header;
317 } 319 }
318 - 320 +
  321 + public String getTableName(){
  322 + return tableName;
  323 + }
  324 + public void setTableName(String tableName){
  325 + this.tableName = tableName;
  326 + }
319 public String getControllerPathMap() { 327 public String getControllerPathMap() {
320 return controllerPathMap; 328 return controllerPathMap;
321 } 329 }
src/com/taover/business/GenerateVCSDP.java
1 package com.taover.business; 1 package com.taover.business;
2 2
3 -import java.io.File;  
4 import java.sql.Connection; 3 import java.sql.Connection;
5 import java.sql.ResultSet; 4 import java.sql.ResultSet;
6 import java.sql.SQLException; 5 import java.sql.SQLException;
@@ -118,7 +117,7 @@ public class GenerateVCSDP { @@ -118,7 +117,7 @@ public class GenerateVCSDP {
118 //生成Service层 117 //生成Service层
119 GenerateService.generateService(envir, coverWhenFileExists); 118 GenerateService.generateService(envir, coverWhenFileExists);
120 //生成view 119 //生成view
121 - GenerateView.generateView(webRootPath, tableNameCurr, columnsInTable, coverWhenFileExists); 120 + GenerateView.generateView(webRootPath, tableNameCurr, columnsInTable, coverWhenFileExists, moduleName);
122 121
123 System.out.println(tableNameCurr + " : 生成结束"); 122 System.out.println(tableNameCurr + " : 生成结束");
124 } 123 }
src/com/taover/business/GenerateView.java
@@ -82,9 +82,10 @@ public class GenerateView { @@ -82,9 +82,10 @@ public class GenerateView {
82 System.out.println(tableNameCurr + " : 生成失败,未设置主键"); 82 System.out.println(tableNameCurr + " : 生成失败,未设置主键");
83 continue; 83 continue;
84 } 84 }
  85 + String moduleName = tableNameCurr.split("_")[0];
85 86
86 //生成view 87 //生成view
87 - generateView(webRootPath, tableNameCurr, columnsInTable, false); 88 + generateView(webRootPath, tableNameCurr, columnsInTable, false, moduleName);
88 89
89 System.out.println(tableNameCurr + " : 生成结束"); 90 System.out.println(tableNameCurr + " : 生成结束");
90 } 91 }
@@ -92,10 +93,10 @@ public class GenerateView { @@ -92,10 +93,10 @@ public class GenerateView {
92 System.out.println("全部结束"); 93 System.out.println("全部结束");
93 } 94 }
94 95
95 - public static void generateView(String webRootPath, String tableName, Vector<TableColumn> columnsInTable, boolean coverWhenFileExists) { 96 + public static void generateView(String webRootPath, String tableName, Vector<TableColumn> columnsInTable, boolean coverWhenFileExists, String moduleName) {
96 try{ 97 try{
97 String controllerMapping = StringUtil.formatBeanNameFirstLow(tableName).toLowerCase(); 98 String controllerMapping = StringUtil.formatBeanNameFirstLow(tableName).toLowerCase();
98 - ViewModel model = ViewModel.createViewModel(controllerMapping, webRootPath, columnsInTable); 99 + ViewModel model = ViewModel.createViewModel(controllerMapping, webRootPath, columnsInTable, tableName);
99 100
100 File f = new File(Tools.getPath() + Constants.TEMPATE_PATH); 101 File f = new File(Tools.getPath() + Constants.TEMPATE_PATH);
101 Configuration cfg = new Configuration(); 102 Configuration cfg = new Configuration();
@@ -127,9 +128,9 @@ public class GenerateView { @@ -127,9 +128,9 @@ public class GenerateView {
127 Template htmlLayuiTemplate = cfg.getTemplate(Constants.TEMPATE_HTMLLAYUINAME, "UTF-8"); 128 Template htmlLayuiTemplate = cfg.getTemplate(Constants.TEMPATE_HTMLLAYUINAME, "UTF-8");
128 htmlLayuiTemplate.process(model, htmlLayuiOut); 129 htmlLayuiTemplate.process(model, htmlLayuiOut);
129 File destLayuiFile = new File( 130 File destLayuiFile = new File(
130 - webRootPath+File.separator+"views"+File.separator+controllerMapping+".html"); 131 + webRootPath+File.separator+"views"+File.separator+moduleName+File.separator+controllerMapping+".html");
131 if(coverWhenFileExists || !destLayuiFile.exists()){ 132 if(coverWhenFileExists || !destLayuiFile.exists()){
132 - Tools.createFile(webRootPath+File.separator+"views", controllerMapping+".html", htmlLayuiOut.toString()); 133 + Tools.createFile(webRootPath+File.separator+"views"+File.separator+moduleName, controllerMapping+".html", htmlLayuiOut.toString());
133 }else{ 134 }else{
134 System.out.println("文件生成:"+destFile.getName()+"文件已经存在,未覆盖!"); 135 System.out.println("文件生成:"+destFile.getName()+"文件已经存在,未覆盖!");
135 } 136 }