Commit d7a0d715 authored by 赵啸非's avatar 赵啸非

修改部分生成代码逻辑

parent c478037d
......@@ -68,17 +68,6 @@ export default {
>
代码构建
</el-button>
<el-button
type="primary"
icon="el-icon-s-order"
size="mini"
onClick={() => {
this.test(row);
}}
>
测试抓包
</el-button>
</div>
);
},
......
......@@ -94,16 +94,76 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.0</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.3.18</version>
<scope>provided</scope>
</dependency>-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>5.2.2</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.json</include>
<include>**/*.yml</include>
<include>**/*.js</include>
<include>**/*.html</include>
<include>**/*.css</include>
<include>**/*.svg</include>
<include>**/*.jpg</include>
<include>**/*.jpeg</include>
<include>**/*.png</include>
<include>**/*.ico</include>
<include>**/*.woff2</include>
<include>**/*.txt</include>
<include>**/*.xlsx</include>
<include>**/*.xls</include>
</includes>
<excludes>
<exclude>env/*.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.docx</include>
<include>**/*.ftl</include>
</includes>
</resource>
</resources>
<plugins>
......
......@@ -634,18 +634,18 @@ public class GentableColumnEntity extends GentableColumnEntityExt {
public void initAttrValue() {
this.tableId = null;
this.columnName = null;
this.columnComment = null;
this.columnName = "1231";
this.columnComment = "1313131";
this.columnType = null;
this.javaType = null;
this.javaField = null;
this.isPrimaryKey = null;
this.isIncrement = null;
this.isRequired = null;
this.isInsert = null;
this.isEdit = null;
this.isList = null;
this.isQuery = null;
this.isPrimaryKey = 0;
this.isIncrement = 0;
this.isRequired = 0;
this.isInsert = 0;
this.isEdit = 0;
this.isList = 0;
this.isQuery = 0;
this.htmlType = null;
this.defaultValue = null;
this.sort = null;
......
......@@ -306,6 +306,32 @@ public class UserEntity extends UserEntityExt implements IUser {
public Integer getUserType() {
return this.userType;
}
@Override
public String getToken() {
return null;
}
@Override
public Long getLoginTime() {
return null;
}
@Override
public Long getExpireTime() {
return null;
}
@Override
public void setExpireTime(Long expireTime) {
}
@Override
public String getMenuUrl() {
return null;
}
/**
* 设置 用户类型,0:系统用户 1:普通用户 2:工作人员,默认2
* @param userType
......
......@@ -113,7 +113,8 @@ public class FreeMarkerUtils {
templates.add("entityQuery.java.ftl");
templates.add("dao.java.ftl");
templates.add("daoImpl.java.ftl");
templates.add("web.java.ftl");
// templates.add("web.java.ftl");
templates.add("webBody.java.ftl");
templates.add("webForm.java.ftl");
templates.add("sqlMap.xml.ftl");
templates.add("db.sql.ftl");
......@@ -128,7 +129,7 @@ public class FreeMarkerUtils {
templates.add("serviceImpl.java.ftl");
templates.add("webVueList.vue.ftl");
templates.add("VueDialogShow.vue.ftl");
templates.add("webVueShow.vue.ftl");
// templates.add("webVueShow.vue.ftl");
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
templates.add("entity-tree.java.ftl");
templates.add("service-tree.java.ftl");
......@@ -139,10 +140,10 @@ public class FreeMarkerUtils {
templates.add("service.java.ftl");
templates.add("serviceImpl.java.ftl");
templates.add("webVueList.vue.ftl");
templates.add("webVueShow.vue.ftl");
//templates.add("webVueShow.vue.ftl");
templates.add("VueDialogShow.vue.ftl");
}
templates.add("webVueView.vue.ftl");
//templates.add("webVueView.vue.ftl");
return templates;
}
......@@ -444,9 +445,14 @@ public class FreeMarkerUtils {
fileName = StringUtils.format("{}/{}/service/impl/{}ServiceImpl.java", javaPath, businessName, className);
} else if (template.contains("serviceImpl-tree.java.ftl")) {
fileName = StringUtils.format("{}/{}/service/impl/{}ServiceImpl.java", javaPath, businessName, className);
} else if (template.contains("web.java.ftl")) {
}
// else if (template.contains("web.java.ftl")) {
// fileName = StringUtils.format("{}/{}/web/{}Controller.java", javaPath, businessName, className);
// }
else if (template.contains("webBody.java.ftl")) {
fileName = StringUtils.format("{}/{}/web/{}Controller.java", javaPath, businessName, className);
} else if (template.contains("webForm.java.ftl")) {
}
else if (template.contains("webForm.java.ftl")) {
fileName = StringUtils.format("{}/{}/web/{}Form.java", javaPath, businessName, className);
} else if (template.contains("sqlMap.xml.ftl")) {
fileName = StringUtils.format("{}/{}/{}Mapper.xml", mybatisPath, businessName, className);
......@@ -454,15 +460,19 @@ public class FreeMarkerUtils {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/list.vue", vuePath, businessNameExt);
} else if (template.contains("webVueShow.vue.ftl")) {
}
/* else if (template.contains("webVueShow.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/show.vue", vuePath, businessNameExt);
} else if (template.contains("webVueView.vue.ftl")) {
}
else if (template.contains("webVueView.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/view.vue", vuePath, businessNameExt);
} else if (template.contains("webVueTreeList.vue.ftl")) {
}*/
else if (template.contains("webVueTreeList.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/list.vue", vuePath, businessNameExt);
......
......@@ -4,6 +4,8 @@ import cn.hutool.core.io.FileUtil;
import com.mortals.xhx.base.system.gentable.model.GentableColumnEntity;
import com.mortals.xhx.base.system.gentable.model.GentableEntity;
import lombok.experimental.UtilityClass;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
......@@ -79,7 +81,7 @@ public class ReadDoc {
}
docTable.setTableName(tableName.trim());
docTable.setTableComment(split[0].replace(",表名","").trim());
docTable.setTableComment(split[0].replace(",表名", "").trim());
// System.out.println("这是第" + num + "个表的数据");
List<XWPFTableRow> rows = table.getRows();
//读取每一行数据,每一行为一列
......@@ -118,9 +120,9 @@ public class ReadDoc {
column.setIsQuery("是".equals(cell.getText().trim()) ? 1 : 0);
//默认值
cell = cells.get(9);
if(!ObjectUtils.isEmpty(cell.getText().trim())){
if (!ObjectUtils.isEmpty(cell.getText().trim())) {
column.setDefaultValue(cell.getText().trim());
}else{
} else {
column.setDefaultValue("");
}
//备注信息
......@@ -135,64 +137,105 @@ public class ReadDoc {
}
} else {
// 处理doc格式 即office2003版本
// POIFSFileSystem pfs = new POIFSFileSystem(file.getInputStream());
//
// HWPFDocument hwpf = new HWPFDocument(pfs);
// Range range = hwpf.getRange();//得到文档的读取范围
// TableIterator it = new TableIterator(range);
// while (it.hasNext()) {
// List<DocTableModel> docTableModels = new ArrayList<DocTableModel>();
//
// Table tb = it.next();
//
// DocTable docTable = new DocTable();
//
// TableRow firstRow = tb.getRow(0);
//
// TableCell firstTdCell = firstRow.getCell(0);
//
// Paragraph firstTdCellParagraph = firstTdCell.getParagraph(0);
// String firstStr = firstTdCellParagraph.text();
// //去除后面的特殊符号
// if (null != firstStr && !"".equals(firstStr)) {
// firstStr = firstStr.substring(0, firstStr.length() - 1);
// }
// String[] split = firstStr.split(":");
// docTable.setDataTableName(split[1]);
//
// //System.out.println("这是第" + num + "个表的数据");
// //迭代行,默认从0开始,可以依据需要设置i的值,改变起始行数,也可设置读取到那行,只需修改循环的判断条件即可
// for (int i = 1; i < tb.numRows(); i++) {
// DocTableModel docTableModel = new DocTableModel();
// TableRow tr = tb.getRow(i);
//
// if("".equals(tr.getCell(0).text().trim())){
POIFSFileSystem pfs = new POIFSFileSystem(file.getInputStream());
HWPFDocument hwpf = new HWPFDocument(pfs);
Range range = hwpf.getRange();//得到文档的读取范围
TableIterator it = new TableIterator(range);
while (it.hasNext()) {
List<GentableColumnEntity> columns = new ArrayList<GentableColumnEntity>();
Table table = it.next();
// XWPFTable table = (XWPFTable) next;
GentableEntity docTable = new GentableEntity();
TableRow firstRow = table.getRow(0);
TableCell firstTdCell = firstRow.getCell(0);
String firstStr = firstTdCell.text();
String[] split = firstStr.split(":");
if (split.length < 2) {
continue;
}
String tableName = split[1];
String[] vals = tableName.split("_");
if (tableName.indexOf("yyyymmdd") != -1) {
docTable.setDividedTableType(3);
} else if (tableName.indexOf("yyyymm") != -1) {
docTable.setDividedTableType(2);
} else if (tableName.indexOf("yyyy") != -1) {
docTable.setDividedTableType(1);
} else {
docTable.setDividedTableType(0);
}
if (vals[vals.length - 1].startsWith("yyyy")) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < vals.length - 1; i++) {
sb.append(vals[i]);
if (i < vals.length - 2) {
sb.append("_");
}
}
tableName = sb.toString();
}
docTable.setTableName(tableName.trim());
docTable.setTableComment(split[0].replace(",表名", "").trim());
// System.out.println("这是第" + num + "个表的数据");
int rows = table.numRows();
//读取每一行数据,每一行为一列
for (int i = 2; i < rows; i++) {
GentableColumnEntity column = new GentableColumnEntity();
TableRow row = table.getRow(i);
//判断是否第一个列数据为空 如果为空 跳过
// if ("".equals(row.getCell(0).getText().trim())) {
// continue;
// }
// //迭代列,默认从0开始
// for (int j = 0; j < tr.numCells(); j++) {
// TableCell td = tr.getCell(j);//取得单元格
// //获取需要设置的属性名称
// String att = vars[j];
//
// //取得单元格的内容
// for (int k = 0; k < td.numParagraphs(); k++) {
// Paragraph para = td.getParagraph(k);
// String s = para.text();
// //去除后面的特殊符号
// if (null != s && !"".equals(s)) {
// s = s.substring(0, s.length() - 1);
// }
//
// setFieldValueByFieldName(att, docTableModel, s);
// }
// }
//
// docTableModels.add(docTableModel);
// }
// docTable.setModelList(docTableModels);
// docTables.add(docTable);
// }
//读取每一列数据
// List<TableCell> cells = row.getCell();
//列名
TableCell cell = row.getCell(1);
column.setColumnName(cell.text().trim());
//数据类型
cell = row.getCell(2);
column.setColumnType(cell.text().trim());
//是否必填
cell = row.getCell(3);
column.setIsRequired("是".equals(cell.text().trim()) ? 1 : 0);
//是否主键
cell = row.getCell(4);
column.setIsPrimaryKey("是".equals(cell.text().trim()) ? 1 : 0);
//是否自增
cell = row.getCell(5);
column.setIsIncrement("是".equals(cell.text().trim()) ? 1 : 0);
//是否列表
cell = row.getCell(6);
column.setIsList("是".equals(cell.text().trim()) ? 1 : 0);
//是否导入导出
cell = row.getCell(7);
column.setIsExport("是".equals(cell.text().trim()) ? 1 : 0);
//是否查询
cell = row.getCell(8);
column.setIsQuery("是".equals(cell.text().trim()) ? 1 : 0);
//默认值
cell = row.getCell(9);
if (!ObjectUtils.isEmpty(cell.text().trim())) {
column.setDefaultValue(cell.text().trim());
} else {
column.setDefaultValue("");
}
//备注信息
cell = row.getCell(10);
column.setColumnComment(cell.text().trim());
columns.add(column);
}
docTable.setColumns(columns);
docTables.add(docTable);
}
}
......
......@@ -10,7 +10,7 @@
where table_schema = (select database())
AND table_name NOT LIKE 'act_%'
<!--过滤初始系统表-->
AND table_name NOT IN (
<!-- AND table_name NOT IN (
'mortals_xhx_gentable',
'mortals_xhx_gentable_column',
'mortals_xhx_idgenerator',
......@@ -27,7 +27,7 @@
'mortals_xhx_user',
'mortals_xhx_valid_code',
'mortals_xhx_area'
)
)-->
<!-- AND table_name NOT LIKE 'mortals_xhx_gen%'-->
AND table_name NOT IN (select tableName from mortals_xhx_gentable
......
......@@ -16,16 +16,19 @@
参数名称|类型|备注|必填|其它
---|---|---|---|---
page|Integer|当前页|否|-
size|Integer|每页条数|否|-
size|Integer|每页条数|否|值为-1,查询所有记录
<#list columns as column>
<#if column.isQuery == 1>
<#if column.javaType=="String" >
${column.javaField}|${column.javaType}|${column.columnComment}|否|字段前后添加%%模糊查询
<#else>
${column.javaField}|${column.javaType}|${column.columnComment}|否|-
</#if>
</#if>
</#list>
**请求样例:**
```
{
<#list columns as column>
<#if column.isQuery == 1>
......@@ -70,15 +73,6 @@ dict|object|字典对象|-
{
"code":1,
"data":{
"per_page":10,
"total":0,
"data":[],
"last_page":0,
"current_page":1
},
"query":{
"modelCode":"phxt1",
"modelName":"排号系统"
}
}
```
......@@ -101,9 +95,7 @@ ${pkColumn.javaField}|${pkColumn.javaType}|主键,唯一|是|-
**请求样例:**
```
http://localhost/${RequestMapping}/edit?id=549
```
**响应参数:**
......@@ -125,7 +117,6 @@ dict|object|字典对象|-
**响应消息样例:**
```
{
"code": 1,
"data": {
......@@ -139,7 +130,6 @@ dict|object|字典对象|-
</#list>
}
}
```
### 查看${functionName}
......@@ -160,9 +150,7 @@ ${pkColumn.javaField}|${pkColumn.javaType}|主键,唯一|是|-
**请求样例:**
```
http://localhost/${RequestMapping}/info?id=549
```
**响应参数:**
......@@ -205,7 +193,6 @@ dict|object|字典对象|-
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存或更新${functionName}:id为空时为新增保存,否则为更新提交
......@@ -222,7 +209,6 @@ ${column.javaField}|${column.javaType}|${column.columnComment}|是|-
**请求样例:**
```
{
<#list columns as column>
<#if !column.isSuperColumn(column.javaField)>
......@@ -252,19 +238,10 @@ data|object|数据对象|-
**响应消息样例:**
```
{
"msg":"新增模块成功",
"code":1,
"data":{
"__mortals_form_state__":"ADD",
"id":4,
"entity":{
"createTime":1642486776780,
"id":4,
"modelCode":"phxt1",
"modelName":"排号系统4",
"updateTime":1642486776780
}
}
}
......@@ -276,7 +253,7 @@ data|object|数据对象|-
**请求URL:** ${RequestMapping}/delete
**请求方式:** POST
**请求方式:** GET
**内容类型:** application/json;charset=utf-8
......@@ -290,9 +267,7 @@ id|String|字符串,多个逗号分隔|是|-
**请求样例:**
```
http://localhost:8080/${RequestMapping}/delete?id=1'
```
**响应参数:**
......
###${functionName}列表
POST {{baseUrl}}/${RequestMapping}/list
Authorization: {{authToken}}
Content-Type: application/json
{
......@@ -21,6 +22,7 @@ Content-Type: application/json
###${functionName}更新与保存
POST {{baseUrl}}/${RequestMapping}/save
Authorization: {{authToken}}
Content-Type: application/json
{
......@@ -42,15 +44,18 @@ client.global.set("${ClassName}_id", JSON.parse(response.body).data.id);
###${functionName}查看
GET {{baseUrl}}/${RequestMapping}/info?id={{${ClassName}_id}}
Authorization: {{authToken}}
Accept: application/json
###${functionName}编辑
GET {{baseUrl}}/${RequestMapping}/edit?id={{${ClassName}_id}}
Authorization: {{authToken}}
Accept: application/json
###${functionName}删除
GET {{baseUrl}}/${RequestMapping}/delete?id={{${ClassName}_id}}
Authorization: {{authToken}}
Accept: application/json
......
......@@ -151,7 +151,7 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
for (Iterator<${ClassName}Entity> iterator = list.iterator(); iterator.hasNext(); ) {
${ClassName}Entity ${ClassName?uncap_first}Entity = iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(${ClassName?uncap_first}Entity.get${treeParentCode?cap_first}())) {
recursionFn(list, ${ClassName?uncap_first}Entity);
returnList.add(${ClassName?uncap_first}Entity);
......
......@@ -5,11 +5,11 @@ import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONObject;
<#assign Controller = "BaseCRUDJsonController">
<#elseif table.isShowControl==2 >
<#assign Controller = "BaseCRUDJsonPhpController">
<#assign Controller = "BaseCRUDJsonBodyMappingController">
<#else>
<#assign Controller = "BaseCRUDJsonMappingController">
</#if>
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>com.mortals</groupId>
<artifactId>mortals-common</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.5-SNAPSHOT</version>
</parent>
<groupId>com.mortals.xhx</groupId>
<artifactId>appbuild-platform</artifactId>
......@@ -115,6 +115,7 @@
</dependencies>
<build>
<!--
<resources>
<resource>
<directory>src/main/resources</directory>
......@@ -124,6 +125,7 @@
<filtering>true</filtering>
</resource>
</resources>
-->
<plugins>
<plugin>
......
Markdown is supported
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