新增 BPM 表单代码生成模板;Cloud 代码生成模块迁移到核心模块;
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved. -->
|
||||
<template>
|
||||
<name>controller</name>
|
||||
<filePath>${moduleName}-client/src/main/java/${packageName}/${moduleName}/api/${subModuleName}</filePath>
|
||||
<fileName>${ClassName}ServiceApi.java</fileName>
|
||||
<content><![CDATA[
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.jeesite.common.service.rest.CrudServiceRest;
|
||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName};
|
||||
|
||||
/**
|
||||
* ${functionName}API
|
||||
* @author ${functionAuthor}
|
||||
* @version ${functionVersion}
|
||||
*/
|
||||
@RequestMapping(value = "/inner/api/${urlPrefix}")
|
||||
public interface ${ClassName}ServiceApi extends ${table.isTreeEntity?'Tree':'Crud'}ServiceRest<${ClassName}> {
|
||||
|
||||
}]]>
|
||||
</content>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved. -->
|
||||
<template>
|
||||
<name>controller</name>
|
||||
<filePath>${moduleName}-client/src/main/java/${packageName}/${moduleName}/client/${subModuleName}</filePath>
|
||||
<fileName>${ClassName}ServiceClient.java</fileName>
|
||||
<content><![CDATA[
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package ${packageName}.${moduleName}.client${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.jeesite.modules.cloud.feign.condition.ConditionalOnNotCurrentApplication;
|
||||
import ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}ServiceApi;
|
||||
|
||||
/**
|
||||
* ${functionName}API
|
||||
* @author ${functionAuthor}
|
||||
* @version ${functionVersion}
|
||||
*/
|
||||
@FeignClient(name="\${service.${moduleName}.name}", path="\${service.${moduleName}.path}")
|
||||
@ConditionalOnNotCurrentApplication(name="\${service.${moduleName}.name}")
|
||||
public interface ${ClassName}ServiceClient extends ${ClassName}ServiceApi {
|
||||
|
||||
}]]>
|
||||
</content>
|
||||
</template>
|
||||
@@ -0,0 +1,352 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved. -->
|
||||
<template>
|
||||
<name>entity</name>
|
||||
<filePath>${moduleName}-client/src/main/java/${packageName}/${moduleName}/entity/${subModuleName}</filePath>
|
||||
<fileName>${ClassName}.java</fileName>
|
||||
<content><![CDATA[
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
||||
|
||||
<% for(i in table.importList){ %>
|
||||
import ${i};
|
||||
<% } %>
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
<% if(table.isTreeEntity){ %>
|
||||
import com.jeesite.common.entity.TreeEntity;
|
||||
<% } %>
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
<% if(table.isTreeEntity){ %>
|
||||
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
||||
<% }else{ %>
|
||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* ${functionName}Entity
|
||||
* @author ${functionAuthor}
|
||||
* @version ${functionVersion}
|
||||
*/
|
||||
@Table(name="${table.genTableName}", alias="a", columns={
|
||||
<%
|
||||
var isBase = false, isData = false,
|
||||
isTree = false, isExtend = false;
|
||||
// ◆ 生成字段属性
|
||||
for(c in table.columnList){
|
||||
// ● 如果是BaseEntity类属性
|
||||
if(table.isBaseEntity && c.isBaseEntityColumn){
|
||||
if(!isBase){
|
||||
isBase = true;
|
||||
%>
|
||||
@Column(includeEntity=BaseEntity.class),
|
||||
<%
|
||||
}
|
||||
// ● 如果是DataEntity类属性
|
||||
}else if(table.isDataEntity && c.isDataEntityColumn){
|
||||
if(!isData){
|
||||
isData = true;
|
||||
%>
|
||||
@Column(includeEntity=DataEntity.class),
|
||||
<%
|
||||
}
|
||||
// ● 如果是TreeEntity类属性
|
||||
}else if(table.isTreeEntity && c.isTreeEntityColumn){
|
||||
if(!isTree){
|
||||
isTree = true;
|
||||
%>
|
||||
@Column(includeEntity=TreeEntity.class),
|
||||
<%
|
||||
}
|
||||
// ● 如果是Extend类属性
|
||||
}else if(table.isExtendEntity && c.isExtendColumn){
|
||||
if(!isExtend){
|
||||
isExtend = true;
|
||||
%>
|
||||
@Column(includeEntity=Extend.class, attrName="extend"),
|
||||
<%
|
||||
}
|
||||
// ● 其它情况下
|
||||
}else{
|
||||
// 容错,如果没有设置父表的主键属性,则设置
|
||||
if(!@StringUtils.contains(c.attrName, ".")){
|
||||
if (table.parentExists && table.parentTableFkName == c.columnName){
|
||||
for (pk in table.parent.pkList){
|
||||
c.fullAttrName = c.fullAttrName + '.' + pk.attrName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
@Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<%
|
||||
if (c.comments != c.columnLabel){
|
||||
print(', comment="'+c.comments+'"');
|
||||
}
|
||||
if (c.isPk == @Global.YES){
|
||||
print(', isPK=true');
|
||||
}else{
|
||||
if (c.isInsert != @Global.YES){
|
||||
print(', isInsert=false');
|
||||
}
|
||||
if (c.isUpdate != @Global.YES){
|
||||
print(', isUpdate=false');
|
||||
}
|
||||
if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType,
|
||||
'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){
|
||||
print(', queryType=QueryType.'+c.queryType);
|
||||
}
|
||||
if (c.isQuery != @Global.YES){
|
||||
print(', isQuery=false');
|
||||
}
|
||||
if (c.attrName == table.treeViewNameAttrName){
|
||||
print(', isTreeName=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),
|
||||
}),
|
||||
<%
|
||||
};
|
||||
joinTables = joinTables + joinTable;
|
||||
}
|
||||
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}",
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (isNotBlank(joinTables)){
|
||||
print('joinTable={');
|
||||
print(joinTables);
|
||||
print('}, ');
|
||||
}
|
||||
// ◆ 生成排序字段
|
||||
%>orderBy="<% if (isTree){
|
||||
%>a.tree_sorts<%
|
||||
for(pk in table.pkList){
|
||||
%>, a.${pk.columnName}<%
|
||||
}
|
||||
}else if(table.parentExists && table.createDateExists){
|
||||
%>a.create_date ASC<%
|
||||
}else if(table.updateDateExists){
|
||||
%>a.update_date DESC<%
|
||||
}else{
|
||||
for(pk in table.pkList){
|
||||
%>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<%
|
||||
}
|
||||
} %>"
|
||||
)
|
||||
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<%
|
||||
isExtend = false;
|
||||
// 生成字段属性
|
||||
for(c in table.columnList){
|
||||
// 如果是Extend类属性
|
||||
if(table.isExtendEntity && c.isExtendColumn){
|
||||
if(!isExtend){
|
||||
isExtend = true;
|
||||
%>
|
||||
private Extend extend; // 扩展字段
|
||||
<%
|
||||
}
|
||||
}
|
||||
// 如果不是基类属性
|
||||
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||
// 父类对象
|
||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||
%>
|
||||
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(); // 子表列表
|
||||
<%
|
||||
}
|
||||
|
||||
// 生成构造方法
|
||||
%>
|
||||
|
||||
public ${ClassName}() {
|
||||
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
||||
}
|
||||
|
||||
<%
|
||||
// 生成带主键参数的构造
|
||||
if (!table.parentExists){
|
||||
if (table.pkList.~size == 1){ %>
|
||||
public ${ClassName}(String id){
|
||||
super(id);
|
||||
}
|
||||
<% }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};
|
||||
<% } %>
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// 生成父表参数的构造
|
||||
else{
|
||||
for(c in table.columnList){
|
||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||
%>
|
||||
|
||||
public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){
|
||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是树实体,则输出相应方法
|
||||
if (table.isTreeEntity){
|
||||
%>
|
||||
|
||||
@Override
|
||||
public ${ClassName} getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(${ClassName} parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
// 生成属性的get和set方法
|
||||
isExtend = false;
|
||||
for(c in table.columnList){
|
||||
// 如果是Extend类属性
|
||||
if(c.isExtendColumn){
|
||||
if(!isExtend){
|
||||
isExtend = true;
|
||||
%>
|
||||
|
||||
public Extend getExtend() {
|
||||
return extend;
|
||||
}
|
||||
|
||||
public void setExtend(Extend extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
<%
|
||||
}
|
||||
// 如果不是基类属性
|
||||
}else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
|
||||
%>
|
||||
|
||||
<%
|
||||
for(a in c.simpleAnnotationList){
|
||||
%>
|
||||
@${a}
|
||||
<%
|
||||
}
|
||||
// 父类对象
|
||||
if(table.parentExists && table.parentTableFkName == c.columnName){
|
||||
%>
|
||||
public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||
return ${c.simpleAttrName};
|
||||
}
|
||||
|
||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) {
|
||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||
}
|
||||
<%
|
||||
// 其它字段
|
||||
}else{
|
||||
%>
|
||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() {
|
||||
return ${c.simpleAttrName};
|
||||
}
|
||||
|
||||
public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||
this.${c.simpleAttrName} = ${c.simpleAttrName};
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 生成条件字段get和set方法(范围类型)
|
||||
for(c in table.columnList){
|
||||
if(c.isQuery == "1" && c.queryType == "BETWEEN"){
|
||||
%>
|
||||
|
||||
public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() {
|
||||
return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE);
|
||||
}
|
||||
|
||||
public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${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);
|
||||
}
|
||||
|
||||
public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) {
|
||||
sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName});
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// 生成子表列表get和set方法
|
||||
for(child in table.childList){
|
||||
%>
|
||||
|
||||
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>
|
||||
@@ -0,0 +1,216 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved. -->
|
||||
<template>
|
||||
<name>service</name>
|
||||
<filePath>src/main/java/${packageName}/${moduleName}/service/${subModuleName}</filePath>
|
||||
<fileName>${ClassName}Service.java</fileName>
|
||||
<content><![CDATA[
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package ${packageName}.${moduleName}.service${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||
|
||||
import java.util.List;
|
||||
|
||||
<% if (table.childList.~size > 0){ %>
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
<% } %>
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.${table.isTreeEntity?'Tree':'Crud'}Service;
|
||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName};
|
||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}Dao;
|
||||
import ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}ServiceApi;
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
import java.util.Map;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.modules.bpm.utils.client.BpmUtils;
|
||||
<% } %>
|
||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
<% } %>
|
||||
<% for (child in table.childList){ %>
|
||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* ${functionName}Service
|
||||
* @author ${functionAuthor}
|
||||
* @version ${functionVersion}
|
||||
*/
|
||||
@Service
|
||||
@RestController
|
||||
@Transactional(readOnly=true)
|
||||
public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Service<${ClassName}Dao, ${ClassName}>
|
||||
implements ${ClassName}ServiceApi {
|
||||
<% for (child in table.childList){ %>
|
||||
|
||||
@Autowired
|
||||
private ${@StringUtils.cap(child.className)}Dao ${@StringUtils.uncap(child.className)}Dao;
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param ${className}
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName} get(${ClassName} ${className}) {
|
||||
<% if (table.childList.~size > 0){ %>
|
||||
${ClassName} entity = super.get(${className});
|
||||
if (entity != null){
|
||||
<% for (child in table.childList){ %>
|
||||
${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}(entity);
|
||||
${@StringUtils.uncap(child.className)}.setStatus(${@StringUtils.cap(child.className)}.STATUS_NORMAL);
|
||||
entity.set${@StringUtils.cap(child.className)}List(${@StringUtils.uncap(child.className)}Dao.findList(${@StringUtils.uncap(child.className)}));
|
||||
<% } %>
|
||||
}
|
||||
return entity;
|
||||
<% }else{ %>
|
||||
return super.get(${className});
|
||||
<% } %>
|
||||
}
|
||||
<% if(!table.isTreeEntity){ %>
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param ${className} 查询条件
|
||||
* @param ${className}.page 分页对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<${ClassName}> findPage(${ClassName} ${className}) {
|
||||
return super.findPage(${className});
|
||||
}
|
||||
<% }else{ %>
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
* @param ${className}
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<${ClassName}> findList(${ClassName} ${className}) {
|
||||
return super.findList(${className});
|
||||
}
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* 保存数据(插入或更新)
|
||||
* @param ${className}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void save(${ClassName} ${className}) {
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
// 如果未设置状态,则指定状态为审核状态,以提交审核流程
|
||||
if (StringUtils.isBlank(${className}.getStatus())){
|
||||
${className}.setStatus(${ClassName}.STATUS_AUDIT);
|
||||
}
|
||||
|
||||
// 如果状态为正常,则代表不正常操作,可能前端进行了数据参数修改
|
||||
if (${ClassName}.STATUS_NORMAL.equals(${className}.getStatus())){
|
||||
throw new ServiceException(text("非法操作,前端数据被劫持!"));
|
||||
}
|
||||
|
||||
// 如果状态为草稿或审核状态,才可以保存业务数据
|
||||
if (${ClassName}.STATUS_DRAFT.equals(${className}.getStatus())
|
||||
|| ${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){
|
||||
super.save(${className});
|
||||
}
|
||||
|
||||
// 如果为审核状态,则进行审批流操作
|
||||
if (${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){
|
||||
|
||||
// 指定流程变量,作为流程条件,决定流转方向
|
||||
Map<String, Object> variables = MapUtils.newHashMap();
|
||||
//variables.put("leaveDays", ${className}.getLeaveDays());
|
||||
|
||||
// 如果流程实例为空,任务编号也为空,则:启动流程
|
||||
if (StringUtils.isBlank(${className}.getBpm().getProcInsId())
|
||||
&& StringUtils.isBlank(${className}.getBpm().getTaskId())){
|
||||
BpmUtils.start(${className}, "${table.optionMap['bpmFormKey']}", variables, null);
|
||||
}
|
||||
// 如果有任务信息,则:提交任务
|
||||
else{
|
||||
BpmUtils.complete(${className}, variables, null);
|
||||
}
|
||||
}
|
||||
<% }else{ %>
|
||||
super.save(${className});
|
||||
<% } %>
|
||||
<% if(toBoolean(table.optionMap['isImageUpload'])){ %>
|
||||
// 保存上传图片
|
||||
FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_image");
|
||||
<% } %>
|
||||
<% if(toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||
// 保存上传附件
|
||||
FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_file");
|
||||
<% } %>
|
||||
<% for (child in table.childList) { %>
|
||||
// 保存 ${ClassName}子表
|
||||
for (${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} : ${className}.get${@StringUtils.cap(child.className)}List()){
|
||||
if (!${@StringUtils.cap(child.className)}.STATUS_DELETE.equals(${@StringUtils.uncap(child.className)}.getStatus())){
|
||||
<%
|
||||
for(c in child.columnList){
|
||||
if (child.parentExists && child.parentTableFkName == c.columnName){
|
||||
%>
|
||||
${@StringUtils.uncap(child.className)}.set${@StringUtils.cap(c.simpleAttrName)}(${className});
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
if (${@StringUtils.uncap(child.className)}.getIsNewRecord()){
|
||||
${@StringUtils.uncap(child.className)}Dao.insert(${@StringUtils.uncap(child.className)});
|
||||
}else{
|
||||
${@StringUtils.uncap(child.className)}Dao.update(${@StringUtils.uncap(child.className)});
|
||||
}
|
||||
}else{
|
||||
${@StringUtils.uncap(child.className)}Dao.delete(${@StringUtils.uncap(child.className)});
|
||||
}
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态
|
||||
* @param ${className}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void updateStatus(${ClassName} ${className}) {
|
||||
super.updateStatus(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param ${className}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void delete(${ClassName} ${className}) {
|
||||
super.delete(${className});
|
||||
<% for (child in table.childList) { %>
|
||||
${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}();
|
||||
<%
|
||||
for(c in child.columnList){
|
||||
if (child.parentExists && child.parentTableFkName == c.columnName){
|
||||
%>
|
||||
${@StringUtils.uncap(child.className)}.set${@StringUtils.cap(c.simpleAttrName)}(${className});
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
${@StringUtils.uncap(child.className)}Dao.deleteByEntity(${@StringUtils.uncap(child.className)});
|
||||
<% } %>
|
||||
}
|
||||
|
||||
}]]>
|
||||
</content>
|
||||
</template>
|
||||
@@ -14,9 +14,28 @@
|
||||
<template>category-ref:dao</template>
|
||||
</childTable>
|
||||
</category>
|
||||
<category value="crud_cloud" label="单表/主子表 (增删改查 Cloud)">
|
||||
<template>crud/mapper.xml</template>
|
||||
<template>cloud/entity.xml</template>
|
||||
<template>crud/dao.xml</template>
|
||||
<template>cloud/api.xml</template>
|
||||
<template>cloud/client.xml</template>
|
||||
<template>cloud/service.xml</template>
|
||||
<template>crud/controller.xml</template>
|
||||
<template>crud/viewList.xml</template>
|
||||
<template>crud/viewForm.xml</template>
|
||||
<childTable>
|
||||
<template>crud/mapper.xml</template>
|
||||
<template>cloud/entity.xml</template>
|
||||
<template>crud/dao.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
<category value="treeGrid" label="树表/树结构表(增删改查)">
|
||||
<template>category-ref:crud</template>
|
||||
</category>
|
||||
<category value="treeGrid_cloud" label="树表/树结构表(增删改查 Cloud)">
|
||||
<template>category-ref:crud</template>
|
||||
</category>
|
||||
<category value="service" label="业务层和持久层(不含控制器和视图)">
|
||||
<template>category-ref:dao</template>
|
||||
<template>crud/service.xml</template>
|
||||
|
||||
@@ -21,6 +21,13 @@ import com.jeesite.common.entity.TreeEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
<% if(table.isTreeEntity){ %>
|
||||
import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
||||
<% }else{ %>
|
||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* ${functionName}Entity
|
||||
@@ -156,7 +163,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
}
|
||||
} %>"
|
||||
)
|
||||
public class ${ClassName} extends ${table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
||||
public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<%
|
||||
|
||||
@@ -22,6 +22,13 @@ import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.${table.isTreeEntity?'Tree':'Crud'}Service;
|
||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName};
|
||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}Dao;
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
import java.util.Map;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.modules.bpm.utils.BpmUtils;
|
||||
<% } %>
|
||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
<% } %>
|
||||
@@ -97,7 +104,43 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void save(${ClassName} ${className}) {
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
// 如果未设置状态,则指定状态为审核状态,以提交审核流程
|
||||
if (StringUtils.isBlank(${className}.getStatus())){
|
||||
${className}.setStatus(${ClassName}.STATUS_AUDIT);
|
||||
}
|
||||
|
||||
// 如果状态为正常,则代表不正常操作,可能前端进行了数据参数修改
|
||||
if (${ClassName}.STATUS_NORMAL.equals(${className}.getStatus())){
|
||||
throw new ServiceException(text("非法操作,前端数据被劫持!"));
|
||||
}
|
||||
|
||||
// 如果状态为草稿或审核状态,才可以保存业务数据
|
||||
if (${ClassName}.STATUS_DRAFT.equals(${className}.getStatus())
|
||||
|| ${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){
|
||||
super.save(${className});
|
||||
}
|
||||
|
||||
// 如果为审核状态,则进行审批流操作
|
||||
if (${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){
|
||||
|
||||
// 指定流程变量,作为流程条件,决定流转方向
|
||||
Map<String, Object> variables = MapUtils.newHashMap();
|
||||
//variables.put("leaveDays", ${className}.getLeaveDays());
|
||||
|
||||
// 如果流程实例为空,任务编号也为空,则:启动流程
|
||||
if (StringUtils.isBlank(${className}.getBpm().getProcInsId())
|
||||
&& StringUtils.isBlank(${className}.getBpm().getTaskId())){
|
||||
BpmUtils.start(${className}, "${table.optionMap['bpmFormKey']}", variables, null);
|
||||
}
|
||||
// 如果有任务信息,则:提交任务
|
||||
else{
|
||||
BpmUtils.complete(${className}, variables, null);
|
||||
}
|
||||
}
|
||||
<% }else{ %>
|
||||
super.save(${className});
|
||||
<% } %>
|
||||
<% if(toBoolean(table.optionMap['isImageUpload'])){ %>
|
||||
// 保存上传图片
|
||||
FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_image");
|
||||
|
||||
@@ -45,13 +45,38 @@
|
||||
<% } %>
|
||||
<% include('/templates/modules/gen/include/formControl.html'){} %>
|
||||
<% include('/templates/modules/gen/include/formChildTable.html'){} %>
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
\<% if(isNotBlank(${className}.bpm.taskId)){ %>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-2">${text('审批意见')}:</label>
|
||||
<div class="col-xs-10">
|
||||
<${'#'}bpm:comment bpmEntity="\${${className}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
\<% } %>
|
||||
<${'#'}bpm:nextTaskInfo bpmEntity="\${${className}}" />
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
\<% if (hasPermi('${permissionPrefix}:edit')){ %>
|
||||
<${'#'}form:hidden path="status"/>
|
||||
\<% if (${className}.isNewRecord || ${className}.status == '9'){ %>
|
||||
<button type="submit" class="btn btn-sm btn-info" id="btnDraft"><i class="fa fa-save"></i> ${text('暂 存')}</button>
|
||||
\<% } %>
|
||||
<${'#'}bpm:button bpmEntity="\${${className}}" formKey="${table.optionMap['bpmFormKey']}" completeText="${text('提 交')}"/>
|
||||
\<% } %>
|
||||
<% }else{ %>
|
||||
\<% if (hasPermi('${permissionPrefix}:edit')){ %>
|
||||
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> \${text('保 存')}</button>
|
||||
\<% } %>
|
||||
<% } %>
|
||||
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> \${text('关 闭')}</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,6 +87,19 @@
|
||||
\<% } %>
|
||||
<% include('/templates/modules/gen/include/formChildTableScript.html'){} %>
|
||||
<script>
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
// 业务实现草稿按钮
|
||||
$('#btnDraft').click(function(){
|
||||
$('#status').val(Global.STATUS_DRAFT);
|
||||
});
|
||||
// 流程按钮操作事件
|
||||
BpmButton = window.BpmButton || {};
|
||||
BpmButton.init = function(task){ }
|
||||
BpmButton.complete = function($this, task){
|
||||
$('#status').val(Global.STATUS_AUDIT);
|
||||
};
|
||||
// 表单验证提交事件
|
||||
<% } %>
|
||||
$("#inputForm").validate({
|
||||
submitHandler: function(form){
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
|
||||
@@ -91,6 +91,11 @@ $('#dataGrid').dataGrid({
|
||||
actions.push('<a href="\${ctx}/${urlPrefix}/form?parentCode='+row.id+'" class="btnList" title="\${text("新增下级${functionNameSimple}")}"><i class="fa fa-plus-square"></i></a> ');
|
||||
<% } %>
|
||||
\<% } %>
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
if (row.status != Global.STATUS_DRAFT){
|
||||
actions.push('<a href="\${ctx}/bpm/bpmRuntime/trace?formKey=${table.optionMap['bpmFormKey']}&bizKey='+row.id+'" class="btnList" title="\${text("流程追踪")}" data-layer="true"><i class="fa fa-file-picture-o"></i></a> ');
|
||||
}
|
||||
<% } %>
|
||||
<% } %>
|
||||
return actions.join('');
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user