若依 4.0

This commit is contained in:
RuoYi
2019-08-08 08:53:12 +08:00
parent 5f05734e46
commit 1c3541cc05
63 changed files with 4410 additions and 1291 deletions

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.generator.mapper.GenMapper">
<resultMap type="TableInfo" id="TableInfoResult">
<id property="tableName" column="table_name" />
<result property="tableComment" column="table_comment" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap type="ColumnInfo" id="ColumnInfoResult">
<id property="columnName" column="column_name" />
<result property="dataType" column="data_type" />
<result property="columnComment" column="column_comment" />
</resultMap>
<sql id="selectGenVo">
select table_name, table_comment, create_time, update_time from information_schema.tables
</sql>
<select id="selectTableList" parameterType="TableInfo" resultMap="TableInfoResult">
<include refid="selectGenVo"/>
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
<if test="tableName != null and tableName != ''">
AND table_name like concat('%', #{tableName}, '%')
</if>
<if test="tableComment != null and tableComment != ''">
AND table_comment like concat('%', #{tableComment}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</select>
<select id="selectTableByName" parameterType="String" resultMap="TableInfoResult">
<include refid="selectGenVo"/>
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
and table_name = #{tableName}
</select>
<select id="selectTableColumnsByName" parameterType="String" resultMap="ColumnInfoResult">
select column_name, data_type, column_comment, extra from information_schema.columns
where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position
</select>
</mapper>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.generator.mapper.GenTableColumnMapper">
<resultMap type="GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
<result property="columnType" column="column_type" />
<result property="javaType" column="java_type" />
<result property="javaField" column="java_field" />
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
<result property="isQuery" column="is_query" />
<result property="queryType" column="query_type" />
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectGenTableColumnVo">
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
</sql>
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
<include refid="selectGenTableColumnVo"/>
where table_id = #{tableId}
order by sort
</select>
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'pri') then '1' else null end) as is_required, (case when column_key = 'pri' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
order by ordinal_position
</select>
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>
<if test="columnComment != null and columnComment != ''">column_comment,</if>
<if test="columnType != null and columnType != ''">column_type,</if>
<if test="javaType != null and javaType != ''">java_type,</if>
<if test="javaField != null and javaField != ''">java_field,</if>
<if test="isPk != null and isPk != ''">is_pk,</if>
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
<if test="isRequired != null and isRequired != ''">is_required,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isEdit != null and isEdit != ''">is_edit,</if>
<if test="isList != null and isList != ''">is_list,</if>
<if test="isQuery != null and isQuery != ''">is_query,</if>
<if test="queryType != null and queryType != ''">query_type,</if>
<if test="htmlType != null and htmlType != ''">html_type,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="sort != null">sort,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableId != null and tableId != ''">#{tableId},</if>
<if test="columnName != null and columnName != ''">#{columnName},</if>
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
<if test="columnType != null and columnType != ''">#{columnType},</if>
<if test="javaType != null and javaType != ''">#{javaType},</if>
<if test="javaField != null and javaField != ''">#{javaField},</if>
<if test="isPk != null and isPk != ''">#{isPk},</if>
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
<if test="isList != null and isList != ''">#{isList},</if>
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
<if test="queryType != null and queryType != ''">#{queryType},</if>
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTableColumn" parameterType="GenTableColumn">
update gen_table_column
<set>
column_comment = #{columnComment},
java_type = #{javaType},
java_field = #{javaField},
is_insert = #{isInsert},
is_edit = #{isEdit},
is_list = #{isList},
is_query = #{isQuery},
is_required = #{isRequired},
query_type = #{queryType},
html_type = #{htmlType},
dict_type = #{dictType},
sort = #{sort},
update_by = #{updateBy},
update_time = sysdate()
</set>
where column_id = #{columnId}
</update>
<delete id="deleteGenTableColumnByIds" parameterType="Long">
delete from gen_table_column where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">
#{tableId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.generator.mapper.GenTableMapper">
<resultMap type="GenTable" id="GenTableResult">
<id property="tableId" column="table_id" />
<result property="tableName" column="table_name" />
<result property="tableComment" column="table_comment" />
<result property="className" column="class_name" />
<result property="tplCategory" column="tpl_category" />
<result property="packageName" column="package_name" />
<result property="moduleName" column="module_name" />
<result property="businessName" column="business_name" />
<result property="functionName" column="function_name" />
<result property="functionAuthor" column="function_author" />
<result property="options" column="options" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap>
<resultMap type="GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
<result property="columnType" column="column_type" />
<result property="javaType" column="java_type" />
<result property="javaField" column="java_field" />
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
<result property="isQuery" column="is_query" />
<result property="queryType" column="query_type" />
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectGenTableVo">
select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/>
<if test="tableName != null and tableName != ''">
AND table_name like concat('%', #{tableName}, '%')
</if>
<if test="tableComment != null and tableComment != ''">
AND table_comment like concat('%', #{tableComment}, '%')
</if>
</select>
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND table_name like concat('%', #{tableName}, '%')
</if>
<if test="tableComment != null and tableComment != ''">
AND table_comment like concat('%', #{tableComment}, '%')
</if>
</select>
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
and table_name = #{tableName}
</select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
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_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}
</select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
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_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}
</select>
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
insert into gen_table (
<if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if>
<if test="className != null and className != ''">class_name,</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
<if test="packageName != null and packageName != ''">package_name,</if>
<if test="moduleName != null and moduleName != ''">module_name,</if>
<if test="businessName != null and businessName != ''">business_name,</if>
<if test="functionName != null and functionName != ''">function_name,</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableName != null">#{tableName},</if>
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
<if test="className != null and className != ''">#{className},</if>
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
<if test="packageName != null and packageName != ''">#{packageName},</if>
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
<if test="businessName != null and businessName != ''">#{businessName},</if>
<if test="functionName != null and functionName != ''">#{functionName},</if>
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTable" parameterType="GenTable">
update gen_table
<set>
<if test="tableName != null">table_name = #{tableName},</if>
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
<if test="className != null and className != ''">class_name = #{className},</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
<if test="options != null and options != ''">options = #{options},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where table_id = #{tableId}
</update>
<delete id="deleteGenTableByIds" parameterType="Long">
delete from gen_table where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">
#{tableId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,483 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改生成信息')" />
<th:block th:include="include :: select2-css" />
<style type="text/css">
.select-table table{table-layout:fixed;}.table>thead>tr>th{text-align:center;}.select-table .table td{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.form-control{padding:3px 6px 4px;height:30px;}.icheckbox-blue{top:0px;left:6px;}.form-control.select2-hidden-accessible{position:static!important;}.select-table table label.error{position: inherit;}select + label.error{z-index:1;right:40px;}
</style>
</head>
<body class="gray-bg" style="font: 14px Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif !important;">
<section class="section-content">
<div class="row">
<div class="col-xs-12">
<div class="ibox float-e-margins">
<div class="ibox-content" style="border-style:none;">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li><a href="#tab-basic" data-toggle="tab" aria-expanded="false">基本信息</a></li>
<li class="active"><a href="#tab-field" data-toggle="tab" aria-expanded="true">字段信息</a></li>
<li><a href="#tab-gen" data-toggle="tab" aria-expanded="false">生成信息</a></li>
<li class="pull-right header">
<i class="fa fa-code"></i> 生成配置
</li>
</ul>
<form id="form-gen-edit" class="form-horizontal" th:object="${table}">
<input name="tableId" type="hidden" th:field="*{tableId}" />
<div class="tab-content">
<!-- 基本信息 -->
<div class="tab-pane" id="tab-basic">
<div class="row mt20">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>表名称:</label>
<div class="col-sm-8">
<input name="tableName" class="form-control" type="text" placeholder="请输入表名称" maxlength="200" th:field="*{tableName}" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>表描述:</label>
<div class="col-sm-8">
<input name="tableComment" class="form-control" type="text" placeholder="请输入表描述" maxlength="500" th:field="*{tableComment}" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>实体类名称:</label>
<div class="col-sm-8">
<input name="className" class="form-control" type="text" placeholder="请输入实体类名称" maxlength="100" th:field="*{className}" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>作者:</label>
<div class="col-sm-8">
<input name="functionAuthor" class="form-control" type="text" placeholder="请输入作者" maxlength="50" th:field="*{functionAuthor}" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-xs-2 control-label">备注:</label>
<div class="col-xs-10">
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
</div>
</div>
</div>
</div>
</div>
<!-- 字段信息 -->
<div class="tab-pane active" id="tab-field">
<div class="select-table table-striped" style="margin-top: 0px;padding-top: 0px;padding-bottom: 0px;">
<table id="bootstrap-table" data-use-row-attr-func="true" data-reorderable-rows="true"></table>
</div>
</div>
<!-- 生成信息 -->
<div class="tab-pane" id="tab-gen">
<div class="row mt20">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>生成模板:</label>
<div class="col-sm-8">
<select class='form-control' id="tplCategory" name='tplCategory' style="width: 100%">
<option value="crud" th:field="*{tplCategory}">单表(增删改查)</option>
<option value="tree" th:field="*{tplCategory}">树表(增删改查)</option>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="生成在哪个java包下例如 com.ruoyi.system"><span style="color: red; ">*</span>生成包路径:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<input name="packageName" class="form-control" type="text" placeholder="请输入生成包路径" maxlength="100" th:field="*{packageName}" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="可理解为子系统名,例如 system"><span style="color: red; ">*</span>生成模块名:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<input name="moduleName" class="form-control" type="text" placeholder="请输入生成模块名" maxlength="30" th:field="*{moduleName}" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="可理解为功能英文名,例如 user"><span style="color: red; ">*</span>生成业务名:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<input name="businessName" class="form-control" type="text" placeholder="请输入生成业务名" maxlength="50" th:field="*{businessName}" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="用作类描述,例如 用户"><span style="color: red; ">*</span>生成功能名:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<input name="functionName" class="form-control" type="text" placeholder="请输入生成功能名" maxlength="50" th:field="*{functionName}" required>
</div>
</div>
</div>
</div>
<div class="hidden" id="otherInfo">
<h4 class="form-header h4">其他信息</h4>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="树显示的编码字段名, 如dept_id"><span style="color: red; ">*</span>树编码字段:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<select class='form-control' id="treeCode" name='params[treeCode]' style="width: 100%">
<option value="">---请选择---</option>
<option th:each="column : ${table.columns}" th:text="${column.columnName + '' + column.columnComment}" th:value="${column.columnName}" th:field="*{treeCode}"></option>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="树显示的父编码字段名, 如parent_Id"><span style="color: red; ">*</span>树父编码字段:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<select class='form-control' id="treeParentCode" name='params[treeParentCode]' style="width: 100%">
<option value="">---请选择---</option>
<option th:each="column : ${table.columns}" th:text="${column.columnName + '' + column.columnComment}" th:value="${column.columnName}" th:field="*{treeParentCode}"></option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label" title="树节点的显示名称字段名, 如dept_name"><span style="color: red; ">*</span>树名称字段:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<select class='form-control' id="treeName" name='params[treeName]' style="width: 100%">
<option value="">---请选择---</option>
<option th:each="column : ${table.columns}" th:text="${column.columnName + '' + column.columnComment}" th:value="${column.columnName}" th:field="*{treeName}"></option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="box-footer">
<div class="col-sm-offset-5 col-sm-6">
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
</div>
</div>
</div>
</div>
</div>
</section>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-table-reorder-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script type="text/javascript">
/*用户信息-修改*/
$("#form-table-edit").validate({
rules: {
tableName: {
required: true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.saveTab(prefix + "/edit", $("#form-gen-edit").serializeArray());
}
}
var prefix = ctx + "tool/gen";
$(function() {
var options = {
url: prefix + "/column/list",
sortName: "sort",
sortOrder: "desc",
height: $(window).height() - 166,
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
onLoadSuccess: onLoadSuccess,
onReorderRow: onReorderRow,
columns: [{
title: "序号",
width: "5%",
formatter: function (value, row, index) {
// 编号隐藏域
var columnIdHtml = $.common.sprintf("<input type='hidden' name='columns[%s].columnId' value='%s'>", index, row.columnId);
// 排序隐藏域
var sortHtml = $.common.sprintf("<input type='hidden' name='columns[%s].sort' value='%s' id='columns_sort_%s'>", index, row.sort, row.columnId);
return columnIdHtml + sortHtml + $.table.serialNumber(index);
},
cellStyle: function(value, row, index) {
return { css: { "cursor": "move" } };
}
},
{
field: 'columnName',
title: '字段列名',
width: "10%",
class: "nodrag",
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
},
{
field: 'columnComment',
title: '字段描述',
width: "10%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].columnComment' value='%s'>", index, value);
return html;
}
},
{
field: 'columnType',
title: '物理类型',
width: "10%",
class: "nodrag",
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
},
{
field: 'javaType',
title: 'Java类型',
width: "10%",
formatter: function (value, row, index) {
var data = [{ index: index, javaType: value }];
return $("#javaTypeTpl").tmpl(data).html();
}
},
{
field: 'javaField',
title: 'Java属性',
width: "10%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].javaField' value='%s' required>", index, value);
return html;
}
},
{
field: 'isInsert',
title: '插入',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isInsert' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isEdit',
title: '编辑',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isEdit' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isList',
title: '列表',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isList' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isQuery',
title: '查询',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isQuery' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'queryType',
title: '查询方式',
width: "10%",
formatter: function (value, row, index) {
var data = [{ index: index, queryType: value }];
return $("#queryTypeTpl").tmpl(data).html();
}
},
{
field: 'isRequired',
title: '必填',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isRequired' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'htmlType',
title: '显示类型',
width: "12%",
formatter: function (value, row, index) {
var data = [{ index: index, htmlType: value }];
return $("#htmlTypeTpl").tmpl(data).html();
}
},
{
field: 'dictType',
title: '字典类型',
width: "13%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].dictType' value='%s' id='columns_dict_%s'>", index, value, row.columnId);
return "<div class='input-group'>" + html + "<span class='input-group-addon input-sm' onclick='selectDictTree(" + row.columnId + ", this)'><i class='fa fa-search'></i></span></div>";
},
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
}]
};
$.table.init(options);
});
// 当所有数据被加载时触发处理函数
function onLoadSuccess(data){
$.fn.select2.defaults.set( "theme", "bootstrap" );
$("select.form-control").each(function () {
$(this).select2().on("change", function () {
$(this).valid();
})
})
$(".check-box").each(function() {
$(this).iCheck({
checkboxClass: 'icheckbox-blue'
})
})
}
// 当拖拽结束后处理函数
function onReorderRow(data) {
for (var i = 0; i < data.length; i++) {
$("#columns_sort_" + data[i].columnId).val(i+1);
}
}
$(function() {
var tplCategory = $("#tplCategory option:selected").val();
tplCategoryVisible(tplCategory);
});
$('#tplCategory').on('select2:select', function (event) {
var tplCategory = $(event.target).val();
tplCategoryVisible(tplCategory);
});
function tplCategoryVisible(tplCategory) {
if("crud" == tplCategory){
$("#treeCode").select2("val", [""]);
$("#treeParentCode").select2("val", [""]);
$("#treeName").select2("val", [""]);
$("#otherInfo").addClass("hidden");
} else if("tree" == tplCategory){
$("#otherInfo").removeClass("hidden");
$("#treeCode").attr("required", "true");
$("#treeParentCode").attr("required", "true");
$("#treeName").attr("required", "true");
}
}
// 选择字典处理函数
function selectDictTree(columnId, obj) {
var dictType = $.common.nullToStr($(obj).parent().find("input").val());
var url = ctx + "system/dict/selectDictTree/" + columnId + "/" + dictType;
var options = {
title: '选择字典类型',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
var columnId = body.find('#columnId').val();
var dictType = body.find('#dictType').val();
layer.close(index);
$("#columns_dict_" + columnId).val(dictType);
}
</script>
</body>
</html>
<!-- java类型 -->
<script id="javaTypeTpl" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='columns[${index}].javaType'>
<option value="Long" {{if javaType==="Long"}}selected{{/if}}>Long</option>
<option value="String" {{if javaType==="String"}}selected{{/if}}>String</option>
<option value="Integer" {{if javaType==="Integer"}}selected{{/if}}>Integer</option>
<option value="Double" {{if javaType==="Double"}}selected{{/if}}>Double</option>
<option value="BigDecimal" {{if javaType==="BigDecimal"}}selected{{/if}}>BigDecimal</option>
<option value="Date" {{if javaType==="Date"}}selected{{/if}}>Date</option>
</select>
</div>
</script>
<!-- 查询方式 -->
<script id="queryTypeTpl" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='columns[${index}].queryType'>
<option value="EQ" {{if queryType==="EQ"}}selected{{/if}}>=</option>
<option value="NE" {{if queryType==="NE"}}selected{{/if}}>!=</option>
<option value="GT" {{if queryType==="GT"}}selected{{/if}}>></option>
<option value="GTE" {{if queryType==="GTE"}}selected{{/if}}>>=</option>
<option value="LT" {{if queryType==="LT"}}selected{{/if}}><</option>
<option value="LTE" {{if queryType==="LTE"}}selected{{/if}}><=</option>
<option value="LIKE" {{if queryType==="LIKE"}}selected{{/if}}>Like</option>
<option value="BETWEEN" {{if queryType==="BETWEEN"}}selected{{/if}}>Between</option>
</select>
</div>
</script>
<!-- 显示类型 -->
<script id="htmlTypeTpl" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='columns[${index}].htmlType'>
<option value="input" {{if htmlType==="input"}}selected{{/if}}></option>
<option value="textarea" {{if htmlType==="textarea"}}selected{{/if}}></option>
<option value="select" {{if htmlType==="select"}}selected{{/if}}></option>
<option value="radio" {{if htmlType==="radio"}}selected{{/if}}></option>
<option value="checkbox" {{if htmlType==="checkbox"}}selected{{/if}}></option>
<option value="datetime" {{if htmlType==="datetime"}}selected{{/if}}></option>
</select>
</div>
</script>

View File

@ -32,9 +32,18 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="javascript:batchGenCode()" shiro:hasPermission="tool:gen:code">
<i class="fa fa-download"></i> 批量生成
<a class="btn btn-success multiple disabled" onclick="javascript:batchGenCode()" shiro:hasPermission="tool:gen:code">
<i class="fa fa-download"></i> 生成
</a>
<a class="btn btn-info" onclick="importTable()">
<i class="fa fa-upload"></i> 导入
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="tool:gen:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="tool:gen:remove">
<i class="fa fa-remove"></i> 删除
</a>
</div>
<div class="col-sm-12 select-table table-striped">
@ -43,18 +52,30 @@
</div>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
<script th:inline="javascript">
var prefix = ctx + "tool/gen";
var editFlag = [[${@permission.hasPermi('tool:gen:edit')}]];
var removeFlag = [[${@permission.hasPermi('tool:gen:remove')}]];
var previewFlag = [[${@permission.hasPermi('tool:gen:preview')}]];
var codeFlag = [[${@permission.hasPermi('tool:gen:code')}]];
$(function() {
var options = {
url: prefix + "/list",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
sortName: "createTime",
sortOrder: "desc",
showExport: true,
modalName: "生成配置",
columns: [{
checkbox: true
},
{
field: 'tableId',
title: '编号',
visible: false
},
{
title: "序号",
formatter: function (value, row, index) {
@ -64,44 +85,77 @@
{
field: 'tableName',
title: '表名称',
width: '20%',
sortable: true
},
{
field: 'tableComment',
title: '表描述',
width: '20%',
sortable: true
},
{
field: 'className',
title: '实体类名称',
sortable: true
},
{
field: 'createTime',
title: '创建时间',
width: '20%',
sortable: true
},
{
field: 'updateTime',
title: '更新时间',
width: '20%',
sortable: true
},
{
title: '操作',
width: '20%',
align: 'center',
formatter: function(value, row, index) {
var msg = '<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="genCode(\'' + row.tableName + '\')"><i class="fa fa-bug"></i>生成代码</a> ';
return msg;
var actions = [];
actions.push('<a class="btn btn-info btn-xs ' + previewFlag + '" href="javascript:void(0)" onclick="preview(\'' + row.tableId + '\')"><i class="fa fa-search"></i>预览</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.tableId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tableId + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-primary btn-xs ' + codeFlag + '" href="javascript:void(0)" onclick="genCode(\'' + row.tableName + '\')"><i class="fa fa-bug"></i>生成代码</a> ');
return actions.join('');
}
}]
};
$.table.init(options);
});
// 预览代码
function preview(tableId) {
var preViewUrl = prefix + "/preview/" + tableId;
$.modal.loading("正在加载数据,请稍后...");
$.get(preViewUrl, function(result) {
if (result.code == web_status.SUCCESS) {
var items = [];
$.each(result.data, function(index, value) {
value = value.replace(/</g, "&lt;");
value = value.replace(/>/g, "&gt;");
var templateName = index.substring(index.lastIndexOf("/") + 1, index.length).replace(/\.vm/g, "");
if(!$.common.equals("sql", templateName) && !$.common.equals("tree.html", templateName)){
items.push({
title: templateName , content: "<pre class=\"layui-code\">" + value + "</pre>"
})
}
});
top.layer.tab({
area: ['90%', '90%'],
shadeClose: true,
tab: items
});
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
});
}
// 生成代码
function genCode(tableName) {
$.modal.confirm("确定要生成" + tableName + "表代码吗?", function() {
location.href = prefix + "/genCode/" + tableName;
location.href = prefix + "/genCode/" + tableName;
layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
})
}
@ -114,10 +168,16 @@
return;
}
$.modal.confirm("确认要生成选中的" + rows.length + "条数据吗?", function() {
location.href = prefix + "/batchGenCode?tables=" + rows;
location.href = prefix + "/batchGenCode?tables=" + rows;
layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
});
}
// 导入表结构
function importTable() {
var importTableUrl = prefix + "/importTable";
$.modal.open("导入表结构", importTableUrl);
}
</script>
</body>
</html>

View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('导入表结构')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="gen-form">
<div class="select-list">
<ul>
<li>
表名称:<input type="text" name="tableName"/>
</li>
<li>
表描述:<input type="text" name="tableComment"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
var prefix = ctx + "tool/gen";
$(function() {
var options = {
url: prefix + "/db/list",
sortName: "createTime",
sortOrder: "desc",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
clickToSelect: true,
columns: [{
checkbox: true
},
{
title: "序号",
formatter: function (value, row, index) {
return $.table.serialNumber(index);
}
},
{
field: 'tableName',
title: '表名称',
width: '20%',
sortable: true
},
{
field: 'tableComment',
title: '表描述',
width: '20%',
sortable: true
},
{
field: 'createTime',
title: '创建时间',
width: '20%',
sortable: true
},
{
field: 'updateTime',
title: '更新时间',
width: '20%',
sortable: true
}]
};
$.table.init(options);
});
/* 导入表结构-选择表结构-提交 */
function submitHandler() {
var rows = $.table.selectColumns("tableName");
if (rows.length == 0) {
$.modal.alertWarning("请至少选择一条记录");
return;
}
var data = {"tables": rows.join()};
$.operate.save(prefix + "/importTable", data);
}
</script>
</body>
</html>

View File

@ -1,61 +1,159 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增${tableComment}')" />
<th:block th:include="include :: header('新增${functionName}')" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${classname}-add">
<form class="form-horizontal m" id="form-${businessName}-add">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName)
#if(!${column.configInfo})
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<input id="${column.attrname}" name="${column.attrname}" class="form-control" type="text">
</div>
</div>
#set($field=$column.javaField)
#if($column.insert && !$column.superColumn && !$column.pk)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#if(${column.configInfo.type} == "dict")
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<select name="${column.attrname}" class="form-control m-b" th:with="type=${@dict.getType('${column.configInfo.value}')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
#elseif(${column.configInfo.type} == "date")
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<input id="${column.attrname}" name="${column.attrname}" class="form-control time-input" type="text">
</div>
</div>
#elseif(${column.configInfo.type} == "fk")
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($deptId = "${className}?.deptId")
#set($deptName = "${className}?.deptName")
<input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${deptId}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:value="${${deptName}}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "input")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<input name="${field}" class="form-control" type="text"#if($column.required) required#end>
</div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
#elseif($column.htmlType == "select" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:checked="${dict.default}"#if($column.required) required#end>
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "datetime")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="${field}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
</div>
</div>
</div>
#elseif($column.htmlType == "textarea")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end></textarea>
</div>
</div>
#end
#end
#end
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "${moduleName}/${classname}"
$("#form-${classname}-add").validate({
rules:{
xxxx:{
required:true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-${classname}-add').serialize());
}
}
</script>
var prefix = ctx + "${moduleName}/${businessName}"
$("#form-${businessName}-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
}
}
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#break
#end
#end
#if($table.tree)
/*${functionName}-新增-选择父部门树*/
function select${BusinessName}Tree() {
var options = {
title: '${functionName}选择',
width: "380",
url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
#end
</script>
</body>
</html>
</html>

View File

@ -1,62 +1,160 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改${tableComment}')" />
<th:block th:include="include :: header('修改${functionName}')" />
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${classname}-edit" th:object="${${classname}}">
<input id="${primaryKey.attrname}" name="${primaryKey.attrname}" th:field="*{${primaryKey.attrname}}" type="hidden">
<form class="form-horizontal m" id="form-${businessName}-edit" th:object="${${className}}">
<input name="${pkColumn.javaField}" th:field="*{${pkColumn.javaField}}" type="hidden">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName)
#if(!${column.configInfo})
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<input id="${column.attrname}" name="${column.attrname}" th:field="*{${column.attrname}}" class="form-control" type="text">
</div>
</div>
#if($column.edit && !$column.superColumn && !$column.pk)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#if(${column.configInfo.type} == "dict")
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<select name="${column.attrname}" class="form-control m-b" th:with="type=${@dict.getType('${column.configInfo.value}')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{${column.attrname}}"></option>
</select>
</div>
</div>
#elseif(${column.configInfo.type} == "date")
<div class="form-group">
<label class="col-sm-3 control-label">${column.columnComment}</label>
<div class="col-sm-8">
<input id="${column.attrname}" name="${column.attrname}" th:field="*{${column.attrname}}" class="form-control time-input" type="text">
</div>
</div>
#elseif(${column.configInfo.type} == "fk")
#set($comment=$column.columnComment)
#end
#set($field=$column.javaField)
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($deptId = "${className}?.deptId")
#set($deptName = "${className}?.deptName")
<input id="treeId" name="${treeParentCode}" type="hidden" th:field="*{${treeParentCode}}" />
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:field="*{parentName}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "input")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<input name="${field}" th:field="*{${field}}" class="form-control" type="text"#if($column.required) required#end>
</div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{${field}}"></option>
</select>
</div>
</div>
#elseif($column.htmlType == "select" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:field="*{${field}}"#if($column.required) required#end>
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "datetime")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="${field}" th:value="${#dates.format(${className}.${field}, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
</div>
</div>
</div>
#elseif($column.htmlType == "textarea")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end>[[*{${field}}]]</textarea>
</div>
</div>
#end
#end
#end
#end
</form>
</form>
</div>
<div th:include="include::footer"></div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
<script type="text/javascript">
var prefix = ctx + "${moduleName}/${classname}";
$("#form-${classname}-edit").validate({
rules:{
xxxx:{
required:true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-${classname}-edit').serialize());
}
}
</script>
var prefix = ctx + "${moduleName}/${businessName}";
$("#form-${businessName}-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
}
}
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#break
#end
#end
#if($table.tree)
/*${functionName}-新增-选择父部门树*/
function select${BusinessName}Tree() {
var options = {
title: '${functionName}选择',
width: "380",
url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
#end
</script>
</body>
</html>
</html>

View File

@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('${functionName}列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
#foreach($column in $columns)
#if($column.query)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.htmlType == "input")
<li>
<p>${comment}</p>
<input type="text" name="${column.javaField}"/>
</li>
#elseif($column.htmlType == "select" || $column.htmlType == "radio" && "" != $dictType)
<li>
<p>${comment}</p>
<select name="${column.javaField}" th:with="type=${@dict.getType('${dictType}')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
#elseif($column.htmlType == "select" || $column.htmlType == "radio" && $dictType)
<li>
<p>${comment}</p>
<select name="${column.javaField}">
<option value="">所有</option>
</select>
</li>
#elseif($column.htmlType == "datetime")
<li class="select-time">
<p>${comment}</p>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[begin${AttrName}]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[end${AttrName}]"/>
</li>
#end
#end
#end
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="${permissionPrefix}:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="${permissionPrefix}:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('${permissionPrefix}:add')}]];
var editFlag = [[${@permission.hasPermi('${permissionPrefix}:edit')}]];
var removeFlag = [[${@permission.hasPermi('${permissionPrefix}:remove')}]];
#foreach($column in $columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
var prefix = ctx + "${moduleName}/${businessName}";
$(function() {
var options = {
code: "${treeCode}",
parentCode: "${treeParentCode}",
expandColumn: "${expandColumn}",
uniqueId: "${pkColumn.javaField}",
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",
exportUrl: prefix + "/export",
modalName: "${functionName}",
columns: [{
field: 'selectItem',
radio: true
},
#foreach($column in $columns)
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk)
#elseif($column.list && "" != $dictType)
{
field : '${javaField}',
title : '${comment}',
align: 'left',
formatter: function(value, row, index) {
return $.table.selectDictLabel(${javaField}Datas, value);
}
},
#elseif($column.list && "" != $javaField)
{
field : '${javaField}',
title : '${comment}',
align: 'left'
},
#end
#end
{
title: '操作',
align: 'center',
align: 'left',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.treeTable.init(options);
});
</script>
</body>
</html>

View File

@ -1,80 +1,93 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('${tableComment}列表')" />
<th:block th:include="include :: header('${functionName}列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName)
#if(!${column.configInfo})
<li>
${column.columnComment}<input type="text" name="${column.attrname}"/>
</li>
#if($column.query)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.htmlType == "input")
<li>
<p>${comment}</p>
<input type="text" name="${column.javaField}"/>
</li>
#elseif($column.htmlType == "select" || $column.htmlType == "radio" && "" != $dictType)
<li>
<p>${comment}</p>
<select name="${column.javaField}" th:with="type=${@dict.getType('${dictType}')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
#elseif($column.htmlType == "select" || $column.htmlType == "radio" && $dictType)
<li>
<p>${comment}</p>
<select name="${column.javaField}">
<option value="">所有</option>
</select>
</li>
#elseif($column.htmlType == "datetime")
<li class="select-time">
<p>${comment}</p>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[begin${AttrName}]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[end${AttrName}]"/>
</li>
#end
#end
#end
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
#else
#if(${column.configInfo.type} == "dict")
<li>
${column.columnComment}<select name="${column.attrname}" th:with="type=${@dict.getType('${column.configInfo.value}')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
#elseif(${column.configInfo.type} == "date")
<li class="select-time">
<label>${column.columnComment} </label>
<input type="text" class="time-input" id="start${column.attrName}" placeholder="开始" name="params[begin${column.attrName}]"/>
<span>-</span>
<input type="text" class="time-input" id="end${column.attrName}" placeholder="结束" name="params[end${column.attrName}]"/>
</li>
#elseif(${column.configInfo.type} == "fk")
#end
#end
#end
#end
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="${moduleName}:${classname}:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="${moduleName}:${classname}:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="${moduleName}:${classname}:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="${moduleName}:${classname}:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="${permissionPrefix}:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="${permissionPrefix}:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="${permissionPrefix}:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="${permissionPrefix}:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('${moduleName}:${classname}:edit')}]];
var removeFlag = [[${@permission.hasPermi('${moduleName}:${classname}:remove')}]];
var prefix = ctx + "${moduleName}/${classname}";
var editFlag = [[${@permission.hasPermi('${permissionPrefix}:edit')}]];
var removeFlag = [[${@permission.hasPermi('${permissionPrefix}:remove')}]];
#foreach($column in $columns)
#if(${column.configInfo} && ${column.configInfo.type} == 'dict')
var datas = [[${@dict.getType('${column.configInfo.value}')}]];
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
var prefix = ctx + "${moduleName}/${businessName}";
$(function() {
var options = {
@ -82,48 +95,51 @@
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "${tableComment}",
showExport: true,
exportUrl: prefix + "/export",
modalName: "${functionName}",
columns: [{
checkbox: true
},
checkbox: true
},
#foreach($column in $columns)
#if($column.columnName == $primaryKey.columnName)
{
field : '${column.attrname}',
title : '${column.columnComment}',
visible: false
},
#elseif($column.columnName != $primaryKey.columnName)
#if(${column.configInfo} && ${column.configInfo.type} == 'dict')
{
field : '${column.attrname}',
title : '${column.columnComment}',
sortable: true,
formatter: function(value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
{
field : '${column.attrname}',
title : '${column.columnComment}',
sortable: true
},
#set($comment=$column.columnComment)
#end
#end
#if($column.pk)
{
field : '${javaField}',
title : '${comment}',
visible: false
},
#elseif($column.list && "" != $dictType)
{
field : '${javaField}',
title : '${comment}',
formatter: function(value, row, index) {
return $.table.selectDictLabel(${javaField}Datas, value);
}
},
#elseif($column.list && "" != $javaField)
{
field : '${javaField}',
title : '${comment}'
},
#end
#end
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.${primaryKey.attrname} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.${primaryKey.attrname} + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('${functionName}树选择')" />
<th:block th:include="include :: ztree-css" />
</head>
<style>
body{height:auto;font-family: "Microsoft YaHei";}
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
</style>
<body class="hold-transition box box-main">
#set($treeId = "${className}?." + $treeCode)
#set($treeName = "${className}?." + $treeName)
<input id="treeId" name="treeId" type="hidden" th:value="${${treeId}}"/>
<input id="treeName" name="treeName" type="hidden" th:value="${${treeName}}"/>
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
<label id="btnShow" title="显示搜索" style="display:none;">︾</label>
<label id="btnHide" title="隐藏搜索">︽</label>
</div>
<div class="treeSearchInput" id="search">
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
</div>
<div class="treeExpandCollapse">
<a href="#" onclick="$.tree.expand()">展开</a> /
<a href="#" onclick="$.tree.collapse()">折叠</a>
</div>
<div id="tree" class="ztree treeselect"></div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
$(function() {
var url = ctx + "system/${businessName}/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
});
function zOnClick(event, treeId, treeNode) {
var treeId = treeNode.id;
var treeName = treeNode.name;
$("#treeId").val(treeId);
$("#treeName").val(treeName);
}
</script>
</body>
</html>

View File

@ -12,116 +12,189 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import ${package}.domain.${className};
import ${package}.service.I${className}Service;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
#if($table.crud)
import com.ruoyi.common.core.page.TableDataInfo;
#elseif($table.tree)
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.domain.Ztree;
#end
/**
* ${tableComment} 信息操作处理
* ${functionName}Controller
*
* @author ${author}
* @date ${datetime}
*/
@Controller
@RequestMapping("/${moduleName}/${classname}")
public class ${className}Controller extends BaseController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController
{
private String prefix = "${moduleName}/${classname}";
@Autowired
private I${className}Service ${classname}Service;
@RequiresPermissions("${moduleName}:${classname}:view")
@GetMapping()
public String ${classname}()
{
return prefix + "/${classname}";
}
/**
* 查询${tableComment}列表
*/
@RequiresPermissions("${moduleName}:${classname}:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(${className} ${classname})
{
startPage();
List<${className}> list = ${classname}Service.select${className}List(${classname});
return getDataTable(list);
}
/**
* 导出${tableComment}列表
*/
@RequiresPermissions("${moduleName}:${classname}:export")
private String prefix = "${moduleName}/${businessName}";
@Autowired
private I${ClassName}Service ${className}Service;
@RequiresPermissions("${permissionPrefix}:view")
@GetMapping()
public String ${businessName}()
{
return prefix + "/${businessName}";
}
#if($table.tree)
/**
* 查询${functionName}树列表
*/
@RequiresPermissions("${permissionPrefix}:list")
@PostMapping("/list")
@ResponseBody
public List<${ClassName}> list(${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return list;
}
#elseif($table.crud)
/**
* 查询${functionName}列表
*/
@RequiresPermissions("${permissionPrefix}:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(${ClassName} ${className})
{
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list);
}
#end
/**
* 导出${functionName}列表
*/
@RequiresPermissions("${permissionPrefix}:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(${className} ${classname})
public AjaxResult export(${ClassName} ${className})
{
List<${className}> list = ${classname}Service.select${className}List(${classname});
ExcelUtil<${className}> util = new ExcelUtil<${className}>(${className}.class);
return util.exportExcel(list, "${classname}");
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
return util.exportExcel(list, "${businessName}");
}
/**
* 新增${tableComment}
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存${tableComment}
*/
@RequiresPermissions("${moduleName}:${classname}:add")
@Log(title = "${tableComment}", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(${className} ${classname})
{
return toAjax(${classname}Service.insert${className}(${classname}));
}
/**
* 修改${tableComment}
*/
@GetMapping("/edit/{${primaryKey.attrname}}")
public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap)
{
${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname});
mmap.put("${classname}", ${classname});
return prefix + "/edit";
}
/**
* 修改保存${tableComment}
*/
@RequiresPermissions("${moduleName}:${classname}:edit")
@Log(title = "${tableComment}", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(${className} ${classname})
{
return toAjax(${classname}Service.update${className}(${classname}));
}
/**
* 删除${tableComment}
*/
@RequiresPermissions("${moduleName}:${classname}:remove")
@Log(title = "${tableComment}", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(${classname}Service.delete${className}ByIds(ids));
}
#if($table.crud)
/**
* 新增${functionName}
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
#elseif($table.tree)
/**
* 新增${functionName}
*/
@GetMapping(value = { "/add/{${pkColumn.javaField}}", "/add/" })
public String add(@PathVariable(value = "${pkColumn.javaField}", required = false) Long ${pkColumn.javaField}, ModelMap mmap)
{
if (StringUtils.isNotNull(${pkColumn.javaField}))
{
mmap.put("${className}", ${className}Service.select${ClassName}ById(${pkColumn.javaField}));
}
return prefix + "/add";
}
#end
/**
* 新增保存${functionName}
*/
@RequiresPermissions("${permissionPrefix}:add")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(${ClassName} ${className})
{
return toAjax(${className}Service.insert${ClassName}(${className}));
}
/**
* 修改${functionName}
*/
@GetMapping("/edit/{${pkColumn.javaField}}")
public String edit(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}, ModelMap mmap)
{
${ClassName} ${className} = ${className}Service.select${ClassName}ById(${pkColumn.javaField});
mmap.put("${className}", ${className});
return prefix + "/edit";
}
/**
* 修改保存${functionName}
*/
@RequiresPermissions("${permissionPrefix}:edit")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(${ClassName} ${className})
{
return toAjax(${className}Service.update${ClassName}(${className}));
}
#if($table.crud)
/**
* 删除${functionName}
*/
@RequiresPermissions("${permissionPrefix}:remove")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(${className}Service.delete${ClassName}ByIds(ids));
}
#elseif($table.tree)
/**
* 删除
*/
@RequiresPermissions("${permissionPrefix}:remove")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@GetMapping("/remove/{${pkColumn.javaField}}")
@ResponseBody
public AjaxResult remove(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
return toAjax(${className}Service.delete${ClassName}ById(${pkColumn.javaField}));
}
#end
#if($table.tree)
/**
* 选择${functionName}树
*/
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
@GetMapping(value = { "/select${BusinessName}Tree/{${pkColumn.javaField}}", "/select${BusinessName}Tree/" })
public String select${BusinessName}Tree(@PathVariable(value = "${pkColumn.javaField}", required = false) Long ${pkColumn.javaField}, ModelMap mmap)
{
if (StringUtils.isNotNull(${pkColumn.javaField}))
{
mmap.put("${className}", ${className}Service.select${ClassName}ById(${pkColumn.javaField}));
}
return prefix + "/tree";
}
/**
* 加载${functionName}树列表
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = ${className}Service.select${ClassName}Tree();
return ztrees;
}
#end
}

View File

@ -1,62 +1,61 @@
package ${package}.mapper;
package ${packageName}.mapper;
import ${package}.domain.${className};
import java.util.List;
import ${packageName}.domain.${ClassName};
import java.util.List;
/**
* ${tableComment} 数据层
* ${functionName}Mapper接口
*
* @author ${author}
* @date ${datetime}
*/
public interface ${className}Mapper
public interface ${ClassName}Mapper
{
/**
* 查询${tableComment}信息
/**
* 查询${functionName}
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
/**
* 查询${tableComment}列表
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${classname} ${tableComment}信息
* @return ${tableComment}集合
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${className}> select${className}List(${className} ${classname});
/**
* 新增${tableComment}
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${classname} ${tableComment}信息
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${className}(${className} ${classname});
/**
* 修改${tableComment}
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${classname} ${tableComment}信息
* @param ${className} ${functionName}
* @return 结果
*/
public int update${className}(${className} ${classname});
/**
* 删除${tableComment}
public int update${ClassName}(${ClassName} ${className});
/**
* 删除${functionName}
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
/**
* 批量删除${tableComment}
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 批量删除${functionName}
*
* @param ${primaryKey.attrname}s 需要删除的数据ID
* @param ${pkColumn.javaField}s 需要删除的数据ID
* @return 结果
*/
public int delete${className}ByIds(String[] ${primaryKey.attrname}s);
}
public int delete${ClassName}ByIds(String[] ${pkColumn.javaField}s);
}

View File

@ -1,54 +1,73 @@
package ${package}.service;
package ${packageName}.service;
import ${package}.domain.${className};
import ${packageName}.domain.${ClassName};
import java.util.List;
#if($table.tree)
import com.ruoyi.common.core.domain.Ztree;
#end
/**
* ${tableComment} 服务层
* ${functionName}Service接口
*
* @author ${author}
* @date ${datetime}
*/
public interface I${className}Service
public interface I${ClassName}Service
{
/**
* 查询${tableComment}信息
/**
* 查询${functionName}
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
/**
* 查询${tableComment}列表
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${classname} ${tableComment}信息
* @return ${tableComment}集合
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${className}> select${className}List(${className} ${classname});
/**
* 新增${tableComment}
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${classname} ${tableComment}信息
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${className}(${className} ${classname});
/**
* 修改${tableComment}
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${classname} ${tableComment}信息
* @param ${className} ${functionName}
* @return 结果
*/
public int update${className}(${className} ${classname});
/**
* 删除${tableComment}信息
public int update${ClassName}(${ClassName} ${className});
/**
* 批量删除${functionName}
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int delete${className}ByIds(String ids);
public int delete${ClassName}ByIds(String ids);
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.tree)
/**
* 查询${functionName}树列表
*
* @return 所有${functionName}信息
*/
public List<Ztree> select${ClassName}Tree();
#end
}

View File

@ -1,83 +1,140 @@
package ${package}.service.impl;
package ${packageName}.service.impl;
import java.util.List;
#if($table.tree)
import java.util.ArrayList;
import com.ruoyi.common.core.domain.Ztree;
#end
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.ruoyi.common.utils.DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ${package}.mapper.${className}Mapper;
import ${package}.domain.${className};
import ${package}.service.I${className}Service;
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.common.core.text.Convert;
/**
* ${tableComment} 服务层实现
* ${functionName}Service业务层处理
*
* @author ${author}
* @date ${datetime}
*/
@Service
public class ${className}ServiceImpl implements I${className}Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service
{
@Autowired
private ${className}Mapper ${classname}Mapper;
@Autowired
private ${ClassName}Mapper ${className}Mapper;
/**
* 查询${tableComment}信息
/**
* 查询${functionName}
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
@Override
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
{
return ${classname}Mapper.select${className}ById(${primaryKey.attrname});
}
/**
* 查询${tableComment}列表
*
* @param ${classname} ${tableComment}信息
* @return ${tableComment}集合
*/
@Override
public List<${className}> select${className}List(${className} ${classname})
{
return ${classname}Mapper.select${className}List(${classname});
}
/**
* 新增${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
@Override
public int insert${className}(${className} ${classname})
{
return ${classname}Mapper.insert${className}(${classname});
}
/**
* 修改${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
@Override
public int update${className}(${className} ${classname})
{
return ${classname}Mapper.update${className}(${classname});
}
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField});
}
/**
* 删除${tableComment}对象
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}
*/
@Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
{
return ${className}Mapper.select${ClassName}List(${className});
}
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
@Override
public int insert${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
#end
return ${className}Mapper.insert${ClassName}(${className});
}
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
@Override
public int update${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end
#end
return ${className}Mapper.update${ClassName}(${className});
}
/**
* 删除${functionName}对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int delete${className}ByIds(String ids)
{
return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids));
}
@Override
public int delete${ClassName}ByIds(String ids)
{
return ${className}Mapper.delete${ClassName}ByIds(Convert.toStrArray(ids));
}
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
}
#if($table.tree)
/**
* 查询${functionName}树列表
*
* @return 所有${functionName}信息
*/
@Override
public List<Ztree> select${ClassName}Tree()
{
List<${ClassName}> ${className}List = ${className}Mapper.select${ClassName}List(new ${ClassName}());
List<Ztree> ztrees = new ArrayList<Ztree>();
for (${ClassName} ${className} : ${className}List)
{
Ztree ztree = new Ztree();
#set($TreeCode=$treeCode.substring(0,1).toUpperCase() + ${treeCode.substring(1)})
#set($TreeParentCode=$treeParentCode.substring(0,1).toUpperCase() + ${treeParentCode.substring(1)})
#set($TreeName=$treeName.substring(0,1).toUpperCase() + ${treeName.substring(1)})
ztree.setId(${className}.get${TreeCode}());
ztree.setpId(${className}.get${TreeParentCode}());
ztree.setName(${className}.get${TreeName}());
ztree.setTitle(${className}.get${TreeName}());
ztrees.add(ztree);
}
return ztrees;
}
#end
}

View File

@ -1,56 +1,75 @@
package ${package}.domain;
package ${packageName}.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
#if($table.crud)
import com.ruoyi.common.core.domain.BaseEntity;
#foreach ($column in $columns)
#if($column.attrType == 'Date' && ($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark'))
import java.util.Date;
#break
#end
#end
#foreach ($column in $columns)
#if($column.attrType == 'BigDecimal')
import java.math.BigDecimal;
#break
#elseif($table.tree)
import com.ruoyi.common.core.domain.TreeEntity;
#end
#foreach ($import in $importList)
import ${import};
#end
/**
* ${tableComment}表 ${tableName}
* ${functionName}对象 ${tableName}
*
* @author ${author}
* @date ${datetime}
*/
public class ${className} extends BaseEntity
#if($table.crud)
#set($Entity="BaseEntity")
#elseif($table.tree)
#set($Entity="TreeEntity")
#end
public class ${ClassName} extends ${Entity}
{
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark')
/** $column.columnComment */
private $column.attrType $column.attrname;
#end
#end
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark')
public void set${column.attrName}($column.attrType $column.attrname)
{
this.$column.attrname = $column.attrname;
}
#if(!$column.superColumn)
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
private $column.javaType $column.javaField;
public $column.attrType get${column.attrName}()
{
return $column.attrname;
}
#end
#end
#foreach ($column in $columns)
#if(!$column.superColumn)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
#end
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns)
.append("${column.attrname}", get${column.attrName}())
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
.append("${column.javaField}", get${AttrName}())
#end
.toString();
}

View File

@ -1,19 +1,19 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${tableComment}', '3', '1', '/${moduleName}/${classname}', 'C', '0', '${moduleName}:${classname}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${tableComment}菜单');
values('${functionName}', '3', '1', '/${moduleName}/${businessName}', 'C', '0', '${permissionPrefix}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${tableComment}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${classname}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}查询', @parentId, '1', '#', 'F', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${tableComment}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${classname}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}新增', @parentId, '2', '#', 'F', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${tableComment}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${classname}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}修改', @parentId, '3', '#', 'F', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${tableComment}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${classname}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}删除', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');

View File

@ -2,70 +2,106 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.mapper.${className}Mapper">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${className}" id="${className}Result">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.attrname}" column="${column.columnName}" />
<result property="${column.javaField}" column="${column.columnName}" />
#end
#if($table.tree)
<result property="parentName" column="parent_name" />
#end
</resultMap>
<sql id="select${className}Vo">
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
</sql>
<select id="select${className}List" parameterType="${className}" resultMap="${className}Result">
<include refid="select${className}Vo"/>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname.trim() != '' #end"> and $column.columnName = #{$column.attrname}</if>
#end
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#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>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
#elseif(\$queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if>
#elseif(\$queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if>
#elseif(\$queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if>
#elseif(\$queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $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>
#end
#end
#end
</where>
#if($table.tree)
order by ${tree_parent_code}
#end
</select>
<select id="select${className}ById" parameterType="${primaryKey.attrType}" resultMap="${className}Result">
<include refid="select${className}Vo"/>
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
#if($table.crud)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.tree)
select#foreach($column in $columns) t.$column.columnName,#end p.dept_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}}
#end
</select>
<insert id="insert${className}" parameterType="${className}"#if($primaryKey.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$primaryKey.attrname"#end>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName,</if>
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName,</if>
#end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">#{$column.attrname},</if>
#end
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">#{$column.javaField},</if>
#end
#end
</trim>
</insert>
<update id="update${className}" parameterType="${className}">
<update id="update${ClassName}" parameterType="${ClassName}">
update ${tableName}
<trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName)
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName = #{$column.attrname},</if>
#if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
#end
#end
</trim>
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update>
<delete id="delete${className}ById" parameterType="${primaryKey.attrType}">
delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}}
<delete id="delete${ClassName}ById" parameterType="${pkColumn.javaType}">
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</delete>
<delete id="delete${className}ByIds" parameterType="String">
delete from ${tableName} where ${primaryKey.columnName} in
<foreach item="${primaryKey.attrname}" collection="array" open="(" separator="," close=")">
#{${primaryKey.attrname}}
<delete id="delete${ClassName}ByIds" parameterType="String">
delete from ${tableName} where ${pkColumn.columnName} in
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
#{${pkColumn.javaField}}
</foreach>
</delete>