新增左树右表和导入导出代码生成模板
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
<template>crud/service.xml</template>
|
<template>crud/service.xml</template>
|
||||||
<template>crud/controller.xml</template>
|
<template>crud/controller.xml</template>
|
||||||
<template>crud/viewList.xml</template>
|
<template>crud/viewList.xml</template>
|
||||||
<template>crud/viewIndex.xml</template>
|
|
||||||
<template>crud/viewForm.xml</template>
|
<template>crud/viewForm.xml</template>
|
||||||
|
<template>crud/viewIndex.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
@@ -22,8 +22,9 @@
|
|||||||
<template>crud/controller.xml</template>
|
<template>crud/controller.xml</template>
|
||||||
<template>crud/vueApi.xml</template>
|
<template>crud/vueApi.xml</template>
|
||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueIndex.xml</template>
|
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
|
<template>crud/vueIndex.xml</template>
|
||||||
|
<template>crud/vueImport.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
@@ -31,8 +32,9 @@
|
|||||||
<category value="crud_only_vue" label="单表/主子表 (增删改查)仅Vue">
|
<category value="crud_only_vue" label="单表/主子表 (增删改查)仅Vue">
|
||||||
<template>crud/vueApi.xml</template>
|
<template>crud/vueApi.xml</template>
|
||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueIndex.xml</template>
|
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
|
<template>crud/vueIndex.xml</template>
|
||||||
|
<template>crud/vueImport.xml</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_select" label="单表/主子表 (增删改查,含 listselect 选择页面)">
|
<category value="crud_select" label="单表/主子表 (增删改查,含 listselect 选择页面)">
|
||||||
<template>category-ref:crud</template>
|
<template>category-ref:crud</template>
|
||||||
@@ -70,6 +72,7 @@
|
|||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueIndex.xml</template>
|
<template>crud/vueIndex.xml</template>
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
|
<template>crud/vueImport.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
<template>crud_cloud/mapper.xml</template>
|
||||||
<template>crud_cloud/entity.xml</template>
|
<template>crud_cloud/entity.xml</template>
|
||||||
|
|||||||
@@ -9,9 +9,10 @@
|
|||||||
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% if (table.isTreeEntity){ %>
|
<% if (table.isTreeEntity){ %>
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
<% }else{ %>
|
<% } %>
|
||||||
|
<% if (!table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -27,8 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
import com.jeesite.common.config.Global;
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.idgen.IdGen;
|
import com.jeesite.common.idgen.IdGen;
|
||||||
@@ -36,6 +39,12 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.lang.DateUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelExport;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
<% } %>
|
||||||
<% if (table.tplCategory == 'crud_select'){ %>
|
<% if (table.tplCategory == 'crud_select'){ %>
|
||||||
import com.alibaba.fastjson.JSONValidator;
|
import com.alibaba.fastjson.JSONValidator;
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
@@ -75,8 +84,8 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
return ${className}Service.getAndValid(${className});
|
return ${className}Service.getAndValid(${className});
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理主页
|
* 管理主页
|
||||||
*/
|
*/
|
||||||
@@ -204,6 +213,50 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
${className}Service.save(${className});
|
${className}Service.save(${className});
|
||||||
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "exportData")
|
||||||
|
public void exportData(${ClassName} ${className}, HttpServletResponse response) {
|
||||||
|
List<${ClassName}> list = ${className}Service.findList(${className});
|
||||||
|
String fileName = "${functionNameSimple}" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "importTemplate")
|
||||||
|
public void importTemplate(HttpServletResponse response) {
|
||||||
|
${ClassName} ${className} = new ${ClassName}();
|
||||||
|
List<${ClassName}> list = ListUtils.newArrayList(${className});
|
||||||
|
String fileName = "${functionNameSimple}模板.xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class, Type.IMPORT)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("${permissionPrefix}:edit")
|
||||||
|
@PostMapping(value = "importData")
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
String message = ${className}Service.importData(file);
|
||||||
|
return renderResult(Global.TRUE, "posfull:"+message);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,359 +1,375 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
No deletion without permission, or be held responsible to law. -->
|
No deletion without permission, or be held responsible to law. -->
|
||||||
<template>
|
<template>
|
||||||
<name>entity</name>
|
<name>entity</name>
|
||||||
<filePath>${baseDir}/src/main/java/${packagePath}/${moduleName}/entity/${subModuleName}</filePath>
|
<filePath>${baseDir}/src/main/java/${packagePath}/${moduleName}/entity/${subModuleName}</filePath>
|
||||||
<fileName>${ClassName}.java</fileName>
|
<fileName>${ClassName}.java</fileName>
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% if(table.childList.~size > 0){ %>
|
<% if(table.childList.~size > 0){ %>
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
<% } %>
|
<% } %>
|
||||||
<% for(i in table.importList){ %>
|
<% for(i in table.importList){ %>
|
||||||
import ${i};
|
import ${i};
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
import com.jeesite.common.entity.DataEntity;
|
import com.jeesite.common.entity.DataEntity;
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.entity.TreeEntity;
|
import com.jeesite.common.entity.TreeEntity;
|
||||||
<% } %>
|
<% } %>
|
||||||
import com.jeesite.common.mybatis.annotation.Column;
|
import com.jeesite.common.mybatis.annotation.Column;
|
||||||
import com.jeesite.common.mybatis.annotation.Table;
|
import com.jeesite.common.mybatis.annotation.Table;
|
||||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(!table.parentExists && toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
/**
|
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||||
* ${functionName}Entity
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||||
* @author ${functionAuthor}
|
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||||
* @version ${functionVersion}
|
<% } %>
|
||||||
*/
|
|
||||||
@Table(name="${table.genTableName}", alias="a", label="${functionNameSimple}信息", columns={
|
/**
|
||||||
<%
|
* ${functionName}Entity
|
||||||
var isBase = false, isData = false,
|
* @author ${functionAuthor}
|
||||||
isTree = false, isExtend = false;
|
* @version ${functionVersion}
|
||||||
// ◆ 生成字段属性
|
*/
|
||||||
for(c in table.columnList){
|
@Table(name="${table.genTableName}", alias="a", label="${functionNameSimple}信息", columns={
|
||||||
// ● 如果是BaseEntity类属性
|
<%
|
||||||
if(table.isBaseEntity && c.isBaseEntityColumn){
|
var isBase = false, isData = false,
|
||||||
if(!isBase){
|
isTree = false, isExtend = false;
|
||||||
isBase = true;
|
// ◆ 生成字段属性
|
||||||
%>
|
for(c in table.columnList){
|
||||||
@Column(includeEntity=BaseEntity.class),
|
// ● 如果是BaseEntity类属性
|
||||||
<%
|
if(table.isBaseEntity && c.isBaseEntityColumn){
|
||||||
}
|
if(!isBase){
|
||||||
// ● 如果是DataEntity类属性
|
isBase = true;
|
||||||
}else if(table.isDataEntity && c.isDataEntityColumn){
|
%>
|
||||||
if(!isData){
|
@Column(includeEntity=BaseEntity.class),
|
||||||
isData = true;
|
<%
|
||||||
%>
|
}
|
||||||
@Column(includeEntity=DataEntity.class),
|
// ● 如果是DataEntity类属性
|
||||||
<%
|
}else if(table.isDataEntity && c.isDataEntityColumn){
|
||||||
}
|
if(!isData){
|
||||||
// ● 如果是TreeEntity类属性
|
isData = true;
|
||||||
}else if(table.isTreeEntity && c.isTreeEntityColumn){
|
%>
|
||||||
if(!isTree){
|
@Column(includeEntity=DataEntity.class),
|
||||||
isTree = true;
|
<%
|
||||||
%>
|
}
|
||||||
@Column(includeEntity=TreeEntity.class),
|
// ● 如果是TreeEntity类属性
|
||||||
<%
|
}else if(table.isTreeEntity && c.isTreeEntityColumn){
|
||||||
}
|
if(!isTree){
|
||||||
// ● 如果是Extend类属性
|
isTree = true;
|
||||||
}else if(table.isExtendEntity && c.isExtendColumn){
|
%>
|
||||||
if(!isExtend){
|
@Column(includeEntity=TreeEntity.class),
|
||||||
isExtend = true;
|
<%
|
||||||
%>
|
}
|
||||||
@Column(includeEntity=Extend.class, attrName="extend"),
|
// ● 如果是Extend类属性
|
||||||
<%
|
}else if(table.isExtendEntity && c.isExtendColumn){
|
||||||
}
|
if(!isExtend){
|
||||||
// ● 其它情况下
|
isExtend = true;
|
||||||
}else{
|
%>
|
||||||
// 容错,如果没有设置父表的主键属性,则设置
|
@Column(includeEntity=Extend.class, attrName="extend"),
|
||||||
if(!@StringUtils.contains(c.attrName, ".")){
|
<%
|
||||||
if (table.parentExists && table.parentTableFkName == c.columnName){
|
}
|
||||||
for (pk in table.parent.pkList){
|
// ● 其它情况下
|
||||||
c.fullAttrName = c.fullAttrName + '.' + pk.attrName;
|
}else{
|
||||||
break;
|
// 容错,如果没有设置父表的主键属性,则设置
|
||||||
}
|
if(!@StringUtils.contains(c.attrName, ".")){
|
||||||
}
|
if (table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
}
|
for (pk in table.parent.pkList){
|
||||||
%>
|
c.fullAttrName = c.fullAttrName + '.' + pk.attrName;
|
||||||
@Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<%
|
break;
|
||||||
if (c.comments != c.columnLabel){
|
}
|
||||||
print(', comment="'+c.comments+'"');
|
}
|
||||||
}
|
}
|
||||||
if (c.isPk == @Global.YES){
|
%>
|
||||||
print(', isPK=true');
|
@Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<%
|
||||||
}else{
|
if (c.comments != c.columnLabel){
|
||||||
if (c.isInsert != @Global.YES){
|
print(', comment="'+c.comments+'"');
|
||||||
print(', isInsert=false');
|
}
|
||||||
}
|
if (c.isPk == @Global.YES){
|
||||||
if (c.isUpdate != @Global.YES){
|
print(', isPK=true');
|
||||||
print(', isUpdate=false');
|
}else{
|
||||||
}
|
if (c.isInsert != @Global.YES){
|
||||||
if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType,
|
print(', isInsert=false');
|
||||||
'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){
|
}
|
||||||
print(', queryType=QueryType.'+c.queryType);
|
if (c.isUpdate != @Global.YES){
|
||||||
}
|
print(', isUpdate=false');
|
||||||
if (c.isQuery != @Global.YES){
|
}
|
||||||
print(', isQuery=false');
|
if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType,
|
||||||
}
|
'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){
|
||||||
if (c.attrName == table.treeViewNameAttrName){
|
print(', queryType=QueryType.'+c.queryType);
|
||||||
print(', isTreeName=true');
|
}
|
||||||
}
|
if (c.isQuery != @Global.YES){
|
||||||
if (c.isNull == @Global.YES && @StringUtils.inString(c.simpleAttrType,
|
print(', isQuery=false');
|
||||||
'Long', 'Integer', 'Double', 'BigDecimal', 'Date')){
|
}
|
||||||
print(', isUpdateForce=true');
|
if (c.attrName == table.treeViewNameAttrName){
|
||||||
}
|
print(', isTreeName=true');
|
||||||
}
|
}
|
||||||
%>),
|
if (c.isNull == @Global.YES && @StringUtils.inString(c.simpleAttrType,
|
||||||
<%
|
'Long', 'Integer', 'Double', 'BigDecimal', 'Date')){
|
||||||
}
|
print(', isUpdateForce=true');
|
||||||
}
|
}
|
||||||
%>
|
}
|
||||||
}, <%
|
%>),
|
||||||
// ◆ 生成关联表
|
<%
|
||||||
var joinTables = '';
|
}
|
||||||
for(c in table.columnList){
|
}
|
||||||
if (c.attrType == 'com.jeesite.modules.sys.entity.User'){
|
%>
|
||||||
var joinTable = {
|
}, <%
|
||||||
%>
|
// ◆ 生成关联表
|
||||||
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
var joinTables = '';
|
||||||
on="u${cLP.index}.user_code = a.${c.columnName}", columns={
|
for(c in table.columnList){
|
||||||
@Column(name="user_code", label="用户编码", isPK=true),
|
if (c.attrType == 'com.jeesite.modules.sys.entity.User'){
|
||||||
@Column(name="user_name", label="用户名称", isQuery=false),
|
var joinTable = {
|
||||||
}),
|
%>
|
||||||
<%
|
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
||||||
};
|
on="u${cLP.index}.user_code = a.${c.columnName}", columns={
|
||||||
joinTables = joinTables + joinTable;
|
@Column(name="user_code", label="用户编码", isPK=true),
|
||||||
}
|
@Column(name="user_name", label="用户名称", isQuery=false),
|
||||||
else if (c.attrType == 'com.jeesite.modules.sys.entity.Office'){
|
}),
|
||||||
var joinTable = {
|
<%
|
||||||
%>
|
};
|
||||||
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
joinTables = joinTables + joinTable;
|
||||||
on="u${cLP.index}.office_code = a.${c.columnName}", columns={
|
}
|
||||||
@Column(name="office_code", label="机构编码", isPK=true),
|
else if (c.attrType == 'com.jeesite.modules.sys.entity.Office'){
|
||||||
@Column(name="office_name", label="机构名称", isQuery=false),
|
var joinTable = {
|
||||||
}),
|
%>
|
||||||
<%
|
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
||||||
};
|
on="u${cLP.index}.office_code = a.${c.columnName}", columns={
|
||||||
joinTables = joinTables + joinTable;
|
@Column(name="office_code", label="机构编码", isPK=true),
|
||||||
}
|
@Column(name="office_name", label="机构名称", isQuery=false),
|
||||||
}
|
}),
|
||||||
if (isNotBlank(joinTables)){
|
<%
|
||||||
print('joinTable={');
|
};
|
||||||
print(joinTables);
|
joinTables = joinTables + joinTable;
|
||||||
print('}, ');
|
}
|
||||||
}
|
}
|
||||||
// ◆ 生成排序字段
|
if (isNotBlank(joinTables)){
|
||||||
%>orderBy="<% if (isTree){
|
print('joinTable={');
|
||||||
%>a.tree_sorts<%
|
print(joinTables);
|
||||||
for(pk in table.pkList){
|
print('}, ');
|
||||||
%>, a.${pk.columnName}<%
|
}
|
||||||
}
|
// ◆ 生成排序字段
|
||||||
}else if(table.parentExists && table.createDateExists){
|
%>orderBy="<% if (isTree){
|
||||||
%>a.create_date ASC<%
|
%>a.tree_sorts<%
|
||||||
}else if(table.updateDateExists){
|
for(pk in table.pkList){
|
||||||
%>a.update_date DESC<%
|
%>, a.${pk.columnName}<%
|
||||||
}else{
|
}
|
||||||
for(pk in table.pkList){
|
}else if(table.parentExists && table.createDateExists){
|
||||||
%>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<%
|
%>a.create_date ASC<%
|
||||||
}
|
}else if(table.updateDateExists){
|
||||||
} %>"
|
%>a.update_date DESC<%
|
||||||
)
|
}else{
|
||||||
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
for(pk in table.pkList){
|
||||||
|
%>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<%
|
||||||
private static final long serialVersionUID = 1L;
|
}
|
||||||
<%
|
} %>"
|
||||||
isExtend = false;
|
)
|
||||||
// 生成字段属性
|
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
||||||
for(c in table.columnList){
|
|
||||||
// 如果是Extend类属性
|
private static final long serialVersionUID = 1L;
|
||||||
if(table.isExtendEntity && c.isExtendColumn){
|
<%
|
||||||
if(!isExtend){
|
isExtend = false;
|
||||||
isExtend = true;
|
// 生成字段属性
|
||||||
%>
|
for(c in table.columnList){
|
||||||
private Extend extend; // 扩展字段
|
// 如果是Extend类属性
|
||||||
<%
|
if(table.isExtendEntity && c.isExtendColumn){
|
||||||
}
|
if(!isExtend){
|
||||||
}
|
isExtend = true;
|
||||||
// 如果不是基类属性
|
%>
|
||||||
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
private Extend extend; // 扩展字段
|
||||||
// 父类对象
|
<%
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
}
|
||||||
%>
|
}
|
||||||
private ${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}; <% if (isNotBlank(c.comments)){ %>// ${c.comments} 父类<% } %>
|
// 如果不是基类属性
|
||||||
<%
|
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||||
// 其它字段
|
// 父类对象
|
||||||
}else{
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
%>
|
%>
|
||||||
private ${c.simpleAttrType} ${c.simpleAttrName}; <%if(isNotBlank(c.comments)){%>// ${c.comments}<%}%>
|
private ${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}; <% if (isNotBlank(c.comments)){ %>// ${c.comments} 父类<% } %>
|
||||||
<%
|
<%
|
||||||
}
|
// 其它字段
|
||||||
}
|
}else{
|
||||||
}
|
%>
|
||||||
|
private ${c.simpleAttrType} ${c.simpleAttrName}; <%if(isNotBlank(c.comments)){%>// ${c.comments}<%}%>
|
||||||
// 生成子表列表字段
|
<%
|
||||||
for(child in table.childList){
|
}
|
||||||
%>
|
}
|
||||||
private List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List = ListUtils.newArrayList(); // 子表列表
|
}
|
||||||
<%
|
|
||||||
}
|
// 生成子表列表字段
|
||||||
|
for(child in table.childList){
|
||||||
// 生成构造方法
|
%>
|
||||||
%>
|
private List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List = ListUtils.newArrayList(); // 子表列表
|
||||||
|
<%
|
||||||
public ${ClassName}() {
|
}
|
||||||
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
|
||||||
}
|
// 生成构造方法
|
||||||
<%
|
%>
|
||||||
// 生成带主键参数的构造
|
|
||||||
if (!table.parentExists){
|
<% if(!table.parentExists && toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
if (table.pkList.~size == 1){ %>
|
@ExcelFields({
|
||||||
|
<% for(c in table.columnList){ if(c.optionMap['isImportExport'] == @Global.YES){ %>
|
||||||
public ${ClassName}(String id){
|
@ExcelField(title="${c.columnLabel}", attrName="${c.attrName}"${
|
||||||
super(id);
|
isNotBlank(c.optionMap['dictType'])?', dictType="'+c.optionMap['dictType']+'"':''
|
||||||
}
|
}, align=Align.CENTER, sort=${c.columnSort}${
|
||||||
<% }else{ %>
|
c.showType == 'date'?', dataFormat="yyyy-MM-dd"':c.showType == 'datetime'?', dataFormat="yyyy-MM-dd hh:mm"':''
|
||||||
|
}),
|
||||||
public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){
|
<% } } %>
|
||||||
<% for(pk in table.pkList){ %>
|
})
|
||||||
this.${pk.simpleAttrName} = ${pk.simpleAttrName};
|
<% } %>
|
||||||
<% } %>
|
public ${ClassName}() {
|
||||||
}
|
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
||||||
<%
|
}
|
||||||
}
|
<%
|
||||||
}
|
// 生成带主键参数的构造
|
||||||
|
if (!table.parentExists){
|
||||||
// 生成父表参数的构造
|
if (table.pkList.~size == 1){ %>
|
||||||
else{
|
|
||||||
for(c in table.columnList){
|
public ${ClassName}(String id){
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
super(id);
|
||||||
%>
|
}
|
||||||
|
<% }else{ %>
|
||||||
public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){
|
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){
|
||||||
}
|
<% for(pk in table.pkList){ %>
|
||||||
<%
|
this.${pk.simpleAttrName} = ${pk.simpleAttrName};
|
||||||
}
|
<% } %>
|
||||||
}
|
}
|
||||||
}
|
<%
|
||||||
|
}
|
||||||
// 如果是树实体,则输出相应方法
|
}
|
||||||
if (table.isTreeEntity){
|
|
||||||
%>
|
// 生成父表参数的构造
|
||||||
|
else{
|
||||||
@Override
|
for(c in table.columnList){
|
||||||
public ${ClassName} getParent() {
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
return parent;
|
%>
|
||||||
}
|
|
||||||
|
public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){
|
||||||
@Override
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
public void setParent(${ClassName} parent) {
|
}
|
||||||
this.parent = parent;
|
<%
|
||||||
}
|
}
|
||||||
<%
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成属性的get和set方法
|
// 如果是树实体,则输出相应方法
|
||||||
isExtend = false;
|
if (table.isTreeEntity){
|
||||||
for(c in table.columnList){
|
%>
|
||||||
// 如果是Extend类属性
|
|
||||||
if(c.isExtendColumn){
|
@Override
|
||||||
if(!isExtend){
|
public ${ClassName} getParent() {
|
||||||
isExtend = true;
|
return parent;
|
||||||
%>
|
}
|
||||||
|
|
||||||
public Extend getExtend() {
|
@Override
|
||||||
return extend;
|
public void setParent(${ClassName} parent) {
|
||||||
}
|
this.parent = parent;
|
||||||
|
}
|
||||||
public void setExtend(Extend extend) {
|
<%
|
||||||
this.extend = extend;
|
}
|
||||||
}
|
|
||||||
<%
|
// 生成属性的get和set方法
|
||||||
}
|
isExtend = false;
|
||||||
// 如果不是基类属性
|
for(c in table.columnList){
|
||||||
}else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
// 如果是Extend类属性
|
||||||
%>
|
if(c.isExtendColumn){
|
||||||
|
if(!isExtend){
|
||||||
<%
|
isExtend = true;
|
||||||
// 父类对象
|
%>
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
|
||||||
%>
|
public Extend getExtend() {
|
||||||
public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() {
|
return extend;
|
||||||
return ${c.simpleAttrName};
|
}
|
||||||
}
|
|
||||||
|
public void setExtend(Extend extend) {
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) {
|
this.extend = extend;
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
}
|
||||||
}
|
<%
|
||||||
<%
|
}
|
||||||
// 其它字段
|
// 如果不是基类属性
|
||||||
}else{
|
}else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||||
for(a in c.simpleAnnotationList){
|
%>
|
||||||
%>
|
|
||||||
@${a}
|
<%
|
||||||
<%
|
// 父类对象
|
||||||
}
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
%>
|
%>
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() {
|
public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||||
return ${c.simpleAttrName};
|
return ${c.simpleAttrName};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) {
|
public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) {
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
}
|
}
|
||||||
<%
|
<%
|
||||||
}
|
// 其它字段
|
||||||
}
|
}else{
|
||||||
}
|
for(a in c.simpleAnnotationList){
|
||||||
|
%>
|
||||||
// 生成条件字段get和set方法(范围类型)
|
@${a}
|
||||||
for(c in table.columnList){
|
<%
|
||||||
if(c.isQuery == "1" && c.queryType == "BETWEEN"){
|
}
|
||||||
%>
|
%>
|
||||||
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() {
|
return ${c.simpleAttrName};
|
||||||
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE);
|
}
|
||||||
}
|
|
||||||
|
public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
sqlMap.getWhere().and("${c.columnName}", QueryType.GTE, ${c.simpleAttrName});
|
}
|
||||||
}
|
<%
|
||||||
|
}
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_lte() {
|
}
|
||||||
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.LTE);
|
}
|
||||||
}
|
|
||||||
|
// 生成条件字段get和set方法(范围类型)
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
for(c in table.columnList){
|
||||||
sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName});
|
if(c.isQuery == "1" && c.queryType == "BETWEEN"){
|
||||||
}
|
%>
|
||||||
<%
|
|
||||||
}
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() {
|
||||||
}
|
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE);
|
||||||
|
}
|
||||||
// 生成子表列表get和set方法
|
|
||||||
for(child in table.childList){
|
public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
%>
|
sqlMap.getWhere().and("${c.columnName}", QueryType.GTE, ${c.simpleAttrName});
|
||||||
|
}
|
||||||
@Valid
|
|
||||||
public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() {
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_lte() {
|
||||||
return ${@StringUtils.uncap(child.className)}List;
|
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.LTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set${@StringUtils.cap(child.className)}List(List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List) {
|
public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
this.${@StringUtils.uncap(child.className)}List = ${@StringUtils.uncap(child.className)}List;
|
sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName});
|
||||||
}
|
}
|
||||||
<% } %>
|
<%
|
||||||
|
}
|
||||||
}]]>
|
}
|
||||||
</content>
|
|
||||||
|
// 生成子表列表get和set方法
|
||||||
|
for(child in table.childList){
|
||||||
|
%>
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() {
|
||||||
|
return ${@StringUtils.uncap(child.className)}List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set${@StringUtils.cap(child.className)}List(List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List) {
|
||||||
|
this.${@StringUtils.uncap(child.className)}List = ${@StringUtils.uncap(child.className)}List;
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
}]]>
|
||||||
|
</content>
|
||||||
</template>
|
</template>
|
||||||
@@ -23,9 +23,11 @@ import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModule
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.service.ServiceException;
|
|
||||||
import com.jeesite.modules.bpm.utils.BpmUtils;
|
import com.jeesite.modules.bpm.utils.BpmUtils;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.service.ServiceException;
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -33,6 +35,14 @@ import com.jeesite.modules.file.utils.FileUploadUtils;
|
|||||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
||||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.validator.ValidatorUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelImport;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service
|
* ${functionName}Service
|
||||||
@@ -180,6 +190,57 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
* @param file 导入的数据文件
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
if (file == null){
|
||||||
|
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||||
|
}
|
||||||
|
int successNum = 0; int failureNum = 0;
|
||||||
|
StringBuilder successMsg = new StringBuilder();
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||||
|
List<${ClassName}> list = ei.getDataList(${ClassName}.class);
|
||||||
|
for (${ClassName} ${className} : list) {
|
||||||
|
try{
|
||||||
|
ValidatorUtils.validateWithException(${className});
|
||||||
|
this.save(${className});
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>" + successNum + "、编号 " + ${className}.getId() + " 导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、编号 " + ${className}.getId() + " 导入失败:";
|
||||||
|
if (e instanceof ConstraintViolationException){
|
||||||
|
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||||
|
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||||
|
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg += e.getMessage();
|
||||||
|
}
|
||||||
|
failureMsg.append(msg);
|
||||||
|
logger.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
failureMsg.append(e.getMessage());
|
||||||
|
return failureMsg.toString();
|
||||||
|
}
|
||||||
|
if (failureNum > 0) {
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
}else{
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新状态
|
* 更新状态
|
||||||
|
|||||||
@@ -15,11 +15,20 @@ import { defHttp } from '/@/utils/http/axios';
|
|||||||
import { useGlobSetting } from '/@/hooks/setting';
|
import { useGlobSetting } from '/@/hooks/setting';
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity){ %>
|
||||||
import { TreeDataModel, TreeModel } from '../model/baseModel';
|
import { TreeDataModel, TreeModel } from '../model/baseModel';
|
||||||
|
<% }else if(isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
import { BasicModel, Page, TreeDataModel } from '../model/baseModel';
|
||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import { BasicModel, Page } from '../model/baseModel';
|
import { BasicModel, Page } from '../model/baseModel';
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import { UploadApiResult } from '../sys/upload';
|
||||||
|
import { UploadFileParams } from '/#/axios';
|
||||||
|
|
||||||
|
const { ctxPath, adminPath } = useGlobSetting();
|
||||||
|
<% }else{ %>
|
||||||
|
|
||||||
const { adminPath } = useGlobSetting();
|
const { adminPath } = useGlobSetting();
|
||||||
|
<% } %>
|
||||||
|
|
||||||
export interface ${ClassName} extends ${table.isTreeEntity?'Tree':'Basic'}Model<${ClassName}> {
|
export interface ${ClassName} extends ${table.isTreeEntity?'Tree':'Basic'}Model<${ClassName}> {
|
||||||
<%
|
<%
|
||||||
@@ -87,6 +96,20 @@ export const ${className}CreateNextNode = (params?: ${ClassName} | any) =>
|
|||||||
|
|
||||||
export const ${className}Save = (params?: any, data?: ${ClassName} | any) =>
|
export const ${className}Save = (params?: any, data?: ${ClassName} | any) =>
|
||||||
defHttp.postJson<${ClassName}>({ url: adminPath + '/${urlPrefix}/save', params, data });
|
defHttp.postJson<${ClassName}>({ url: adminPath + '/${urlPrefix}/save', params, data });
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
export const ${className}ImportData = (
|
||||||
|
params: UploadFileParams,
|
||||||
|
onUploadProgress: (progressEvent: ProgressEvent) => void,
|
||||||
|
) =>
|
||||||
|
defHttp.uploadFile<UploadApiResult>(
|
||||||
|
{
|
||||||
|
url: ctxPath + adminPath + '/${urlPrefix}/importData',
|
||||||
|
onUploadProgress,
|
||||||
|
},
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
export const ${className}Disable = (params?: ${ClassName} | any) =>
|
export const ${className}Disable = (params?: ${ClassName} | any) =>
|
||||||
@@ -98,7 +121,11 @@ export const ${className}Enable = (params?: ${ClassName} | any) =>
|
|||||||
|
|
||||||
export const ${className}Delete = (params?: ${ClassName} | any) =>
|
export const ${className}Delete = (params?: ${ClassName} | any) =>
|
||||||
defHttp.get<${ClassName}>({ url: adminPath + '/${urlPrefix}/delete', params });
|
defHttp.get<${ClassName}>({ url: adminPath + '/${urlPrefix}/delete', params });
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
|
||||||
|
export const ${className}TreeData = (params?: any) =>
|
||||||
|
defHttp.get<TreeDataModel[]>({ url: adminPath + '${table.optionMap['leftTreeRightTableUrl']}', params });
|
||||||
|
<% }else if(table.isTreeEntity){ %>
|
||||||
|
|
||||||
export const ${className}TreeData = (params?: any) =>
|
export const ${className}TreeData = (params?: any) =>
|
||||||
defHttp.get<TreeDataModel[]>({ url: adminPath + '/${urlPrefix}/treeData', params });
|
defHttp.get<TreeDataModel[]>({ url: adminPath + '/${urlPrefix}/treeData', params });
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
No deletion without permission, or be held responsible to law. -->
|
||||||
|
<template>
|
||||||
|
<name>formImport</name>
|
||||||
|
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
||||||
|
<fileName>formImport.vue</fileName>
|
||||||
|
<content><![CDATA[
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<!--
|
||||||
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
* No deletion without permission, or be held responsible to law.
|
||||||
|
* @author ${functionAuthor}
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
:title="t('导入${functionNameSimple}')"
|
||||||
|
:okText="t('导入')"
|
||||||
|
@register="registerModal"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
:minHeight="120"
|
||||||
|
:width="400"
|
||||||
|
>
|
||||||
|
<Upload
|
||||||
|
accept=".xls,.xlsx"
|
||||||
|
:file-list="fileList"
|
||||||
|
:remove="handleRemove"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
>
|
||||||
|
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
||||||
|
<span class="ml-4">{{ uploadInfo }}</span>
|
||||||
|
</Upload>
|
||||||
|
<div class="ml-4 mt-4">
|
||||||
|
{{ t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}
|
||||||
|
</div>
|
||||||
|
<div class="mt-4">
|
||||||
|
<a-button @click="handleDownloadTemplate()" type="text">
|
||||||
|
<Icon icon="fa:file-excel-o" />
|
||||||
|
{{ t('下载模板') }}
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { Upload } from 'ant-design-vue';
|
||||||
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { useGlobSetting } from '/@/hooks/setting';
|
||||||
|
import { downloadByUrl } from '/@/utils/file/download';
|
||||||
|
import { Icon } from '/@/components/Icon';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { ${className}ImportData } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'register']);
|
||||||
|
|
||||||
|
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
||||||
|
const { showMessage, showMessageModal } = useMessage();
|
||||||
|
|
||||||
|
const fileList = ref([]);
|
||||||
|
const uploadInfo = ref('');
|
||||||
|
|
||||||
|
const beforeUpload = (file: never) => {
|
||||||
|
fileList.value = [file];
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemove = () => {
|
||||||
|
fileList.value = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
|
||||||
|
fileList.value = [];
|
||||||
|
uploadInfo.value = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
async function handleDownloadTemplate() {
|
||||||
|
const { ctxAdminPath } = useGlobSetting();
|
||||||
|
downloadByUrl({
|
||||||
|
url: ctxAdminPath + '/${urlPrefix}/importTemplate',
|
||||||
|
target: '_self',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUploadProgress(progressEvent: ProgressEvent) {
|
||||||
|
const complete = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
|
||||||
|
if (complete != 100) {
|
||||||
|
uploadInfo.value = t('正在导入,请稍后') + ' ' + complete + '%...';
|
||||||
|
} else {
|
||||||
|
uploadInfo.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
if (fileList.value.length == 0) {
|
||||||
|
showMessage(t('请选择要导入的数据文件'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
const params = {
|
||||||
|
file: fileList.value[0],
|
||||||
|
};
|
||||||
|
const { data } = await ${className}ImportData(params, onUploadProgress);
|
||||||
|
showMessageModal({ content: data.message });
|
||||||
|
setTimeout(closeModal);
|
||||||
|
emit('success');
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error && error.errorFields) {
|
||||||
|
showMessage(t('您填写的信息有误,请根据提示修正。'));
|
||||||
|
}
|
||||||
|
console.log('error', error);
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
<% %>
|
||||||
|
]]>
|
||||||
|
</content>
|
||||||
|
</template>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
||||||
<fileName>index.vue</fileName>
|
<fileName>index.vue</fileName>
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
<!--
|
<!--
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
* No deletion without permission, or be held responsible to law.
|
* No deletion without permission, or be held responsible to law.
|
||||||
|
|||||||
@@ -27,6 +27,14 @@
|
|||||||
<Icon icon="bi:chevron-double-up" /> {{ t('折叠') }}
|
<Icon icon="bi:chevron-double-up" /> {{ t('折叠') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a-button type="default" @click="handleExport()">
|
||||||
|
<Icon icon="ant-design:download-outlined" /> {{ t('导出') }}
|
||||||
|
</a-button>
|
||||||
|
<a-button type="default" @click="handleImport()">
|
||||||
|
<Icon icon="ant-design:upload-outlined" /> {{ t('导入') }}
|
||||||
|
</a-button>
|
||||||
|
<% } %>
|
||||||
<a-button type="primary" @click="handleForm({})" v-auth="'${permissionPrefix}:edit'">
|
<a-button type="primary" @click="handleForm({})" v-auth="'${permissionPrefix}:edit'">
|
||||||
<Icon icon="fluent:add-12-filled" /> {{ t('新增') }}
|
<Icon icon="fluent:add-12-filled" /> {{ t('新增') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
@@ -72,6 +80,9 @@ if(table.isTreeEntity){
|
|||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
<BpmRuntimeTrace @register="registerTraceModal" />
|
<BpmRuntimeTrace @register="registerTraceModal" />
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -83,9 +94,14 @@ if(table.isTreeEntity){
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineComponent<% if(table.isTreeEntity){ %>, watch, nextTick<% } %> } from 'vue';
|
import { defineComponent<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>, watch<% }
|
||||||
|
%><% if(table.isTreeEntity){ %>, nextTick<% } %> } from 'vue';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import { useGlobSetting } from '/@/hooks/setting';
|
||||||
|
import { downloadByUrl } from '/@/utils/file/download';
|
||||||
|
<% } %>
|
||||||
import { router } from '/@/router';
|
import { router } from '/@/router';
|
||||||
import { Icon } from '/@/components/Icon';
|
import { Icon } from '/@/components/Icon';
|
||||||
import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
|
import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
|
||||||
@@ -116,14 +132,19 @@ for(c in table.columnList){
|
|||||||
import { areaTreeData } from '/@/api/sys/area';
|
import { areaTreeData } from '/@/api/sys/area';
|
||||||
<% } %>
|
<% } %>
|
||||||
import { useDrawer } from '/@/components/Drawer';
|
import { useDrawer } from '/@/components/Drawer';
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
||||||
<% } %>
|
<% } %>
|
||||||
import { FormProps } from '/@/components/Form';
|
import { FormProps } from '/@/components/Form';
|
||||||
import InputForm from './form.vue';
|
import InputForm from './form.vue';
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import FormImport from './formImport.vue';
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
treeCode: String,
|
treeCode: String,
|
||||||
});
|
});
|
||||||
@@ -360,14 +381,9 @@ for(c in table.columnList){
|
|||||||
};
|
};
|
||||||
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||||
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %> }] = useTable({
|
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %>, getForm }] = useTable({
|
||||||
api: ${className}ListData,
|
api: ${className}ListData,
|
||||||
beforeFetch: (params) => {
|
beforeFetch: (params) => {
|
||||||
<% if(table.isTreeEntity){ %>
|
|
||||||
<% for(pk in table.pkList){ %>
|
|
||||||
params.${pk.attrName} = props.treeCode;
|
|
||||||
<% } %>
|
|
||||||
<% } %>
|
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
columns: tableColumns,
|
columns: tableColumns,
|
||||||
@@ -381,14 +397,25 @@ for(c in table.columnList){
|
|||||||
<% } %>
|
<% } %>
|
||||||
canResize: true,
|
canResize: true,
|
||||||
});
|
});
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.treeCode,
|
() => props.treeCode,
|
||||||
() => {
|
async () => {
|
||||||
|
await getForm().setFieldsValue({
|
||||||
|
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
|
'${table.optionMap['leftTreeRightTableFk']}': props.treeCode,
|
||||||
|
<% }else if(table.isTreeEntity){ %>
|
||||||
|
<% for(pk in table.pkList){ %>
|
||||||
|
'${pk.attrName}': props.treeCode,
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
|
});
|
||||||
reload();
|
reload();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
|
|
||||||
function fetchSuccess() {
|
function fetchSuccess() {
|
||||||
if (props.treeCode) {
|
if (props.treeCode) {
|
||||||
@@ -400,6 +427,22 @@ for(c in table.columnList){
|
|||||||
function handleForm(record: Recordable) {
|
function handleForm(record: Recordable) {
|
||||||
openDrawer(true, record);
|
openDrawer(true, record);
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
async function handleExport() {
|
||||||
|
const { ctxAdminPath } = useGlobSetting();
|
||||||
|
downloadByUrl({
|
||||||
|
url: ctxAdminPath + '/${urlPrefix}/exportData',
|
||||||
|
target: '_self',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const [registerImportModal, { openModal: importModal }] = useModal();
|
||||||
|
|
||||||
|
function handleImport() {
|
||||||
|
importModal(true, {});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
async function handleDisable(record: Recordable) {
|
async function handleDisable(record: Recordable) {
|
||||||
|
|||||||
@@ -9,9 +9,10 @@
|
|||||||
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% if (table.isTreeEntity){ %>
|
<% if (table.isTreeEntity){ %>
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
<% }else{ %>
|
<% } %>
|
||||||
|
<% if (!table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -27,8 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
import com.jeesite.common.config.Global;
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.idgen.IdGen;
|
import com.jeesite.common.idgen.IdGen;
|
||||||
@@ -36,6 +39,12 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.lang.DateUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelExport;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
<% } %>
|
||||||
<% if (table.tplCategory == 'crud_select'){ %>
|
<% if (table.tplCategory == 'crud_select'){ %>
|
||||||
import com.alibaba.fastjson.JSONValidator;
|
import com.alibaba.fastjson.JSONValidator;
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
@@ -75,8 +84,8 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
return ${className}Service.getAndValid(${className});
|
return ${className}Service.getAndValid(${className});
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理主页
|
* 管理主页
|
||||||
*/
|
*/
|
||||||
@@ -204,6 +213,50 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
${className}Service.save(${className});
|
${className}Service.save(${className});
|
||||||
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "exportData")
|
||||||
|
public void exportData(${ClassName} ${className}, HttpServletResponse response) {
|
||||||
|
List<${ClassName}> list = ${className}Service.findList(${className});
|
||||||
|
String fileName = "${functionNameSimple}" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "importTemplate")
|
||||||
|
public void importTemplate(HttpServletResponse response) {
|
||||||
|
${ClassName} ${className} = new ${ClassName}();
|
||||||
|
List<${ClassName}> list = ListUtils.newArrayList(${className});
|
||||||
|
String fileName = "${functionNameSimple}模板.xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class, Type.IMPORT)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("${permissionPrefix}:edit")
|
||||||
|
@PostMapping(value = "importData")
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
String message = ${className}Service.importData(file);
|
||||||
|
return renderResult(Global.TRUE, "posfull:"+message);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,356 +1,375 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
No deletion without permission, or be held responsible to law. -->
|
No deletion without permission, or be held responsible to law. -->
|
||||||
<template>
|
<template>
|
||||||
<name>entity</name>
|
<name>entity</name>
|
||||||
<filePath>${baseDir}/${moduleName}-client/src/main/java/${packagePath}/${moduleName}/entity/${subModuleName}</filePath>
|
<filePath>${baseDir}/${moduleName}-client/src/main/java/${packagePath}/${moduleName}/entity/${subModuleName}</filePath>
|
||||||
<fileName>${ClassName}.java</fileName>
|
<fileName>${ClassName}.java</fileName>
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% for(i in table.importList){ %>
|
<% if(table.childList.~size > 0){ %>
|
||||||
import ${i};
|
import javax.validation.Valid;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% for(i in table.importList){ %>
|
||||||
import com.jeesite.common.entity.DataEntity;
|
import ${i};
|
||||||
<% if(table.isTreeEntity){ %>
|
<% } %>
|
||||||
import com.jeesite.common.entity.TreeEntity;
|
|
||||||
<% } %>
|
import com.jeesite.common.entity.DataEntity;
|
||||||
import com.jeesite.common.mybatis.annotation.Column;
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.mybatis.annotation.Table;
|
import com.jeesite.common.entity.TreeEntity;
|
||||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
import com.jeesite.common.mybatis.annotation.Column;
|
||||||
<% if(table.isTreeEntity){ %>
|
import com.jeesite.common.mybatis.annotation.Table;
|
||||||
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||||
<% }else{ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
<% if(table.isTreeEntity){ %>
|
||||||
<% } %>
|
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
||||||
<% } %>
|
<% }else{ %>
|
||||||
|
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||||
/**
|
<% } %>
|
||||||
* ${functionName}Entity
|
<% } %>
|
||||||
* @author ${functionAuthor}
|
<% if(!table.parentExists && toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
* @version ${functionVersion}
|
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||||
*/
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||||
@Table(name="${table.genTableName}", alias="a", label="${functionNameSimple}信息", columns={
|
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||||
<%
|
<% } %>
|
||||||
var isBase = false, isData = false,
|
|
||||||
isTree = false, isExtend = false;
|
/**
|
||||||
// ◆ 生成字段属性
|
* ${functionName}Entity
|
||||||
for(c in table.columnList){
|
* @author ${functionAuthor}
|
||||||
// ● 如果是BaseEntity类属性
|
* @version ${functionVersion}
|
||||||
if(table.isBaseEntity && c.isBaseEntityColumn){
|
*/
|
||||||
if(!isBase){
|
@Table(name="${table.genTableName}", alias="a", label="${functionNameSimple}信息", columns={
|
||||||
isBase = true;
|
<%
|
||||||
%>
|
var isBase = false, isData = false,
|
||||||
@Column(includeEntity=BaseEntity.class),
|
isTree = false, isExtend = false;
|
||||||
<%
|
// ◆ 生成字段属性
|
||||||
}
|
for(c in table.columnList){
|
||||||
// ● 如果是DataEntity类属性
|
// ● 如果是BaseEntity类属性
|
||||||
}else if(table.isDataEntity && c.isDataEntityColumn){
|
if(table.isBaseEntity && c.isBaseEntityColumn){
|
||||||
if(!isData){
|
if(!isBase){
|
||||||
isData = true;
|
isBase = true;
|
||||||
%>
|
%>
|
||||||
@Column(includeEntity=DataEntity.class),
|
@Column(includeEntity=BaseEntity.class),
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
// ● 如果是TreeEntity类属性
|
// ● 如果是DataEntity类属性
|
||||||
}else if(table.isTreeEntity && c.isTreeEntityColumn){
|
}else if(table.isDataEntity && c.isDataEntityColumn){
|
||||||
if(!isTree){
|
if(!isData){
|
||||||
isTree = true;
|
isData = true;
|
||||||
%>
|
%>
|
||||||
@Column(includeEntity=TreeEntity.class),
|
@Column(includeEntity=DataEntity.class),
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
// ● 如果是Extend类属性
|
// ● 如果是TreeEntity类属性
|
||||||
}else if(table.isExtendEntity && c.isExtendColumn){
|
}else if(table.isTreeEntity && c.isTreeEntityColumn){
|
||||||
if(!isExtend){
|
if(!isTree){
|
||||||
isExtend = true;
|
isTree = true;
|
||||||
%>
|
%>
|
||||||
@Column(includeEntity=Extend.class, attrName="extend"),
|
@Column(includeEntity=TreeEntity.class),
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
// ● 其它情况下
|
// ● 如果是Extend类属性
|
||||||
}else{
|
}else if(table.isExtendEntity && c.isExtendColumn){
|
||||||
// 容错,如果没有设置父表的主键属性,则设置
|
if(!isExtend){
|
||||||
if(!@StringUtils.contains(c.attrName, ".")){
|
isExtend = true;
|
||||||
if (table.parentExists && table.parentTableFkName == c.columnName){
|
%>
|
||||||
for (pk in table.parent.pkList){
|
@Column(includeEntity=Extend.class, attrName="extend"),
|
||||||
c.fullAttrName = c.fullAttrName + '.' + pk.attrName;
|
<%
|
||||||
break;
|
}
|
||||||
}
|
// ● 其它情况下
|
||||||
}
|
}else{
|
||||||
}
|
// 容错,如果没有设置父表的主键属性,则设置
|
||||||
%>
|
if(!@StringUtils.contains(c.attrName, ".")){
|
||||||
@Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<%
|
if (table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
if (c.comments != c.columnLabel){
|
for (pk in table.parent.pkList){
|
||||||
print(', comment="'+c.comments+'"');
|
c.fullAttrName = c.fullAttrName + '.' + pk.attrName;
|
||||||
}
|
break;
|
||||||
if (c.isPk == @Global.YES){
|
}
|
||||||
print(', isPK=true');
|
}
|
||||||
}else{
|
}
|
||||||
if (c.isInsert != @Global.YES){
|
%>
|
||||||
print(', isInsert=false');
|
@Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<%
|
||||||
}
|
if (c.comments != c.columnLabel){
|
||||||
if (c.isUpdate != @Global.YES){
|
print(', comment="'+c.comments+'"');
|
||||||
print(', isUpdate=false');
|
}
|
||||||
}
|
if (c.isPk == @Global.YES){
|
||||||
if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType,
|
print(', isPK=true');
|
||||||
'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){
|
}else{
|
||||||
print(', queryType=QueryType.'+c.queryType);
|
if (c.isInsert != @Global.YES){
|
||||||
}
|
print(', isInsert=false');
|
||||||
if (c.isQuery != @Global.YES){
|
}
|
||||||
print(', isQuery=false');
|
if (c.isUpdate != @Global.YES){
|
||||||
}
|
print(', isUpdate=false');
|
||||||
if (c.attrName == table.treeViewNameAttrName){
|
}
|
||||||
print(', isTreeName=true');
|
if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType,
|
||||||
}
|
'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){
|
||||||
if (c.isNull == @Global.YES && @StringUtils.inString(c.simpleAttrType,
|
print(', queryType=QueryType.'+c.queryType);
|
||||||
'Long', 'Integer', 'Double', 'BigDecimal', 'Date')){
|
}
|
||||||
print(', isUpdateForce=true');
|
if (c.isQuery != @Global.YES){
|
||||||
}
|
print(', isQuery=false');
|
||||||
}
|
}
|
||||||
%>),
|
if (c.attrName == table.treeViewNameAttrName){
|
||||||
<%
|
print(', isTreeName=true');
|
||||||
}
|
}
|
||||||
}
|
if (c.isNull == @Global.YES && @StringUtils.inString(c.simpleAttrType,
|
||||||
%>
|
'Long', 'Integer', 'Double', 'BigDecimal', 'Date')){
|
||||||
}, <%
|
print(', isUpdateForce=true');
|
||||||
// ◆ 生成关联表
|
}
|
||||||
var joinTables = '';
|
}
|
||||||
for(c in table.columnList){
|
%>),
|
||||||
if (c.attrType == 'com.jeesite.modules.sys.entity.User'){
|
<%
|
||||||
var joinTable = {
|
}
|
||||||
%>
|
}
|
||||||
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
%>
|
||||||
on="u${cLP.index}.user_code = a.${c.columnName}", columns={
|
}, <%
|
||||||
@Column(name="user_code", label="用户编码", isPK=true),
|
// ◆ 生成关联表
|
||||||
@Column(name="user_name", label="用户名称", isQuery=false),
|
var joinTables = '';
|
||||||
}),
|
for(c in table.columnList){
|
||||||
<%
|
if (c.attrType == 'com.jeesite.modules.sys.entity.User'){
|
||||||
};
|
var joinTable = {
|
||||||
joinTables = joinTables + joinTable;
|
%>
|
||||||
}
|
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
||||||
else if (c.attrType == 'com.jeesite.modules.sys.entity.Office'){
|
on="u${cLP.index}.user_code = a.${c.columnName}", columns={
|
||||||
var joinTable = {
|
@Column(name="user_code", label="用户编码", isPK=true),
|
||||||
%>
|
@Column(name="user_name", label="用户名称", isQuery=false),
|
||||||
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
}),
|
||||||
on="u${cLP.index}.office_code = a.${c.columnName}", columns={
|
<%
|
||||||
@Column(name="office_code", label="机构编码", isPK=true),
|
};
|
||||||
@Column(name="office_name", label="机构名称", isQuery=false),
|
joinTables = joinTables + joinTable;
|
||||||
}),
|
}
|
||||||
<%
|
else if (c.attrType == 'com.jeesite.modules.sys.entity.Office'){
|
||||||
};
|
var joinTable = {
|
||||||
joinTables = joinTables + joinTable;
|
%>
|
||||||
}
|
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}",
|
||||||
}
|
on="u${cLP.index}.office_code = a.${c.columnName}", columns={
|
||||||
if (isNotBlank(joinTables)){
|
@Column(name="office_code", label="机构编码", isPK=true),
|
||||||
print('joinTable={');
|
@Column(name="office_name", label="机构名称", isQuery=false),
|
||||||
print(joinTables);
|
}),
|
||||||
print('}, ');
|
<%
|
||||||
}
|
};
|
||||||
// ◆ 生成排序字段
|
joinTables = joinTables + joinTable;
|
||||||
%>orderBy="<% if (isTree){
|
}
|
||||||
%>a.tree_sorts<%
|
}
|
||||||
for(pk in table.pkList){
|
if (isNotBlank(joinTables)){
|
||||||
%>, a.${pk.columnName}<%
|
print('joinTable={');
|
||||||
}
|
print(joinTables);
|
||||||
}else if(table.parentExists && table.createDateExists){
|
print('}, ');
|
||||||
%>a.create_date ASC<%
|
}
|
||||||
}else if(table.updateDateExists){
|
// ◆ 生成排序字段
|
||||||
%>a.update_date DESC<%
|
%>orderBy="<% if (isTree){
|
||||||
}else{
|
%>a.tree_sorts<%
|
||||||
for(pk in table.pkList){
|
for(pk in table.pkList){
|
||||||
%>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<%
|
%>, a.${pk.columnName}<%
|
||||||
}
|
}
|
||||||
} %>"
|
}else if(table.parentExists && table.createDateExists){
|
||||||
)
|
%>a.create_date ASC<%
|
||||||
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
}else if(table.updateDateExists){
|
||||||
|
%>a.update_date DESC<%
|
||||||
private static final long serialVersionUID = 1L;
|
}else{
|
||||||
<%
|
for(pk in table.pkList){
|
||||||
isExtend = false;
|
%>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<%
|
||||||
// 生成字段属性
|
}
|
||||||
for(c in table.columnList){
|
} %>"
|
||||||
// 如果是Extend类属性
|
)
|
||||||
if(table.isExtendEntity && c.isExtendColumn){
|
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
||||||
if(!isExtend){
|
|
||||||
isExtend = true;
|
private static final long serialVersionUID = 1L;
|
||||||
%>
|
<%
|
||||||
private Extend extend; // 扩展字段
|
isExtend = false;
|
||||||
<%
|
// 生成字段属性
|
||||||
}
|
for(c in table.columnList){
|
||||||
}
|
// 如果是Extend类属性
|
||||||
// 如果不是基类属性
|
if(table.isExtendEntity && c.isExtendColumn){
|
||||||
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
if(!isExtend){
|
||||||
// 父类对象
|
isExtend = true;
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
%>
|
||||||
%>
|
private Extend extend; // 扩展字段
|
||||||
private ${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}; <% if (isNotBlank(c.comments)){ %>// ${c.comments} 父类<% } %>
|
<%
|
||||||
<%
|
}
|
||||||
// 其它字段
|
}
|
||||||
}else{
|
// 如果不是基类属性
|
||||||
%>
|
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||||
private ${c.simpleAttrType} ${c.simpleAttrName}; <%if(isNotBlank(c.comments)){%>// ${c.comments}<%}%>
|
// 父类对象
|
||||||
<%
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
}
|
%>
|
||||||
}
|
private ${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}; <% if (isNotBlank(c.comments)){ %>// ${c.comments} 父类<% } %>
|
||||||
}
|
<%
|
||||||
|
// 其它字段
|
||||||
// 生成子表列表字段
|
}else{
|
||||||
for(child in table.childList){
|
%>
|
||||||
%>
|
private ${c.simpleAttrType} ${c.simpleAttrName}; <%if(isNotBlank(c.comments)){%>// ${c.comments}<%}%>
|
||||||
private List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List = ListUtils.newArrayList(); // 子表列表
|
<%
|
||||||
<%
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 生成构造方法
|
|
||||||
%>
|
// 生成子表列表字段
|
||||||
|
for(child in table.childList){
|
||||||
public ${ClassName}() {
|
%>
|
||||||
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
private List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List = ListUtils.newArrayList(); // 子表列表
|
||||||
}
|
<%
|
||||||
<%
|
}
|
||||||
// 生成带主键参数的构造
|
|
||||||
if (!table.parentExists){
|
// 生成构造方法
|
||||||
if (table.pkList.~size == 1){ %>
|
%>
|
||||||
|
|
||||||
public ${ClassName}(String id){
|
<% if(!table.parentExists && toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
super(id);
|
@ExcelFields({
|
||||||
}
|
<% for(c in table.columnList){ if(c.optionMap['isImportExport'] == @Global.YES){ %>
|
||||||
<% }else{ %>
|
@ExcelField(title="${c.columnLabel}", attrName="${c.attrName}"${
|
||||||
|
isNotBlank(c.optionMap['dictType'])?', dictType="'+c.optionMap['dictType']+'"':''
|
||||||
public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){
|
}, align=Align.CENTER, sort=${c.columnSort}${
|
||||||
<% for(pk in table.pkList){ %>
|
c.showType == 'date'?', dataFormat="yyyy-MM-dd"':c.showType == 'datetime'?', dataFormat="yyyy-MM-dd hh:mm"':''
|
||||||
this.${pk.simpleAttrName} = ${pk.simpleAttrName};
|
}),
|
||||||
<% } %>
|
<% } } %>
|
||||||
}
|
})
|
||||||
<%
|
<% } %>
|
||||||
}
|
public ${ClassName}() {
|
||||||
}
|
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
||||||
|
}
|
||||||
// 生成父表参数的构造
|
<%
|
||||||
else{
|
// 生成带主键参数的构造
|
||||||
for(c in table.columnList){
|
if (!table.parentExists){
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
if (table.pkList.~size == 1){ %>
|
||||||
%>
|
|
||||||
|
public ${ClassName}(String id){
|
||||||
public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){
|
super(id);
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
}
|
||||||
}
|
<% }else{ %>
|
||||||
<%
|
|
||||||
}
|
public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){
|
||||||
}
|
<% for(pk in table.pkList){ %>
|
||||||
}
|
this.${pk.simpleAttrName} = ${pk.simpleAttrName};
|
||||||
|
<% } %>
|
||||||
// 如果是树实体,则输出相应方法
|
}
|
||||||
if (table.isTreeEntity){
|
<%
|
||||||
%>
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public ${ClassName} getParent() {
|
// 生成父表参数的构造
|
||||||
return parent;
|
else{
|
||||||
}
|
for(c in table.columnList){
|
||||||
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
@Override
|
%>
|
||||||
public void setParent(${ClassName} parent) {
|
|
||||||
this.parent = parent;
|
public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){
|
||||||
}
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
<%
|
}
|
||||||
}
|
<%
|
||||||
|
}
|
||||||
// 生成属性的get和set方法
|
}
|
||||||
isExtend = false;
|
}
|
||||||
for(c in table.columnList){
|
|
||||||
// 如果是Extend类属性
|
// 如果是树实体,则输出相应方法
|
||||||
if(c.isExtendColumn){
|
if (table.isTreeEntity){
|
||||||
if(!isExtend){
|
%>
|
||||||
isExtend = true;
|
|
||||||
%>
|
@Override
|
||||||
|
public ${ClassName} getParent() {
|
||||||
public Extend getExtend() {
|
return parent;
|
||||||
return extend;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public void setExtend(Extend extend) {
|
public void setParent(${ClassName} parent) {
|
||||||
this.extend = extend;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
// 如果不是基类属性
|
|
||||||
}else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
// 生成属性的get和set方法
|
||||||
%>
|
isExtend = false;
|
||||||
|
for(c in table.columnList){
|
||||||
<%
|
// 如果是Extend类属性
|
||||||
// 父类对象
|
if(c.isExtendColumn){
|
||||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
if(!isExtend){
|
||||||
%>
|
isExtend = true;
|
||||||
public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() {
|
%>
|
||||||
return ${c.simpleAttrName};
|
|
||||||
}
|
public Extend getExtend() {
|
||||||
|
return extend;
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) {
|
}
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
|
||||||
}
|
public void setExtend(Extend extend) {
|
||||||
<%
|
this.extend = extend;
|
||||||
// 其它字段
|
}
|
||||||
}else{
|
<%
|
||||||
for(a in c.simpleAnnotationList){
|
}
|
||||||
%>
|
// 如果不是基类属性
|
||||||
@${a}
|
}else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||||
<%
|
%>
|
||||||
}
|
|
||||||
%>
|
<%
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() {
|
// 父类对象
|
||||||
return ${c.simpleAttrName};
|
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||||
}
|
%>
|
||||||
|
public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) {
|
return ${c.simpleAttrName};
|
||||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
}
|
||||||
}
|
|
||||||
<%
|
public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) {
|
||||||
}
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
}
|
}
|
||||||
}
|
<%
|
||||||
|
// 其它字段
|
||||||
// 生成条件字段get和set方法(范围类型)
|
}else{
|
||||||
for(c in table.columnList){
|
for(a in c.simpleAnnotationList){
|
||||||
if(c.isQuery == "1" && c.queryType == "BETWEEN"){
|
%>
|
||||||
%>
|
@${a}
|
||||||
|
<%
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() {
|
}
|
||||||
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE);
|
%>
|
||||||
}
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||||
|
return ${c.simpleAttrName};
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
}
|
||||||
sqlMap.getWhere().and("${c.columnName}", QueryType.GTE, ${c.simpleAttrName});
|
|
||||||
}
|
public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
|
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_lte() {
|
}
|
||||||
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.LTE);
|
<%
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
}
|
||||||
sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName});
|
|
||||||
}
|
// 生成条件字段get和set方法(范围类型)
|
||||||
<%
|
for(c in table.columnList){
|
||||||
}
|
if(c.isQuery == "1" && c.queryType == "BETWEEN"){
|
||||||
}
|
%>
|
||||||
|
|
||||||
// 生成子表列表get和set方法
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() {
|
||||||
for(child in table.childList){
|
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE);
|
||||||
%>
|
}
|
||||||
|
|
||||||
@Valid
|
public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() {
|
sqlMap.getWhere().and("${c.columnName}", QueryType.GTE, ${c.simpleAttrName});
|
||||||
return ${@StringUtils.uncap(child.className)}List;
|
}
|
||||||
}
|
|
||||||
|
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_lte() {
|
||||||
public void set${@StringUtils.cap(child.className)}List(List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List) {
|
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.LTE);
|
||||||
this.${@StringUtils.uncap(child.className)}List = ${@StringUtils.uncap(child.className)}List;
|
}
|
||||||
}
|
|
||||||
<% } %>
|
public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||||
|
sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName});
|
||||||
}]]>
|
}
|
||||||
</content>
|
<%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成子表列表get和set方法
|
||||||
|
for(child in table.childList){
|
||||||
|
%>
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() {
|
||||||
|
return ${@StringUtils.uncap(child.className)}List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set${@StringUtils.cap(child.className)}List(List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List) {
|
||||||
|
this.${@StringUtils.uncap(child.className)}List = ${@StringUtils.uncap(child.className)}List;
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
}]]>
|
||||||
|
</content>
|
||||||
</template>
|
</template>
|
||||||
@@ -25,8 +25,10 @@ import ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModule
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
|
import com.jeesite.modules.bpm.utils.BpmUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.service.ServiceException;
|
import com.jeesite.common.service.ServiceException;
|
||||||
import com.jeesite.modules.bpm.utils.client.BpmUtils;
|
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||||
@@ -35,6 +37,14 @@ import com.jeesite.modules.file.utils.FileUploadUtils;
|
|||||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
||||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.validator.ValidatorUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelImport;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
import io.seata.spring.annotation.GlobalTransactional;
|
import io.seata.spring.annotation.GlobalTransactional;
|
||||||
|
|
||||||
@@ -187,6 +197,58 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
* @param file 导入的数据文件
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@GlobalTransactional
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
if (file == null){
|
||||||
|
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||||
|
}
|
||||||
|
int successNum = 0; int failureNum = 0;
|
||||||
|
StringBuilder successMsg = new StringBuilder();
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||||
|
List<${ClassName}> list = ei.getDataList(${ClassName}.class);
|
||||||
|
for (${ClassName} ${className} : list) {
|
||||||
|
try{
|
||||||
|
ValidatorUtils.validateWithException(${className});
|
||||||
|
this.save(${className});
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>" + successNum + "、编号 " + ${className}.getId() + " 导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、编号 " + ${className}.getId() + " 导入失败:";
|
||||||
|
if (e instanceof ConstraintViolationException){
|
||||||
|
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||||
|
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||||
|
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg += e.getMessage();
|
||||||
|
}
|
||||||
|
failureMsg.append(msg);
|
||||||
|
logger.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
failureMsg.append(e.getMessage());
|
||||||
|
return failureMsg.toString();
|
||||||
|
}
|
||||||
|
if (failureNum > 0) {
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
}else{
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新状态
|
* 更新状态
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%/* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
<%/* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
* No deletion without permission, or be held responsible to law. */%>
|
* No deletion without permission, or be held responsible to law. */%>
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>
|
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>
|
||||||
<div class="ui-layout-west">
|
<div class="ui-layout-west">
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
@@ -36,12 +36,19 @@ $('body').layout({
|
|||||||
var win = $("#mainFrame")[0].contentWindow;
|
var win = $("#mainFrame")[0].contentWindow;
|
||||||
// 树结构初始化加载
|
// 树结构初始化加载
|
||||||
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
|
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
|
||||||
async:{enable:true,autoParam:["id=parentCode"],url:"\${ctx}/${urlPrefix}/treeData"},
|
async:{enable:true,autoParam:["id=parentCode"],url:"\${ctx}${
|
||||||
|
isNotBlank(table.optionMap['leftTreeRightTableUrl'])
|
||||||
|
?table.optionMap['leftTreeRightTableUrl']
|
||||||
|
:'/'+urlPrefix+'/treeData'}"},
|
||||||
callback:{onClick:function(event, treeId, treeNode){
|
callback:{onClick:function(event, treeId, treeNode){
|
||||||
tree.expandNode(treeNode);
|
tree.expandNode(treeNode);
|
||||||
//win.$('button[type=reset]').click();
|
//win.$('button[type=reset]').click();
|
||||||
<% for(pk in table.pkList){ %>
|
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
|
win.$('#searchForm [name="${table.optionMap['leftTreeRightTableFk']}"]').val(treeNode.id);
|
||||||
|
<% }else{ %>
|
||||||
|
<% for(pk in table.pkList){ %>
|
||||||
win.$('#${pk.attrName}').val(treeNode.id);
|
win.$('#${pk.attrName}').val(treeNode.id);
|
||||||
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
win.page();
|
win.page();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -14,7 +14,13 @@
|
|||||||
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
||||||
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a>
|
||||||
|
<% } %>
|
||||||
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnImport"><i class="glyphicon glyphicon-import"></i> ${text('导入')}</a>
|
||||||
|
<% } %>
|
||||||
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
||||||
@@ -30,4 +36,59 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>
|
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<script>
|
||||||
|
$('#btnExport').click(function(){
|
||||||
|
js.ajaxSubmitForm($('#searchForm'), {
|
||||||
|
url:'\${ctx}/${urlPrefix}/exportData',
|
||||||
|
downloadFile:true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#btnImport').click(function(){
|
||||||
|
js.layer.open({
|
||||||
|
type: 1,
|
||||||
|
area: ['400px'],
|
||||||
|
title: '\${text("导入${functionNameSimple}")}',
|
||||||
|
resize: false,
|
||||||
|
scrollbar: true,
|
||||||
|
content: js.template('importTpl'),
|
||||||
|
btn: ['<i class="fa fa-check"></i> \${text("导入")}',
|
||||||
|
'<i class="fa fa-remove"></i> \${text("关闭")}'],
|
||||||
|
btn1: function(index, layero){
|
||||||
|
var form = {
|
||||||
|
inputForm: layero.find('#inputForm'),
|
||||||
|
file: layero.find('#file').val()
|
||||||
|
};
|
||||||
|
if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
|
||||||
|
js.showMessage("\${text('文件不正确,请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
js.ajaxSubmitForm(form.inputForm, function(data){
|
||||||
|
js.showMessage(data.message);
|
||||||
|
if(data.result == Global.TRUE){
|
||||||
|
js.layer.closeAll();
|
||||||
|
}
|
||||||
|
page();
|
||||||
|
}, "json");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script id="importTpl" type="text/template">//<!--
|
||||||
|
<form id="inputForm" action="\${ctx}/${urlPrefix}/importData" method="post" enctype="multipart/form-data"
|
||||||
|
class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-xs-offset-1">
|
||||||
|
<input type="file" id="file" name="file" class="form-file"/>
|
||||||
|
<div class="mt10 pt5" style="color:red">
|
||||||
|
\${text('提示:仅允许导入“xls”或“xlsx”格式文件!')}
|
||||||
|
</div>
|
||||||
|
<div class="mt10 pt5">
|
||||||
|
<a href="\${ctx}/${urlPrefix}/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> \${text('下载模板')}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
//--></script><% } %>
|
||||||
Reference in New Issue
Block a user