Merge branch 'duhanyu' of http://39.101.188.84:7000/suzhou-jichuang-lanhai/JinJiHuJava
commit
bc27886dc7
@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
|
||||
<description>
|
||||
generator代码生成
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,60 +0,0 @@
|
||||
package com.ruoyi.generator.mapper;
|
||||
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务字段 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface GenTableColumnMapper {
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 列信息
|
||||
*/
|
||||
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
||||
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
* @param tableId 业务字段编号
|
||||
* @return 业务字段集合
|
||||
*/
|
||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 新增业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
||||
|
||||
/**
|
||||
* 修改业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
||||
|
||||
/**
|
||||
* 删除业务字段
|
||||
*
|
||||
* @param genTableColumns 列数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
|
||||
|
||||
/**
|
||||
* 批量删除业务字段
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGenTableColumnByIds(Long[] ids);
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.ruoyi.generator.mapper;
|
||||
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface GenTableMapper {
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
* @param genTable 业务信息
|
||||
* @return 业务集合
|
||||
*/
|
||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
*
|
||||
* @param genTable 业务信息
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
*
|
||||
* @param tableNames 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
||||
|
||||
/**
|
||||
* 查询所有表信息
|
||||
*
|
||||
* @return 表信息集合
|
||||
*/
|
||||
public List<GenTable> selectGenTableAll();
|
||||
|
||||
/**
|
||||
* 查询表ID业务信息
|
||||
*
|
||||
* @param id 业务ID
|
||||
* @return 业务信息
|
||||
*/
|
||||
public GenTable selectGenTableById(Long id);
|
||||
|
||||
/**
|
||||
* 查询表名称业务信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 业务信息
|
||||
*/
|
||||
public GenTable selectGenTableByName(String tableName);
|
||||
|
||||
/**
|
||||
* 新增业务
|
||||
*
|
||||
* @param genTable 业务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGenTable(GenTable genTable);
|
||||
|
||||
/**
|
||||
* 修改业务
|
||||
*
|
||||
* @param genTable 业务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGenTable(GenTable genTable);
|
||||
|
||||
/**
|
||||
* 批量删除业务
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGenTableByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 创建表
|
||||
*
|
||||
* @param sql 表结构
|
||||
* @return 结果
|
||||
*/
|
||||
public int createTable(String sql);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package com.ruoyi.generator.service;
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务字段 服务层实现
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
||||
@Autowired
|
||||
private GenTableColumnMapper genTableColumnMapper;
|
||||
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
* @param tableId 业务字段编号
|
||||
* @return 业务字段集合
|
||||
*/
|
||||
@Override
|
||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
||||
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGenTableColumn(GenTableColumn genTableColumn) {
|
||||
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGenTableColumn(GenTableColumn genTableColumn) {
|
||||
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除业务字段对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGenTableColumnByIds(String ids) {
|
||||
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.ruoyi.generator.service;
|
||||
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务字段 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface IGenTableColumnService {
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
* @param tableId 业务字段编号
|
||||
* @return 业务字段集合
|
||||
*/
|
||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 新增业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
||||
|
||||
/**
|
||||
* 修改业务字段
|
||||
*
|
||||
* @param genTableColumn 业务字段信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
||||
|
||||
/**
|
||||
* 删除业务字段信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGenTableColumnByIds(String ids);
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
package com.ruoyi.generator.util;
|
||||
|
||||
import com.ruoyi.common.constant.GenConstants;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.generator.config.GenConfig;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 代码生成器 工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class GenUtils {
|
||||
/**
|
||||
* 初始化表信息
|
||||
*/
|
||||
public static void initTable(GenTable genTable, String operName) {
|
||||
genTable.setClassName(convertClassName(genTable.getTableName()));
|
||||
genTable.setPackageName(GenConfig.getPackageName());
|
||||
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
||||
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
||||
genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
||||
genTable.setFunctionAuthor(GenConfig.getAuthor());
|
||||
genTable.setCreateBy(operName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化列属性字段
|
||||
*/
|
||||
public static void initColumnField(GenTableColumn column, GenTable table) {
|
||||
String dataType = getDbType(column.getColumnType());
|
||||
String columnName = column.getColumnName();
|
||||
column.setTableId(table.getTableId());
|
||||
column.setCreateBy(table.getCreateBy());
|
||||
// 设置java字段名
|
||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||
// 设置默认类型
|
||||
column.setJavaType(GenConstants.TYPE_STRING);
|
||||
column.setQueryType(GenConstants.QUERY_EQ);
|
||||
|
||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
|
||||
// 字符串长度超过500设置为文本域
|
||||
Integer columnLength = getColumnLength(column.getColumnType());
|
||||
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||
column.setHtmlType(htmlType);
|
||||
} else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
|
||||
column.setJavaType(GenConstants.TYPE_DATE);
|
||||
column.setHtmlType(GenConstants.HTML_DATETIME);
|
||||
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||
|
||||
// 如果是浮点型 统一用BigDecimal
|
||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||
}
|
||||
// 如果是整形
|
||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
||||
}
|
||||
// 长整形
|
||||
else {
|
||||
column.setJavaType(GenConstants.TYPE_LONG);
|
||||
}
|
||||
}
|
||||
|
||||
// 插入字段(默认所有字段都需要插入)
|
||||
column.setIsInsert(GenConstants.REQUIRE);
|
||||
|
||||
// 编辑字段
|
||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
|
||||
column.setIsEdit(GenConstants.REQUIRE);
|
||||
}
|
||||
// 列表字段
|
||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
|
||||
column.setIsList(GenConstants.REQUIRE);
|
||||
}
|
||||
// 查询字段
|
||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
|
||||
column.setIsQuery(GenConstants.REQUIRE);
|
||||
}
|
||||
|
||||
// 查询字段类型
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
|
||||
column.setQueryType(GenConstants.QUERY_LIKE);
|
||||
}
|
||||
// 状态字段设置单选框
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
|
||||
column.setHtmlType(GenConstants.HTML_RADIO);
|
||||
}
|
||||
// 类型&性别字段设置下拉框
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
|
||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
||||
}
|
||||
// 图片字段设置图片上传控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
|
||||
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
||||
}
|
||||
// 文件字段设置文件上传控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "file")) {
|
||||
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
||||
}
|
||||
// 内容字段设置富文本控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
|
||||
column.setHtmlType(GenConstants.HTML_EDITOR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数组是否包含指定值
|
||||
*
|
||||
* @param arr 数组
|
||||
* @param targetValue 值
|
||||
* @return 是否包含
|
||||
*/
|
||||
public static boolean arraysContains(String[] arr, String targetValue) {
|
||||
return Arrays.asList(arr).contains(targetValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块名
|
||||
*
|
||||
* @param packageName 包名
|
||||
* @return 模块名
|
||||
*/
|
||||
public static String getModuleName(String packageName) {
|
||||
int lastIndex = packageName.lastIndexOf(".");
|
||||
int nameLength = packageName.length();
|
||||
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务名
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 业务名
|
||||
*/
|
||||
public static String getBusinessName(String tableName) {
|
||||
int lastIndex = tableName.lastIndexOf("_");
|
||||
int nameLength = tableName.length();
|
||||
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表名转换成Java类名
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 类名
|
||||
*/
|
||||
public static String convertClassName(String tableName) {
|
||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||
String tablePrefix = GenConfig.getTablePrefix();
|
||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
|
||||
String[] searchList = StringUtils.split(tablePrefix, ",");
|
||||
tableName = replaceFirst(tableName, searchList);
|
||||
}
|
||||
return StringUtils.convertToCamelCase(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量替换前缀
|
||||
*
|
||||
* @param replacementm 替换值
|
||||
* @param searchList 替换列表
|
||||
* @return
|
||||
*/
|
||||
public static String replaceFirst(String replacementm, String[] searchList) {
|
||||
String text = replacementm;
|
||||
for (String searchString : searchList) {
|
||||
if (replacementm.startsWith(searchString)) {
|
||||
text = replacementm.replaceFirst(searchString, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字替换
|
||||
*
|
||||
* @param text 需要被替换的名字
|
||||
* @return 替换后的名字
|
||||
*/
|
||||
public static String replaceText(String text) {
|
||||
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型字段
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static String getDbType(String columnType) {
|
||||
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||
return StringUtils.substringBefore(columnType, "(");
|
||||
} else {
|
||||
return columnType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段长度
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static Integer getColumnLength(String columnType) {
|
||||
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
||||
return Integer.valueOf(length);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,131 +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.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="Long" 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 '0' 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>
|
||||
<if test="columnComment != null">column_comment = #{columnComment},</if>
|
||||
<if test="javaType != null">java_type = #{javaType},</if>
|
||||
<if test="javaField != null">java_field = #{javaField},</if>
|
||||
<if test="isInsert != null">is_insert = #{isInsert},</if>
|
||||
<if test="isEdit != null">is_edit = #{isEdit},</if>
|
||||
<if test="isList != null">is_list = #{isList},</if>
|
||||
<if test="isQuery != null">is_query = #{isQuery},</if>
|
||||
<if test="isRequired != null">is_required = #{isRequired},</if>
|
||||
<if test="queryType != null">query_type = #{queryType},</if>
|
||||
<if test="htmlType != null">html_type = #{htmlType},</if>
|
||||
<if test="dictType != null">dict_type = #{dictType},</if>
|
||||
<if test="sort != null">sort = #{sort},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
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>
|
||||
|
||||
<delete id="deleteGenTableColumns">
|
||||
delete from gen_table_column where column_id in
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.columnId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -1,221 +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.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="subTableName" column="sub_table_name"/>
|
||||
<result property="subTableFkName" column="sub_table_fk_name"/>
|
||||
<result property="className" column="class_name"/>
|
||||
<result property="tplCategory" column="tpl_category"/>
|
||||
<result property="tplWebType" column="tpl_web_type"/>
|
||||
<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="genType" column="gen_type"/>
|
||||
<result property="genPath" column="gen_path"/>
|
||||
<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, sub_table_name, sub_table_fk_name, class_name, tpl_category,
|
||||
tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path,
|
||||
options, create_by, create_time, update_by, update_time, remark from gen_table
|
||||
</sql>
|
||||
|
||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
<include refid="selectGenTableVo"/>
|
||||
<where>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||
</if>
|
||||
<if test="tableComment != null and tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
</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 lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||
</if>
|
||||
<if test="tableComment != null and tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
order by create_time desc
|
||||
</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.sub_table_name, t.sub_table_fk_name, t.class_name,
|
||||
t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
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} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name,
|
||||
t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
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} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name,
|
||||
t.tpl_category, t.tpl_web_type, 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
|
||||
order by c.sort
|
||||
</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="tplWebType != null and tplWebType != ''">tpl_web_type,</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="genType != null and genType != ''">gen_type,</if>
|
||||
<if test="genPath != null and genPath != ''">gen_path,</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="tplWebType != null and tplWebType != ''">#{tplWebType},</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="genType != null and genType != ''">#{genType},</if>
|
||||
<if test="genPath != null and genPath != ''">#{genPath},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="createTable">
|
||||
${sql}
|
||||
</update>
|
||||
|
||||
<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="subTableName != null">sub_table_name = #{subTableName},</if>
|
||||
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
||||
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
||||
<if test="tplWebType != null and tplWebType != ''">tpl_web_type = #{tplWebType},</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>
|
@ -1,108 +0,0 @@
|
||||
package ${packageName}.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}Controller
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${moduleName}/${businessName}")
|
||||
public class ${ClassName}Controller extends BaseController {
|
||||
@Autowired
|
||||
private I${ClassName}Service ${className}Service;
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud || $table.sub)
|
||||
public TableDataInfo list(${ClassName} ${className}) {
|
||||
startPage();
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
return getDataTable(list);
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public AjaxResult list(${ClassName} ${className}) {
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
return success(list);
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 导出${functionName}列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ${ClassName} ${className}) {
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
|
||||
util.exportExcel(response, list, "${functionName}数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取${functionName}详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ${ClassName} ${className}) {
|
||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
|
||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/{${pkColumn.javaField}s}")
|
||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package ${packageName}.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ${packageName}.domain.${ClassName};
|
||||
#if($table.sub)
|
||||
import ${packageName}.domain .${subClassName};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}Mapper接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper {
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
* 批量删除${subTable.functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 批量新增${subTable.functionName}
|
||||
*
|
||||
* @param ${subclassName}List ${subTable.functionName}列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
|
||||
|
||||
/**
|
||||
* 通过${functionName}主键删除${subTable.functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#end
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package ${packageName}.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ${packageName}.domain .${ClassName};
|
||||
|
||||
/**
|
||||
* ${functionName}Service接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${ClassName}Service {
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
package ${packageName}.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
#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;
|
||||
#if($table.sub)
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${packageName}.domain.${subClassName};
|
||||
#end
|
||||
import ${packageName}.mapper.${ClassName}Mapper;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
|
||||
/**
|
||||
* ${functionName}Service业务层处理
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
@Autowired
|
||||
private ${ClassName}Mapper ${className}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${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 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int insert${ClassName}(${ClassName} ${className}) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime')
|
||||
${className}.setCreateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||
insert${subClassName}(${className});
|
||||
return rows;
|
||||
#else
|
||||
return ${className}Mapper.insert${ClassName}(${className});
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int update${ClassName}(${ClassName} ${className}) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'updateTime')
|
||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}())
|
||||
;
|
||||
insert${subClassName}(${className});
|
||||
#end
|
||||
return ${className}Mapper.update${ClassName}(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
}
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
* 新增${subTable.functionName}信息
|
||||
*
|
||||
* @param ${className} ${functionName}对象
|
||||
*/
|
||||
public void insert${subClassName}(${ClassName} ${className}) {
|
||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||
if (StringUtils.isNotNull(${subclassName}List)) {
|
||||
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||
for (${subClassName} ${subclassName} :${subclassName}List)
|
||||
{
|
||||
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
||||
list.add(${subclassName});
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
${className}Mapper.batch${subClassName}(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询${functionName}列表
|
||||
export function list${BusinessName}(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询${functionName}详细
|
||||
export function get${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增${functionName}
|
||||
export function add${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改${functionName}
|
||||
export function update${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除${functionName}
|
||||
export function del${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
|
||||
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
|
@ -1,166 +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="${packageName}.mapper.${ClassName}Mapper">
|
||||
|
||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
||||
#foreach ($column in $columns)
|
||||
<result property="${column.javaField}" column="${column.columnName}"/>
|
||||
#end
|
||||
</resultMap>
|
||||
#if($table.sub)
|
||||
|
||||
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
||||
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}"
|
||||
javaType="java.util.List" resultMap="${subClassName}Result"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
||||
#foreach ($column in $subTable.columns)
|
||||
<result property="${column.javaField}" column="sub_${column.columnName}"/>
|
||||
#end
|
||||
</resultMap>
|
||||
#end
|
||||
|
||||
<sql id="select${ClassName}Vo">
|
||||
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end
|
||||
from ${tableName}
|
||||
</sql>
|
||||
|
||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
#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 > #{$javaField}
|
||||
</if>
|
||||
#elseif($queryType == "GTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
|
||||
and $columnName >= #{$javaField}
|
||||
</if>
|
||||
#elseif($queryType == "LT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
|
||||
and $columnName < #{$javaField}
|
||||
</if>
|
||||
#elseif($queryType == "LTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
|
||||
and $columnName <= #{$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>
|
||||
</select>
|
||||
|
||||
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}"
|
||||
resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||
#if($table.crud || $table.tree)
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#elseif($table.sub)
|
||||
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
|
||||
#foreach($column in $subTable.columns) b.$column.columnName as
|
||||
sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
|
||||
|
||||
from ${tableName} a
|
||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#end
|
||||
</select>
|
||||
|
||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true"
|
||||
keyProperty="$pkColumn.javaField"#end>
|
||||
insert into ${tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null#if($column.javaType ==
|
||||
'String' && $column.required) and $column.javaField != ''#end">$column.columnName,
|
||||
</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null#if($column.javaType ==
|
||||
'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},
|
||||
</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update${ClassName}" parameterType="${ClassName}">
|
||||
update ${tableName}
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName)
|
||||
<if test="$column.javaField != null#if($column.javaType ==
|
||||
'String' && $column.required) and $column.javaField != ''#end">$column.columnName =
|
||||
#{$column.javaField},
|
||||
</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</update>
|
||||
|
||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</delete>
|
||||
|
||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
|
||||
delete from ${tableName} where ${pkColumn.columnName} in
|
||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
||||
#{${pkColumn.javaField}}
|
||||
</foreach>
|
||||
</delete>
|
||||
#if($table.sub)
|
||||
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
||||
delete from ${subTableName} where ${subTableFkName} in
|
||||
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
||||
#{${subTableFkclassName}}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||
</delete>
|
||||
|
||||
<insert id="batch${subClassName}">
|
||||
insert into ${subTableName}
|
||||
(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size())
|
||||
,#end#end) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#foreach($column in $subTable.columns) #{item.$column.javaField
|
||||
}#if($foreach.count != $subTable.columns.size()),#end#end)
|
||||
</foreach>
|
||||
</insert>
|
||||
#end
|
||||
</mapper>
|
Loading…
Reference in new issue