代码生成的d

This commit is contained in:
lin 2020-12-18 17:49:23 +08:00
parent ebfedb130e
commit 76a1ad9b0d
17 changed files with 334 additions and 96 deletions

View File

@ -17,9 +17,22 @@
$("input[name='updateTime']").prop('disabled', true);
4、 Java8 使用 stream().filter()过滤List对象查找符合条件的对象集合
//查找身高在1.8米及以上的男生
List<StudentInfo> boys = studentList.stream().filter(s->s.getGender() && s.getHeight() >= 1.8).collect(Collectors.toList());
//输出查找结果
StudentInfo.printStudents(boys);
// 取身份信息
SysUser user = ShiroUtils.getSysUser();
// 根据用户id取出菜单
List<SysMenu> menus = menuService.selectMenusByUser(user);
mmap.put("menus", menus);
mmap.put("user", user);
=============== 相关资料 ========================================================================
@ -39,3 +52,11 @@ j2eefast开源
https://gitee.com/zhouhuanOGP/J2EEFAST
附件和图片上传我全套扣的j2eefast的ruoyi的用着太怪了
阿里云开发者成长计划
https://developer.aliyun.com/plan/grow-up?spm=5176.19720258.J_8058803260.1292.1d722c4ae1PLsq
VueOA
https://blog.csdn.net/aria_miazzy/article/details/104960221
https://gitee.com/yunwisdoms/oa-front-service

View File

@ -76,6 +76,9 @@ public class GenTable extends BaseEntity
/** 主键信息 */
private GenTableColumn pkColumn;
/** 名称列信息 */
private GenTableColumn dspColumn;
/** 子表信息 */
private GenTable subTable;
@ -271,6 +274,14 @@ public class GenTable extends BaseEntity
this.pkColumn = pkColumn;
}
public GenTableColumn getDspColumn() {
return dspColumn;
}
public void setDspColumn(GenTableColumn dspColumn) {
this.dspColumn = dspColumn;
}
public GenTable getSubTable()
{
return subTable;

View File

@ -73,7 +73,6 @@ public class GenTableColumn extends BaseEntity implements Cloneable
/** 默认值1是 */
private String isDefaultValue;
/** 关联实体名 */
private String relevTable ;
@ -83,6 +82,11 @@ public class GenTableColumn extends BaseEntity implements Cloneable
/** 关联表字段名称 */
private String relevTableName;
/** 关联实体 字段名称 */
private String relevjavafiledname;
/** 关联实体 Column 别名 */
private String relevcolumnalias;
/** 关联实体 别名 */
private String relevAlias;
@ -298,6 +302,22 @@ public class GenTableColumn extends BaseEntity implements Cloneable
return isRelevByHidden != null && StringUtils.equals("1", isRelevByHidden);
}
public String getRelevjavafiledname() {
return relevjavafiledname;
}
public void setRelevjavafiledname(String relevjavafiledname) {
this.relevjavafiledname = relevjavafiledname;
}
public String getRelevcolumnalias() {
return relevcolumnalias;
}
public void setRelevcolumnalias(String relevcolumnalias) {
this.relevcolumnalias = relevcolumnalias;
}
public String getRelevAlias() {
return relevAlias;
}
@ -306,6 +326,7 @@ public class GenTableColumn extends BaseEntity implements Cloneable
this.relevAlias = relevAlias;
}
public String getIsRepeatControl() {
return isRepeatControl;
}

View File

@ -1,28 +1,10 @@
package com.ruoyi.generator.service.impl;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.CharsetKit;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
@ -36,23 +18,60 @@ import com.ruoyi.generator.service.IGenTableService;
import com.ruoyi.generator.util.GenUtils;
import com.ruoyi.generator.util.VelocityInitializer;
import com.ruoyi.generator.util.VelocityUtils;
import com.ruoyi.system.domain.RelevTable;
import com.ruoyi.system.mapper.RelevTableMapper;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 业务 服务层实现
*
* @author ruoyi
*/
@Component
@Service
public class GenTableServiceImpl implements IGenTableService
{
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Autowired
private RelevTableMapper relevTableMapper;
private static GenTableServiceImpl gnTableServiceImpl ;
@Autowired
private GenTableMapper genTableMapper;
@Autowired
private GenTableColumnMapper genTableColumnMapper;
@PostConstruct //通过@PostConstruct实现初始化bean之前进行的操作
public void init() {
gnTableServiceImpl = this;
gnTableServiceImpl.relevTableMapper = this.relevTableMapper;
}
/**
* 查询业务信息
*
@ -202,11 +221,18 @@ public class GenTableServiceImpl implements IGenTableService
GenTable table = genTableMapper.selectGenTableById(tableId);
// 设置主子表信息
setSubTable(table);
// 设置主键列信息
setPkColumn(table);
// 设置名称重复列信息
setRepeatDspColumn(table);
VelocityInitializer.initVelocity();
VelocityContext context = VelocityUtils.prepareContext(table);
List<RelevTable> lstRelev =
relevTableMapper.selectRelevTableAll() ; // "SysUser"
VelocityContext context = VelocityUtils.prepareContext(table,lstRelev);
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
@ -251,10 +277,15 @@ public class GenTableServiceImpl implements IGenTableService
setSubTable(table);
// 设置主键列信息
setPkColumn(table);
// 设置名称重复列信息
setRepeatDspColumn(table);
VelocityInitializer.initVelocity();
VelocityContext context = VelocityUtils.prepareContext(table);
List<RelevTable> lstRelev =
relevTableMapper.selectRelevTableAll() ; // "SysUser"
VelocityContext context = VelocityUtils.prepareContext(table,lstRelev);
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
@ -345,10 +376,15 @@ public class GenTableServiceImpl implements IGenTableService
setSubTable(table);
// 设置主键列信息
setPkColumn(table);
// 设置名称重复列信息
setRepeatDspColumn(table);
VelocityInitializer.initVelocity();
VelocityContext context = VelocityUtils.prepareContext(table);
List<RelevTable> lstRelev =
relevTableMapper.selectRelevTableAll() ; // "SysUser"
VelocityContext context = VelocityUtils.prepareContext(table,lstRelev);
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
@ -457,6 +493,28 @@ public class GenTableServiceImpl implements IGenTableService
}
}
/**
* 设置 名称列信息
*
* @param table 业务表信息
*/
public void setRepeatDspColumn(GenTable table)
{
for (GenTableColumn column : table.getColumns())
{
if (column.isRepeatControl())
{
table.setDspColumn(column);
break;
}
}
if (StringUtils.isNull(table.getDspColumn()))
{
table.setDspColumn(table.getColumns().get(0));
}
}
/**
* 设置主子表信息
*

View File

@ -9,19 +9,15 @@ import com.ruoyi.generator.config.GenConfig;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.system.domain.RelevTable;
import com.ruoyi.system.service.IRelevTableService;
import org.apache.velocity.VelocityContext;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
public class VelocityUtils {
@Autowired
private IRelevTableService relevTableService;
/**
* 项目空间路径
*/
@ -47,7 +43,7 @@ public class VelocityUtils {
*
* @return 模板列表
*/
public static VelocityContext prepareContext(GenTable genTable) {
public static VelocityContext prepareContext(GenTable genTable,List<RelevTable> lstRelevTb) {
String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName();
@ -67,6 +63,7 @@ public class VelocityUtils {
velocityContext.put("author", genTable.getFunctionAuthor());
velocityContext.put("datetime", DateUtils.getDate());
velocityContext.put("pkColumn", genTable.getPkColumn());
velocityContext.put("dspRepeatColumn", genTable.getDspColumn());
velocityContext.put("importList", getImportList(genTable));
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
@ -75,9 +72,58 @@ public class VelocityUtils {
List<GenTableColumn> effectivecols = new ArrayList<GenTableColumn>();//定义一个list对象
List<GenTableColumn> effectiveceditols = new ArrayList<GenTableColumn>();//定义一个list对象
List<GenTableColumn> fieldcols = new ArrayList<GenTableColumn>();// 模板的变量 colums
List<GenTableColumn> hiddenfiledcols = new ArrayList<GenTableColumn>();// 模板隐藏变量 hiddenfiledcols
List<GenTableColumn> hiddenleftjoinfiledcols = new ArrayList<GenTableColumn>();// 模板隐藏变量 hiddenfiledcols
Integer icount = 0 ;
for (GenTableColumn tcolumn : tempcolumns) {
if ( !StringUtil.isEmpty( tcolumn.getRelevEntity() ) && !tcolumn.isPk() ) {
// 添加 关联字段 信息
try {
// 根据关联字段 查找 ....
// RelevTable relevTb = null ; // lstRelevTb
List<RelevTable> lstcurRelevTb = lstRelevTb.stream().filter( s->s.getRelevEntity().equals(tcolumn.getRelevEntity()) ).collect(Collectors.toList());
//输出查找结果
tcolumn.setRelevEntityId( lstcurRelevTb.get(0).getRelevEntityId() );
tcolumn.setRelevEntityName( lstcurRelevTb.get(0).getRelevEntityName() );
tcolumn.setRelevTable(lstcurRelevTb.get(0).getRelevTable());
tcolumn.setRelevTableName(lstcurRelevTb.get(0).getRelevTableName());
tcolumn.setRelevTableId(lstcurRelevTb.get(0).getRelevTableId());
// 取得 关联实体信息
GenTableColumn relevColumn = (GenTableColumn) tcolumn.clone();
relevColumn.setJavaField( tcolumn.getJavaField().concat( relevColumn.getRelevEntityName() ));
fieldcols.add(relevColumn) ;
tcolumn.setIsRelevByHidden("1");
tcolumn.setColumnComment(tcolumn.getColumnComment().concat("ID"));
tcolumn.setRelevjavafiledname( tcolumn.getJavaField().concat( relevColumn.getRelevEntityName() ) );
icount ++ ;
tcolumn.setRelevAlias("a".concat(icount.toString()));
tcolumn.setRelevcolumnalias(tcolumn.getRelevAlias().concat(tcolumn.getRelevEntity().toLowerCase()));
hiddenleftjoinfiledcols.add(tcolumn) ;
fieldcols.add(tcolumn) ;
if (relevColumn.isInsert() && !relevColumn.isPk())
if (relevColumn.isUsableColumn() || !relevColumn.isSuperColumn())
effectivecols.add(relevColumn);
if (relevColumn.isEdit() && !relevColumn.isPk())
if (relevColumn.isUsableColumn() || !relevColumn.isSuperColumn())
effectiveceditols.add(relevColumn);
}catch (Exception e){
}
} else {
fieldcols.add(tcolumn) ;
if (tcolumn.isInsert() && !tcolumn.isPk())
if (tcolumn.isUsableColumn() || !tcolumn.isSuperColumn())
effectivecols.add(tcolumn);
@ -85,38 +131,16 @@ public class VelocityUtils {
if (tcolumn.isEdit() && !tcolumn.isPk())
if (tcolumn.isUsableColumn() || !tcolumn.isSuperColumn())
effectiveceditols.add(tcolumn);
if ( !StringUtil.isEmpty( tcolumn.getRelevEntity() ) && !tcolumn.isPk() ) {
// 添加 关联字段 信息
try {
// 取得 关联实体信息
GenTableColumn relevColumn = (GenTableColumn) tcolumn.clone();
RelevTable relevTb =
relevTableService.selectRelevTableByRelevEntity( tcolumn.getRelevEntity() ) ;
relevColumn.setRelevEntityId( relevTb.getRelevEntityId() );
relevColumn.setRelevEntityName( relevTb.getRelevEntityName() );
relevColumn.setRelevTable(relevTb.getRelevTable());
relevColumn.setRelevTableName(relevTb.getRelevTableName());
relevColumn.setRelevTableId(relevTb.getRelevTableId());
fieldcols.add(relevColumn) ;
}catch (Exception e){
}
tcolumn.setIsRelevByHidden("1");
fieldcols.add(tcolumn) ;
} else
fieldcols.add(tcolumn) ;
};
//
velocityContext.put("effectivecols", effectivecols);
velocityContext.put("effectiveeditcols", effectiveceditols);
velocityContext.put("columns", genTable.getColumns());
// 在界面上 要隐藏的ID
velocityContext.put("hiddenleftjoinfiledcols", hiddenleftjoinfiledcols);
velocityContext.put("mappercols", genTable.getColumns() ); //
velocityContext.put("columns", fieldcols ); // genTable.getColumns()
velocityContext.put("table", genTable);
setMenuVelocityContext(velocityContext, genTable);

View File

@ -42,6 +42,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isReadonly" column="is_readonly" />
<result property="relevEntity" column="relev_entity" />
<result property="isRepeatControl" column="is_repeat_control" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
@ -104,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
t.form_cols,t.bill_prefix,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.relev_entity,c.is_repeat_control,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort
@ -113,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
t.form_cols,t.bill_prefix,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.relev_entity,c.is_repeat_control,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort
@ -122,7 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
t.form_cols,t.bill_prefix,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.relev_entity,c.is_repeat_control,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort

View File

@ -24,6 +24,11 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if( $hiddencolumns.size() > 0 )
#foreach($column in $hiddencolumns)
<input type="hidden" name="${column.javaField}" id="${column.javaField}" />
#end
#end
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end

View File

@ -2,19 +2,19 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增${functionName}')" />
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
@ -24,11 +24,15 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if( $hiddenleftjoinfiledcols.size() > 0 )
#foreach($column in $hiddenleftjoinfiledcols)
<input type="hidden" name="${column.javaField}" id="${column.javaField}" />
#end
#end
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end
<input type="hidden" name="supplierTypeId" id="supplierTypeId" />
<input type="hidden" name="unitId" id="unitId" />
#set($cumvar=0)
#set($colcount=$effectivecols.size())
@ -114,13 +118,13 @@
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
@ -151,7 +155,7 @@
$.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
}
}
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
@ -161,7 +165,7 @@
});
#end
#end
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$(".file-upload").fileinput({
@ -176,7 +180,7 @@
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectivecols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(function() {

View File

@ -2,19 +2,19 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改${functionName}')" />
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
@ -24,6 +24,12 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-edit" th:object="${${className}}">
#if( $hiddenleftjoinfiledcols.size() > 0 )
#foreach($column in $hiddenleftjoinfiledcols)
<input type="hidden" name="${column.javaField}" id="${column.javaField}" />
#end
#end
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end
@ -89,19 +95,19 @@
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-js" />
#break
@ -125,7 +131,7 @@
$.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
}
}
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
@ -135,7 +141,7 @@
});
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$(".file-upload").each(function (i) {
@ -156,7 +162,7 @@
#break
#end
#end
#foreach($column in $columns)
#foreach($column in $effectiveeditcols)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(function() {

View File

@ -24,6 +24,12 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-edit" th:object="${${className}}">
#if( $hiddencolumns.size() > 0 )
#foreach($column in $hiddencolumns)
<input type="hidden" name="${column.javaField}" id="${column.javaField}" />
#end
#end
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end

View File

@ -22,6 +22,15 @@ public interface ${ClassName}Mapper
*/
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
#if($dspRepeatColumn.size() > 0)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${ClassName} select${ClassName}ByName(${pkColumn.javaType} ${pkColumn.javaField},${dspRepeatColumn.javaType} ${dspRepeatColumn.javaField});
#end
/**
* 查询${functionName}列表
*

View File

@ -22,6 +22,16 @@ public interface I${ClassName}Service
*/
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
#if($dspRepeatColumn.size() > 0)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${ClassName} select${ClassName}ByName(${pkColumn.javaType} ${pkColumn.javaField},${dspRepeatColumn.javaType} ${dspRepeatColumn.javaField});
#end
/**
* 查询${functionName}列表
*

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.ArrayList;
import com.ruoyi.common.core.domain.Ztree;
#end
#foreach ($column in $columns)
#foreach ($column in $mappercols)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.ruoyi.common.utils.DateUtils;
#break
@ -48,6 +48,20 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField});
}
#if($dspRepeatColumn.size() > 0)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
@Override
public ${ClassName} select${ClassName}ByName(${pkColumn.javaType} ${pkColumn.javaField},${dspRepeatColumn.javaType} ${dspRepeatColumn.javaField})
{
return ${className}Mapper.select${ClassName}ByName(${pkColumn.javaField},${dspRepeatColumn.javaField});
}
#end
/**
* 查询${functionName}列表
*
@ -72,7 +86,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
@Override
public int insert${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#foreach ($column in $mappercols)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
@ -98,7 +112,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
@Override
public int update${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#foreach ($column in $mappercols)
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end

View File

@ -5,9 +5,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
#foreach ($column in $mappercols)
<result property="${column.javaField}" column="${column.columnName}" />
#end
#if($hiddenleftjoinfiledcols.size()>0)
#foreach ($column in $hiddenleftjoinfiledcols)
<result property="${column.relevjavafiledname}" column="${column.relevcolumnalias}" />
#end
#end
#if($table.tree)
<result property="parentName" column="parent_name" />
#end
@ -26,13 +31,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#end
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
select#foreach($column in $mappercols) t.$column.columnName#if($velocityCount != $mappercols.size()),#end#end
#if($hiddenleftjoinfiledcols.size()>0),
#foreach($column in $hiddenleftjoinfiledcols)
$column.relevAlias.$column.relevTableName as $column.relevcolumnalias#if($velocityCount != $hiddenleftjoinfiledcols.size()),#end#end
#end
from ${tableName} t
#if($hiddenleftjoinfiledcols.size()>0)
#foreach($column in $hiddenleftjoinfiledcols)
left join $column.relevTable $column.relevAlias on t.$column.columnName=$column.relevAlias.$column.relevTableId
#end
#end
</sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#foreach($column in $mappercols)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
@ -40,21 +55,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName = #{$javaField}</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName != #{$javaField}</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName &gt; #{$javaField}</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName &gt;= #{$javaField}</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName &lt; #{$javaField}</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and t.$columnName like concat('%', #{$javaField}, '%')</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and t.$columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end
#end
#end
@ -67,14 +82,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
where t.${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.tree)
select#foreach($column in $columns) t.$column.columnName,#end p.${tree_name} as parent_name
select#foreach($column in $mappercols) t.$column.columnName,#end p.${tree_name} as parent_name
from ${tableName} t
left join ${tableName} p on p.${pkColumn.columnName} = t.${tree_parent_code}
where t.${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
select#foreach($column in $mappercols) a.$column.columnName#if($velocityCount != $mappercols.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
from ${tableName} a
@ -83,17 +98,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#end
</select>
#if($dspRepeatColumn.size() > 0)
<select id="select${ClassName}ByName" parameterType="String" resultMap="${ClassName}Result">
#if($table.crud)
<include refid="select t.${pkColumn.columnName} from ${tableName} t"/>
where t.${pkColumn.columnName} <> #{${pkColumn.javaField}}
and t.${dspRepeatColumn.columnName} = #{${dspRepeatColumn.javaField}}
#end
</select>
#end
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#foreach($column in $mappercols)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
#end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#foreach($column in $mappercols)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
#end
@ -104,7 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="update${ClassName}" parameterType="${ClassName}">
update ${tableName}
<trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns)
#foreach($column in $mappercols)
#if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
#end

View File

@ -28,6 +28,13 @@ public interface RelevTableMapper
*/
public RelevTable selectRelevTableByRelevEntity(String relevEntity);
/**
* 查询关联实体维护列表 所有数据
*
* @return 关联实体维护集合
*/
public List<RelevTable> selectRelevTableAll();
/**
* 查询关联实体维护列表
*

View File

@ -44,6 +44,15 @@ public class RelevTableServiceImpl implements IRelevTableService
{
return relevTableMapper.selectRelevTableByRelevEntity(relevEntity);
}
/**
* 查询关联实体维护列表
*
* @return 关联实体维护
*/
public List<RelevTable> selectRelevTableAll()
{
return relevTableMapper.selectRelevTableAll();
}
/**
* 查询关联实体维护列表

View File

@ -24,6 +24,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select relev_id, relev_name, relev_entity, relev_entity_id, relev_entity_name, is_default_value, relev_table, relev_table_id, relev_table_name, create_by, create_time, update_by, update_time from sys_relev_table
</sql>
<select id="selectRelevTableAll" parameterType="String" resultMap="RelevTableResult">
<include refid="selectRelevTableVo"/>
</select>
<select id="selectRelevTableList" parameterType="RelevTable" resultMap="RelevTableResult">
<include refid="selectRelevTableVo"/>
<where>