Commit 3fb292a4c1a6551a7f782af50d385634c5988cc4
1 parent
b04db3d6
代码生成器的编辑界面~
Showing
34 changed files
with
496 additions
and
476 deletions
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
| @@ -37,36 +37,6 @@ import com.ruoyi.generator.service.IGenTableService; | @@ -37,36 +37,6 @@ import com.ruoyi.generator.service.IGenTableService; | ||
| 37 | @RestController | 37 | @RestController |
| 38 | @RequestMapping("/tool/gen") | 38 | @RequestMapping("/tool/gen") |
| 39 | public class GenController extends BaseController { | 39 | public class GenController extends BaseController { |
| 40 | - @Autowired | ||
| 41 | - private IGenTableService genTableService; | ||
| 42 | - | ||
| 43 | - @Autowired | ||
| 44 | - private IGenTableColumnService genTableColumnService; | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 查询代码生成列表 | ||
| 48 | - */ | ||
| 49 | - @PreAuthorize("@ss.hasPermi('tool:gen:list')") | ||
| 50 | - @GetMapping("/list") | ||
| 51 | - public TableDataInfo genList(GenTable genTable) { | ||
| 52 | - startPage(); | ||
| 53 | - List<GenTable> list = genTableService.selectGenTableList(genTable); | ||
| 54 | - return getDataTable(list); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * 修改代码生成业务 | ||
| 59 | - */ | ||
| 60 | - @PreAuthorize("@ss.hasPermi('tool:gen:query')") | ||
| 61 | - @GetMapping(value = "/{talbleId}") | ||
| 62 | - public AjaxResult getInfo(@PathVariable Long talbleId) { | ||
| 63 | - GenTable table = genTableService.selectGenTableById(talbleId); | ||
| 64 | - List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); | ||
| 65 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 66 | - map.put("info", table); | ||
| 67 | - map.put("rows", list); | ||
| 68 | - return AjaxResult.success(map); | ||
| 69 | - } | ||
| 70 | 40 | ||
| 71 | /** | 41 | /** |
| 72 | * 查询数据库列表 | 42 | * 查询数据库列表 |
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java deleted
| 1 | -package com.ruoyi.generator.domain; | ||
| 2 | - | ||
| 3 | -import javax.validation.constraints.NotBlank; | ||
| 4 | - | ||
| 5 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 6 | -import com.ruoyi.common.utils.StringUtils; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 代码生成业务字段表 gen_table_column | ||
| 10 | - * | ||
| 11 | - * @author ruoyi | ||
| 12 | - */ | ||
| 13 | -public class GenTableColumn extends BaseEntity { | ||
| 14 | - | ||
| 15 | - public static boolean isSuperColumn(String javaField) { | ||
| 16 | - return StringUtils.equalsAnyIgnoreCase(javaField, | ||
| 17 | - // BaseEntity | ||
| 18 | - "createBy", "createTime", "updateBy", "updateTime", "remark", | ||
| 19 | - // TreeEntity | ||
| 20 | - "parentName", "parentId", "orderNum", "ancestors"); | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - public boolean isUsableColumn() { | ||
| 24 | - return isUsableColumn(javaField); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - public static boolean isUsableColumn(String javaField) { | ||
| 28 | - // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单 | ||
| 29 | - return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | -} |
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java deleted
| 1 | -package com.ruoyi.generator.mapper; | ||
| 2 | - | ||
| 3 | -import java.util.List; | ||
| 4 | - | ||
| 5 | -import com.ruoyi.generator.domain.GenTableColumn; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * 业务字段 数据层 | ||
| 9 | - * | ||
| 10 | - * @author ruoyi | ||
| 11 | - */ | ||
| 12 | -public interface GenTableColumnMapper { | ||
| 13 | - /** | ||
| 14 | - * 根据表名称查询列信息 | ||
| 15 | - * | ||
| 16 | - * @param tableName 表名称 | ||
| 17 | - * @return 列信息 | ||
| 18 | - */ | ||
| 19 | - public List<GenTableColumn> selectDbTableColumnsByName(String tableName); | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 查询业务字段列表 | ||
| 23 | - * | ||
| 24 | - * @param tableId 业务字段编号 | ||
| 25 | - * @return 业务字段集合 | ||
| 26 | - */ | ||
| 27 | - public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * 新增业务字段 | ||
| 31 | - * | ||
| 32 | - * @param genTableColumn 业务字段信息 | ||
| 33 | - * @return 结果 | ||
| 34 | - */ | ||
| 35 | - public int insertGenTableColumn(GenTableColumn genTableColumn); | ||
| 36 | - | ||
| 37 | - /** | ||
| 38 | - * 修改业务字段 | ||
| 39 | - * | ||
| 40 | - * @param genTableColumn 业务字段信息 | ||
| 41 | - * @return 结果 | ||
| 42 | - */ | ||
| 43 | - public int updateGenTableColumn(GenTableColumn genTableColumn); | ||
| 44 | - | ||
| 45 | - /** | ||
| 46 | - * 删除业务字段 | ||
| 47 | - * | ||
| 48 | - * @param genTableColumns 列数据 | ||
| 49 | - * @return 结果 | ||
| 50 | - */ | ||
| 51 | - public int deleteGenTableColumns(List<GenTableColumn> genTableColumns); | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 批量删除业务字段 | ||
| 55 | - * | ||
| 56 | - * @param ids 需要删除的数据ID | ||
| 57 | - * @return 结果 | ||
| 58 | - */ | ||
| 59 | - public int deleteGenTableColumnByIds(Long[] ids); | ||
| 60 | -} |
ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8" ?> | ||
| 2 | -<!DOCTYPE mapper | ||
| 3 | -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 4 | -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 5 | -<mapper namespace="com.ruoyi.generator.mapper.GenTableColumnMapper"> | ||
| 6 | - | ||
| 7 | - <resultMap type="GenTableColumn" id="GenTableColumnResult"> | ||
| 8 | - <id property="columnId" column="column_id" /> | ||
| 9 | - <result property="tableId" column="table_id" /> | ||
| 10 | - <result property="columnName" column="column_name" /> | ||
| 11 | - <result property="columnComment" column="column_comment" /> | ||
| 12 | - <result property="columnType" column="column_type" /> | ||
| 13 | - <result property="javaType" column="java_type" /> | ||
| 14 | - <result property="javaField" column="java_field" /> | ||
| 15 | - <result property="isPk" column="is_pk" /> | ||
| 16 | - <result property="isIncrement" column="is_increment" /> | ||
| 17 | - <result property="isRequired" column="is_required" /> | ||
| 18 | - <result property="isInsert" column="is_insert" /> | ||
| 19 | - <result property="isEdit" column="is_edit" /> | ||
| 20 | - <result property="isList" column="is_list" /> | ||
| 21 | - <result property="isQuery" column="is_query" /> | ||
| 22 | - <result property="queryType" column="query_type" /> | ||
| 23 | - <result property="htmlType" column="html_type" /> | ||
| 24 | - <result property="dictType" column="dict_type" /> | ||
| 25 | - <result property="sort" column="sort" /> | ||
| 26 | - <result property="createBy" column="create_by" /> | ||
| 27 | - <result property="createTime" column="create_time" /> | ||
| 28 | - <result property="updateBy" column="update_by" /> | ||
| 29 | - <result property="updateTime" column="update_time" /> | ||
| 30 | - </resultMap> | ||
| 31 | - | ||
| 32 | - <sql id="selectGenTableColumnVo"> | ||
| 33 | - 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 | ||
| 34 | - </sql> | ||
| 35 | - | ||
| 36 | - <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> | ||
| 37 | - <include refid="selectGenTableColumnVo"/> | ||
| 38 | - where table_id = #{tableId} | ||
| 39 | - order by sort | ||
| 40 | - </select> | ||
| 41 | - | ||
| 42 | - <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> | ||
| 43 | - 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 | ||
| 44 | - from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) | ||
| 45 | - order by ordinal_position | ||
| 46 | - </select> | ||
| 47 | - | ||
| 48 | - <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> | ||
| 49 | - insert into gen_table_column ( | ||
| 50 | - <if test="tableId != null and tableId != ''">table_id,</if> | ||
| 51 | - <if test="columnName != null and columnName != ''">column_name,</if> | ||
| 52 | - <if test="columnComment != null and columnComment != ''">column_comment,</if> | ||
| 53 | - <if test="columnType != null and columnType != ''">column_type,</if> | ||
| 54 | - <if test="javaType != null and javaType != ''">java_type,</if> | ||
| 55 | - <if test="javaField != null and javaField != ''">java_field,</if> | ||
| 56 | - <if test="isPk != null and isPk != ''">is_pk,</if> | ||
| 57 | - <if test="isIncrement != null and isIncrement != ''">is_increment,</if> | ||
| 58 | - <if test="isRequired != null and isRequired != ''">is_required,</if> | ||
| 59 | - <if test="isInsert != null and isInsert != ''">is_insert,</if> | ||
| 60 | - <if test="isEdit != null and isEdit != ''">is_edit,</if> | ||
| 61 | - <if test="isList != null and isList != ''">is_list,</if> | ||
| 62 | - <if test="isQuery != null and isQuery != ''">is_query,</if> | ||
| 63 | - <if test="queryType != null and queryType != ''">query_type,</if> | ||
| 64 | - <if test="htmlType != null and htmlType != ''">html_type,</if> | ||
| 65 | - <if test="dictType != null and dictType != ''">dict_type,</if> | ||
| 66 | - <if test="sort != null">sort,</if> | ||
| 67 | - <if test="createBy != null and createBy != ''">create_by,</if> | ||
| 68 | - create_time | ||
| 69 | - )values( | ||
| 70 | - <if test="tableId != null and tableId != ''">#{tableId},</if> | ||
| 71 | - <if test="columnName != null and columnName != ''">#{columnName},</if> | ||
| 72 | - <if test="columnComment != null and columnComment != ''">#{columnComment},</if> | ||
| 73 | - <if test="columnType != null and columnType != ''">#{columnType},</if> | ||
| 74 | - <if test="javaType != null and javaType != ''">#{javaType},</if> | ||
| 75 | - <if test="javaField != null and javaField != ''">#{javaField},</if> | ||
| 76 | - <if test="isPk != null and isPk != ''">#{isPk},</if> | ||
| 77 | - <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if> | ||
| 78 | - <if test="isRequired != null and isRequired != ''">#{isRequired},</if> | ||
| 79 | - <if test="isInsert != null and isInsert != ''">#{isInsert},</if> | ||
| 80 | - <if test="isEdit != null and isEdit != ''">#{isEdit},</if> | ||
| 81 | - <if test="isList != null and isList != ''">#{isList},</if> | ||
| 82 | - <if test="isQuery != null and isQuery != ''">#{isQuery},</if> | ||
| 83 | - <if test="queryType != null and queryType != ''">#{queryType},</if> | ||
| 84 | - <if test="htmlType != null and htmlType != ''">#{htmlType},</if> | ||
| 85 | - <if test="dictType != null and dictType != ''">#{dictType},</if> | ||
| 86 | - <if test="sort != null">#{sort},</if> | ||
| 87 | - <if test="createBy != null and createBy != ''">#{createBy},</if> | ||
| 88 | - sysdate() | ||
| 89 | - ) | ||
| 90 | - </insert> | ||
| 91 | - | ||
| 92 | - <update id="updateGenTableColumn" parameterType="GenTableColumn"> | ||
| 93 | - update gen_table_column | ||
| 94 | - <set> | ||
| 95 | - column_comment = #{columnComment}, | ||
| 96 | - java_type = #{javaType}, | ||
| 97 | - java_field = #{javaField}, | ||
| 98 | - is_insert = #{isInsert}, | ||
| 99 | - is_edit = #{isEdit}, | ||
| 100 | - is_list = #{isList}, | ||
| 101 | - is_query = #{isQuery}, | ||
| 102 | - is_required = #{isRequired}, | ||
| 103 | - query_type = #{queryType}, | ||
| 104 | - html_type = #{htmlType}, | ||
| 105 | - dict_type = #{dictType}, | ||
| 106 | - sort = #{sort}, | ||
| 107 | - update_by = #{updateBy}, | ||
| 108 | - update_time = sysdate() | ||
| 109 | - </set> | ||
| 110 | - where column_id = #{columnId} | ||
| 111 | - </update> | ||
| 112 | - | ||
| 113 | - <delete id="deleteGenTableColumnByIds" parameterType="Long"> | ||
| 114 | - delete from gen_table_column where table_id in | ||
| 115 | - <foreach collection="array" item="tableId" open="(" separator="," close=")"> | ||
| 116 | - #{tableId} | ||
| 117 | - </foreach> | ||
| 118 | - </delete> | ||
| 119 | - | ||
| 120 | - <delete id="deleteGenTableColumns"> | ||
| 121 | - delete from gen_table_column where column_id in | ||
| 122 | - <foreach collection="list" item="item" open="(" separator="," close=")"> | ||
| 123 | - #{item.columnId} | ||
| 124 | - </foreach> | ||
| 125 | - </delete> | ||
| 126 | - | ||
| 127 | -</mapper> | ||
| 128 | \ No newline at end of file | 0 | \ No newline at end of file |
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
| @@ -4,75 +4,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -4,75 +4,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | <mapper namespace="com.ruoyi.generator.mapper.GenTableMapper"> | 5 | <mapper namespace="com.ruoyi.generator.mapper.GenTableMapper"> |
| 6 | 6 | ||
| 7 | - <resultMap type="GenTable" id="GenTableResult"> | ||
| 8 | - <id property="tableId" column="table_id" /> | ||
| 9 | - <result property="tableName" column="table_name" /> | ||
| 10 | - <result property="tableComment" column="table_comment" /> | ||
| 11 | - <result property="className" column="class_name" /> | ||
| 12 | - <result property="tplCategory" column="tpl_category" /> | ||
| 13 | - <result property="packageName" column="package_name" /> | ||
| 14 | - <result property="moduleName" column="module_name" /> | ||
| 15 | - <result property="businessName" column="business_name" /> | ||
| 16 | - <result property="functionName" column="function_name" /> | ||
| 17 | - <result property="functionAuthor" column="function_author" /> | ||
| 18 | - <result property="genType" column="gen_type" /> | ||
| 19 | - <result property="genPath" column="gen_path" /> | ||
| 20 | - <result property="options" column="options" /> | ||
| 21 | - <result property="createBy" column="create_by" /> | ||
| 22 | - <result property="createTime" column="create_time" /> | ||
| 23 | - <result property="updateBy" column="update_by" /> | ||
| 24 | - <result property="updateTime" column="update_time" /> | ||
| 25 | - <result property="remark" column="remark" /> | ||
| 26 | - <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> | ||
| 27 | - </resultMap> | ||
| 28 | - | ||
| 29 | - <resultMap type="GenTableColumn" id="GenTableColumnResult"> | ||
| 30 | - <id property="columnId" column="column_id" /> | ||
| 31 | - <result property="tableId" column="table_id" /> | ||
| 32 | - <result property="columnName" column="column_name" /> | ||
| 33 | - <result property="columnComment" column="column_comment" /> | ||
| 34 | - <result property="columnType" column="column_type" /> | ||
| 35 | - <result property="javaType" column="java_type" /> | ||
| 36 | - <result property="javaField" column="java_field" /> | ||
| 37 | - <result property="isPk" column="is_pk" /> | ||
| 38 | - <result property="isIncrement" column="is_increment" /> | ||
| 39 | - <result property="isRequired" column="is_required" /> | ||
| 40 | - <result property="isInsert" column="is_insert" /> | ||
| 41 | - <result property="isEdit" column="is_edit" /> | ||
| 42 | - <result property="isList" column="is_list" /> | ||
| 43 | - <result property="isQuery" column="is_query" /> | ||
| 44 | - <result property="queryType" column="query_type" /> | ||
| 45 | - <result property="htmlType" column="html_type" /> | ||
| 46 | - <result property="dictType" column="dict_type" /> | ||
| 47 | - <result property="sort" column="sort" /> | ||
| 48 | - <result property="createBy" column="create_by" /> | ||
| 49 | - <result property="createTime" column="create_time" /> | ||
| 50 | - <result property="updateBy" column="update_by" /> | ||
| 51 | - <result property="updateTime" column="update_time" /> | ||
| 52 | - </resultMap> | ||
| 53 | - | ||
| 54 | - <sql id="selectGenTableVo"> | ||
| 55 | - select table_id, table_name, table_comment, class_name, tpl_category, 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 | ||
| 56 | - </sql> | ||
| 57 | - | ||
| 58 | - <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> | ||
| 59 | - <include refid="selectGenTableVo"/> | ||
| 60 | - <where> | ||
| 61 | - <if test="tableName != null and tableName != ''"> | ||
| 62 | - AND lower(table_name) like lower(concat('%', #{tableName}, '%')) | ||
| 63 | - </if> | ||
| 64 | - <if test="tableComment != null and tableComment != ''"> | ||
| 65 | - AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) | ||
| 66 | - </if> | ||
| 67 | - <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> | ||
| 68 | - AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') | ||
| 69 | - </if> | ||
| 70 | - <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> | ||
| 71 | - AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') | ||
| 72 | - </if> | ||
| 73 | - </where> | ||
| 74 | - </select> | ||
| 75 | - | ||
| 76 | <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult"> | 7 | <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| 77 | select table_name, table_comment, create_time, update_time from information_schema.tables | 8 | select table_name, table_comment, create_time, update_time from information_schema.tables |
| 78 | where table_schema = (select database()) | 9 | where table_schema = (select database()) |
| @@ -91,22 +22,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -91,22 +22,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 91 | AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') | 22 | AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') |
| 92 | </if> | 23 | </if> |
| 93 | </select> | 24 | </select> |
| 94 | - | 25 | + |
| 95 | <select id="selectDbTableListByNames" resultMap="GenTableResult"> | 26 | <select id="selectDbTableListByNames" resultMap="GenTableResult"> |
| 96 | select table_name, table_comment, create_time, update_time from information_schema.tables | 27 | select table_name, table_comment, create_time, update_time from information_schema.tables |
| 97 | where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) | 28 | where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| 98 | and table_name in | 29 | and table_name in |
| 99 | <foreach collection="array" item="name" open="(" separator="," close=")"> | 30 | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| 100 | #{name} | 31 | #{name} |
| 101 | - </foreach> | 32 | + </foreach> |
| 102 | </select> | 33 | </select> |
| 103 | - | 34 | + |
| 104 | <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> | 35 | <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> |
| 105 | select table_name, table_comment, create_time, update_time from information_schema.tables | 36 | select table_name, table_comment, create_time, update_time from information_schema.tables |
| 106 | where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) | 37 | where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) |
| 107 | and table_name = #{tableName} | 38 | and table_name = #{tableName} |
| 108 | </select> | 39 | </select> |
| 109 | - | 40 | + |
| 110 | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> | 41 | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> |
| 111 | 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.gen_type, t.gen_path, t.options, t.remark, | 42 | 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.gen_type, t.gen_path, t.options, t.remark, |
| 112 | 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 | 43 | 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 |
| @@ -114,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -114,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 114 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id | 45 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| 115 | where t.table_id = #{tableId} order by c.sort | 46 | where t.table_id = #{tableId} order by c.sort |
| 116 | </select> | 47 | </select> |
| 117 | - | 48 | + |
| 118 | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> | 49 | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> |
| 119 | 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.gen_type, t.gen_path, t.options, t.remark, | 50 | 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.gen_type, t.gen_path, t.options, t.remark, |
| 120 | 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 | 51 | 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 |
| @@ -122,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -122,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 122 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id | 53 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| 123 | where t.table_name = #{tableName} order by c.sort | 54 | where t.table_name = #{tableName} order by c.sort |
| 124 | </select> | 55 | </select> |
| 125 | - | 56 | + |
| 126 | <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> | 57 | <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> |
| 127 | insert into gen_table ( | 58 | insert into gen_table ( |
| 128 | <if test="tableName != null">table_name,</if> | 59 | <if test="tableName != null">table_name,</if> |
| @@ -156,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -156,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 156 | sysdate() | 87 | sysdate() |
| 157 | ) | 88 | ) |
| 158 | </insert> | 89 | </insert> |
| 159 | - | 90 | + |
| 160 | <update id="updateGenTable" parameterType="GenTable"> | 91 | <update id="updateGenTable" parameterType="GenTable"> |
| 161 | update gen_table | 92 | update gen_table |
| 162 | <set> | 93 | <set> |
| @@ -178,12 +109,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -178,12 +109,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 178 | </set> | 109 | </set> |
| 179 | where table_id = #{tableId} | 110 | where table_id = #{tableId} |
| 180 | </update> | 111 | </update> |
| 181 | - | 112 | + |
| 182 | <delete id="deleteGenTableByIds" parameterType="Long"> | 113 | <delete id="deleteGenTableByIds" parameterType="Long"> |
| 183 | - delete from gen_table where table_id in | 114 | + delete from gen_table where table_id in |
| 184 | <foreach collection="array" item="tableId" open="(" separator="," close=")"> | 115 | <foreach collection="array" item="tableId" open="(" separator="," close=")"> |
| 185 | #{tableId} | 116 | #{tableId} |
| 186 | </foreach> | 117 | </foreach> |
| 187 | </delete> | 118 | </delete> |
| 188 | 119 | ||
| 189 | -</mapper> | ||
| 190 | \ No newline at end of file | 120 | \ No newline at end of file |
| 121 | +</mapper> |
ruoyi-ui/src/api/tool/codegen.js
| 1 | import request from '@/utils/request' | 1 | import request from '@/utils/request' |
| 2 | 2 | ||
| 3 | +// 获得表定义分页 | ||
| 4 | +export function getCodeGenTablePage(query) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/tool/codegen/page', | ||
| 7 | + method: 'get', | ||
| 8 | + params: query | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 获得表和字段的明细 | ||
| 13 | +export function getCodeGenDetail(tableId) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/tool/codegen/detail?tableId=' + tableId, | ||
| 16 | + method: 'get', | ||
| 17 | + }) | ||
| 18 | +} |
ruoyi-ui/src/api/tool/gen.js
| 1 | import request from '@/utils/request' | 1 | import request from '@/utils/request' |
| 2 | 2 | ||
| 3 | -// 查询生成表数据 | ||
| 4 | -export function listTable(query) { | ||
| 5 | - return request({ | ||
| 6 | - url: '/tool/gen/list', | ||
| 7 | - method: 'get', | ||
| 8 | - params: query | ||
| 9 | - }) | ||
| 10 | -} | ||
| 11 | // 查询db数据库列表 | 3 | // 查询db数据库列表 |
| 12 | export function listDbTable(query) { | 4 | export function listDbTable(query) { |
| 13 | return request({ | 5 | return request({ |
ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
| @@ -18,8 +18,8 @@ | @@ -18,8 +18,8 @@ | ||
| 18 | </el-form-item> | 18 | </el-form-item> |
| 19 | </el-col> | 19 | </el-col> |
| 20 | <el-col :span="12"> | 20 | <el-col :span="12"> |
| 21 | - <el-form-item label="作者" prop="functionAuthor"> | ||
| 22 | - <el-input placeholder="请输入" v-model="info.functionAuthor" /> | 21 | + <el-form-item label="作者" prop="author"> |
| 22 | + <el-input placeholder="请输入" v-model="info.author" /> | ||
| 23 | </el-form-item> | 23 | </el-form-item> |
| 24 | </el-col> | 24 | </el-col> |
| 25 | <el-col :span="24"> | 25 | <el-col :span="24"> |
| @@ -51,7 +51,7 @@ export default { | @@ -51,7 +51,7 @@ export default { | ||
| 51 | className: [ | 51 | className: [ |
| 52 | { required: true, message: "请输入实体类名称", trigger: "blur" } | 52 | { required: true, message: "请输入实体类名称", trigger: "blur" } |
| 53 | ], | 53 | ], |
| 54 | - functionAuthor: [ | 54 | + author: [ |
| 55 | { required: true, message: "请输入作者", trigger: "blur" } | 55 | { required: true, message: "请输入作者", trigger: "blur" } |
| 56 | ] | 56 | ] |
| 57 | } | 57 | } |
ruoyi-ui/src/views/tool/gen/editTable.vue
| @@ -2,11 +2,10 @@ | @@ -2,11 +2,10 @@ | ||
| 2 | <el-card> | 2 | <el-card> |
| 3 | <el-tabs v-model="activeName"> | 3 | <el-tabs v-model="activeName"> |
| 4 | <el-tab-pane label="基本信息" name="basic"> | 4 | <el-tab-pane label="基本信息" name="basic"> |
| 5 | - <basic-info-form ref="basicInfo" :info="info" /> | 5 | + <basic-info-form ref="basicInfo" :info="table" /> |
| 6 | </el-tab-pane> | 6 | </el-tab-pane> |
| 7 | <el-tab-pane label="字段信息" name="cloum"> | 7 | <el-tab-pane label="字段信息" name="cloum"> |
| 8 | - <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> | ||
| 9 | - <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" /> | 8 | + <el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight"> |
| 10 | <el-table-column | 9 | <el-table-column |
| 11 | label="字段列名" | 10 | label="字段列名" |
| 12 | prop="columnName" | 11 | prop="columnName" |
| @@ -41,44 +40,43 @@ | @@ -41,44 +40,43 @@ | ||
| 41 | <el-input v-model="scope.row.javaField"></el-input> | 40 | <el-input v-model="scope.row.javaField"></el-input> |
| 42 | </template> | 41 | </template> |
| 43 | </el-table-column> | 42 | </el-table-column> |
| 44 | - | ||
| 45 | - <el-table-column label="插入" min-width="5%"> | 43 | + <el-table-column label="插入" min-width="4%"> |
| 46 | <template slot-scope="scope"> | 44 | <template slot-scope="scope"> |
| 47 | - <el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox> | 45 | + <el-checkbox true-label="true" false-label="false" v-model="scope.row.createOperation"></el-checkbox> |
| 48 | </template> | 46 | </template> |
| 49 | </el-table-column> | 47 | </el-table-column> |
| 50 | - <el-table-column label="编辑" min-width="5%"> | 48 | + <el-table-column label="编辑" min-width="4%"> |
| 51 | <template slot-scope="scope"> | 49 | <template slot-scope="scope"> |
| 52 | - <el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox> | 50 | + <el-checkbox true-label="true" false-label="false" v-model="scope.row.updateOperation"></el-checkbox> |
| 53 | </template> | 51 | </template> |
| 54 | </el-table-column> | 52 | </el-table-column> |
| 55 | - <el-table-column label="列表" min-width="5%"> | 53 | + <el-table-column label="列表" min-width="4%"> |
| 56 | <template slot-scope="scope"> | 54 | <template slot-scope="scope"> |
| 57 | - <el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox> | 55 | + <el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperationResult"></el-checkbox> |
| 58 | </template> | 56 | </template> |
| 59 | </el-table-column> | 57 | </el-table-column> |
| 60 | - <el-table-column label="查询" min-width="5%"> | 58 | + <el-table-column label="查询" min-width="4%"> |
| 61 | <template slot-scope="scope"> | 59 | <template slot-scope="scope"> |
| 62 | - <el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox> | 60 | + <el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperation"></el-checkbox> |
| 63 | </template> | 61 | </template> |
| 64 | </el-table-column> | 62 | </el-table-column> |
| 65 | <el-table-column label="查询方式" min-width="10%"> | 63 | <el-table-column label="查询方式" min-width="10%"> |
| 66 | <template slot-scope="scope"> | 64 | <template slot-scope="scope"> |
| 67 | - <el-select v-model="scope.row.queryType"> | ||
| 68 | - <el-option label="=" value="EQ" /> | ||
| 69 | - <el-option label="!=" value="NE" /> | ||
| 70 | - <el-option label=">" value="GT" /> | ||
| 71 | - <el-option label=">=" value="GTE" /> | ||
| 72 | - <el-option label="<" value="LT" /> | ||
| 73 | - <el-option label="<=" value="LTE" /> | 65 | + <el-select v-model="scope.row.listOperationCondition"> |
| 66 | + <el-option label="=" value="=" /> | ||
| 67 | + <el-option label="!=" value="!=" /> | ||
| 68 | + <el-option label=">" value=">" /> | ||
| 69 | + <el-option label=">=" value=">=" /> | ||
| 70 | + <el-option label="<" value="<>" /> | ||
| 71 | + <el-option label="<=" value="<=" /> | ||
| 74 | <el-option label="LIKE" value="LIKE" /> | 72 | <el-option label="LIKE" value="LIKE" /> |
| 75 | <el-option label="BETWEEN" value="BETWEEN" /> | 73 | <el-option label="BETWEEN" value="BETWEEN" /> |
| 76 | </el-select> | 74 | </el-select> |
| 77 | </template> | 75 | </template> |
| 78 | </el-table-column> | 76 | </el-table-column> |
| 79 | - <el-table-column label="必填" min-width="5%"> | 77 | + <el-table-column label="允许空" min-width="5%"> |
| 80 | <template slot-scope="scope"> | 78 | <template slot-scope="scope"> |
| 81 | - <el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox> | 79 | + <el-checkbox true-label="true" false-label="false" v-model="scope.row.nullable"></el-checkbox> |
| 82 | </template> | 80 | </template> |
| 83 | </el-table-column> | 81 | </el-table-column> |
| 84 | <el-table-column label="显示类型" min-width="12%"> | 82 | <el-table-column label="显示类型" min-width="12%"> |
| @@ -110,10 +108,15 @@ | @@ -110,10 +108,15 @@ | ||
| 110 | </el-select> | 108 | </el-select> |
| 111 | </template> | 109 | </template> |
| 112 | </el-table-column> | 110 | </el-table-column> |
| 111 | + <el-table-column label="示例" min-width="10%"> | ||
| 112 | + <template slot-scope="scope"> | ||
| 113 | + <el-input v-model="scope.row.example"></el-input> | ||
| 114 | + </template> | ||
| 115 | + </el-table-column> | ||
| 113 | </el-table> | 116 | </el-table> |
| 114 | </el-tab-pane> | 117 | </el-tab-pane> |
| 115 | <el-tab-pane label="生成信息" name="genInfo"> | 118 | <el-tab-pane label="生成信息" name="genInfo"> |
| 116 | - <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/> | 119 | + <gen-info-form ref="genInfo" :info="table" :tables="tables" :menus="menus"/> |
| 117 | </el-tab-pane> | 120 | </el-tab-pane> |
| 118 | </el-tabs> | 121 | </el-tabs> |
| 119 | <el-form label-width="100px"> | 122 | <el-form label-width="100px"> |
| @@ -125,7 +128,8 @@ | @@ -125,7 +128,8 @@ | ||
| 125 | </el-card> | 128 | </el-card> |
| 126 | </template> | 129 | </template> |
| 127 | <script> | 130 | <script> |
| 128 | -import { getGenTable, updateGenTable } from "@/api/tool/gen"; | 131 | +import { updateGenTable } from "@/api/tool/gen"; |
| 132 | +import { getCodeGenDetail } from "@/api/tool/codegen"; | ||
| 129 | import { optionselect as getDictOptionselect } from "@/api/system/dict/type"; | 133 | import { optionselect as getDictOptionselect } from "@/api/system/dict/type"; |
| 130 | import { listMenu as getMenuTreeselect } from "@/api/system/menu"; | 134 | import { listMenu as getMenuTreeselect } from "@/api/system/menu"; |
| 131 | import basicInfoForm from "./basicInfoForm"; | 135 | import basicInfoForm from "./basicInfoForm"; |
| @@ -147,23 +151,22 @@ export default { | @@ -147,23 +151,22 @@ export default { | ||
| 147 | // 表信息 | 151 | // 表信息 |
| 148 | tables: [], | 152 | tables: [], |
| 149 | // 表列信息 | 153 | // 表列信息 |
| 150 | - cloumns: [], | 154 | + columns: [], |
| 151 | // 字典信息 | 155 | // 字典信息 |
| 152 | dictOptions: [], | 156 | dictOptions: [], |
| 153 | // 菜单信息 | 157 | // 菜单信息 |
| 154 | menus: [], | 158 | menus: [], |
| 155 | // 表详细信息 | 159 | // 表详细信息 |
| 156 | - info: {} | 160 | + table: {} |
| 157 | }; | 161 | }; |
| 158 | }, | 162 | }, |
| 159 | created() { | 163 | created() { |
| 160 | const tableId = this.$route.params && this.$route.params.tableId; | 164 | const tableId = this.$route.params && this.$route.params.tableId; |
| 161 | if (tableId) { | 165 | if (tableId) { |
| 162 | // 获取表详细信息 | 166 | // 获取表详细信息 |
| 163 | - getGenTable(tableId).then(res => { | ||
| 164 | - this.cloumns = res.data.rows; | ||
| 165 | - this.info = res.data.info; | ||
| 166 | - this.tables = res.data.tables; | 167 | + getCodeGenDetail(tableId).then(res => { |
| 168 | + this.table = res.data.table; | ||
| 169 | + this.columns = res.data.columns; | ||
| 167 | }); | 170 | }); |
| 168 | /** 查询字典下拉列表 */ | 171 | /** 查询字典下拉列表 */ |
| 169 | getDictOptionselect().then(response => { | 172 | getDictOptionselect().then(response => { |
| @@ -184,7 +187,7 @@ export default { | @@ -184,7 +187,7 @@ export default { | ||
| 184 | const validateResult = res.every(item => !!item); | 187 | const validateResult = res.every(item => !!item); |
| 185 | if (validateResult) { | 188 | if (validateResult) { |
| 186 | const genTable = Object.assign({}, basicForm.model, genForm.model); | 189 | const genTable = Object.assign({}, basicForm.model, genForm.model); |
| 187 | - genTable.columns = this.cloumns; | 190 | + genTable.columns = this.columns; |
| 188 | genTable.params = { | 191 | genTable.params = { |
| 189 | treeCode: genTable.treeCode, | 192 | treeCode: genTable.treeCode, |
| 190 | treeName: genTable.treeName, | 193 | treeName: genTable.treeName, |
| @@ -220,10 +223,10 @@ export default { | @@ -220,10 +223,10 @@ export default { | ||
| 220 | const sortable = Sortable.create(el, { | 223 | const sortable = Sortable.create(el, { |
| 221 | handle: ".allowDrag", | 224 | handle: ".allowDrag", |
| 222 | onEnd: evt => { | 225 | onEnd: evt => { |
| 223 | - const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; | ||
| 224 | - this.cloumns.splice(evt.newIndex, 0, targetRow); | ||
| 225 | - for (let index in this.cloumns) { | ||
| 226 | - this.cloumns[index].sort = parseInt(index) + 1; | 226 | + const targetRow = this.columns.splice(evt.oldIndex, 1)[0]; |
| 227 | + this.columns.splice(evt.newIndex, 0, targetRow); | ||
| 228 | + for (let index in this.columns) { | ||
| 229 | + this.columns[index].sort = parseInt(index) + 1; | ||
| 227 | } | 230 | } |
| 228 | } | 231 | } |
| 229 | }); | 232 | }); |
ruoyi-ui/src/views/tool/gen/index.vue
| @@ -64,7 +64,6 @@ | @@ -64,7 +64,6 @@ | ||
| 64 | plain | 64 | plain |
| 65 | icon="el-icon-edit" | 65 | icon="el-icon-edit" |
| 66 | size="mini" | 66 | size="mini" |
| 67 | - :disabled="single" | ||
| 68 | @click="handleEditTable" | 67 | @click="handleEditTable" |
| 69 | v-hasPermi="['tool:gen:edit']" | 68 | v-hasPermi="['tool:gen:edit']" |
| 70 | >修改</el-button> | 69 | >修改</el-button> |
| @@ -75,7 +74,6 @@ | @@ -75,7 +74,6 @@ | ||
| 75 | plain | 74 | plain |
| 76 | icon="el-icon-delete" | 75 | icon="el-icon-delete" |
| 77 | size="mini" | 76 | size="mini" |
| 78 | - :disabled="multiple" | ||
| 79 | @click="handleDelete" | 77 | @click="handleDelete" |
| 80 | v-hasPermi="['tool:gen:remove']" | 78 | v-hasPermi="['tool:gen:remove']" |
| 81 | >删除</el-button> | 79 | >删除</el-button> |
| @@ -83,13 +81,7 @@ | @@ -83,13 +81,7 @@ | ||
| 83 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | 81 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 84 | </el-row> | 82 | </el-row> |
| 85 | 83 | ||
| 86 | - <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> | ||
| 87 | - <el-table-column type="selection" align="center" width="55"></el-table-column> | ||
| 88 | - <el-table-column label="序号" type="index" width="50" align="center"> | ||
| 89 | - <template slot-scope="scope"> | ||
| 90 | - <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> | ||
| 91 | - </template> | ||
| 92 | - </el-table-column> | 84 | + <el-table v-loading="loading" :data="tableList"> |
| 93 | <el-table-column | 85 | <el-table-column |
| 94 | label="表名称" | 86 | label="表名称" |
| 95 | align="center" | 87 | align="center" |
| @@ -111,8 +103,16 @@ | @@ -111,8 +103,16 @@ | ||
| 111 | :show-overflow-tooltip="true" | 103 | :show-overflow-tooltip="true" |
| 112 | width="120" | 104 | width="120" |
| 113 | /> | 105 | /> |
| 114 | - <el-table-column label="创建时间" align="center" prop="createTime" width="160" /> | ||
| 115 | - <el-table-column label="更新时间" align="center" prop="updateTime" width="160" /> | 106 | + <el-table-column label="创建时间" align="center" prop="createTime" width="160"> |
| 107 | + <template slot-scope="scope"> | ||
| 108 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 109 | + </template> | ||
| 110 | + </el-table-column> | ||
| 111 | + <el-table-column label="创建时间" align="center" prop="createTime" width="160"> | ||
| 112 | + <template slot-scope="scope"> | ||
| 113 | + <span>{{ parseTime(scope.row.updateTime) }}</span> | ||
| 114 | + </template> | ||
| 115 | + </el-table-column> | ||
| 116 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 116 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 117 | <template slot-scope="scope"> | 117 | <template slot-scope="scope"> |
| 118 | <el-button | 118 | <el-button |
| @@ -156,7 +156,7 @@ | @@ -156,7 +156,7 @@ | ||
| 156 | <pagination | 156 | <pagination |
| 157 | v-show="total>0" | 157 | v-show="total>0" |
| 158 | :total="total" | 158 | :total="total" |
| 159 | - :page.sync="queryParams.pageNum" | 159 | + :page.sync="queryParams.pageNo" |
| 160 | :limit.sync="queryParams.pageSize" | 160 | :limit.sync="queryParams.pageSize" |
| 161 | @pagination="getList" | 161 | @pagination="getList" |
| 162 | /> | 162 | /> |
| @@ -178,12 +178,15 @@ | @@ -178,12 +178,15 @@ | ||
| 178 | </template> | 178 | </template> |
| 179 | 179 | ||
| 180 | <script> | 180 | <script> |
| 181 | -import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; | 181 | +import { previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; |
| 182 | +import { getCodeGenTablePage } from "@/api/tool/codegen"; | ||
| 183 | + | ||
| 182 | import importTable from "./importTable"; | 184 | import importTable from "./importTable"; |
| 183 | import { downLoadZip } from "@/utils/zipdownload"; | 185 | import { downLoadZip } from "@/utils/zipdownload"; |
| 184 | // 代码高亮插件 | 186 | // 代码高亮插件 |
| 185 | import hljs from "highlight.js/lib/highlight"; | 187 | import hljs from "highlight.js/lib/highlight"; |
| 186 | import "highlight.js/styles/github-gist.css"; | 188 | import "highlight.js/styles/github-gist.css"; |
| 189 | +import {list} from "@/api/system/loginlog"; | ||
| 187 | hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); | 190 | hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); |
| 188 | hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml")); | 191 | hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml")); |
| 189 | hljs.registerLanguage("html", require("highlight.js/lib/languages/xml")); | 192 | hljs.registerLanguage("html", require("highlight.js/lib/languages/xml")); |
| @@ -200,14 +203,8 @@ export default { | @@ -200,14 +203,8 @@ export default { | ||
| 200 | loading: true, | 203 | loading: true, |
| 201 | // 唯一标识符 | 204 | // 唯一标识符 |
| 202 | uniqueId: "", | 205 | uniqueId: "", |
| 203 | - // 选中数组 | ||
| 204 | - ids: [], | ||
| 205 | // 选中表数组 | 206 | // 选中表数组 |
| 206 | tableNames: [], | 207 | tableNames: [], |
| 207 | - // 非单个禁用 | ||
| 208 | - single: true, | ||
| 209 | - // 非多个禁用 | ||
| 210 | - multiple: true, | ||
| 211 | // 显示搜索条件 | 208 | // 显示搜索条件 |
| 212 | showSearch: true, | 209 | showSearch: true, |
| 213 | // 总条数 | 210 | // 总条数 |
| @@ -218,7 +215,7 @@ export default { | @@ -218,7 +215,7 @@ export default { | ||
| 218 | dateRange: "", | 215 | dateRange: "", |
| 219 | // 查询参数 | 216 | // 查询参数 |
| 220 | queryParams: { | 217 | queryParams: { |
| 221 | - pageNum: 1, | 218 | + pageNo: 1, |
| 222 | pageSize: 10, | 219 | pageSize: 10, |
| 223 | tableName: undefined, | 220 | tableName: undefined, |
| 224 | tableComment: undefined | 221 | tableComment: undefined |
| @@ -237,7 +234,7 @@ export default { | @@ -237,7 +234,7 @@ export default { | ||
| 237 | }, | 234 | }, |
| 238 | activated() { | 235 | activated() { |
| 239 | const time = this.$route.query.t; | 236 | const time = this.$route.query.t; |
| 240 | - if (time != null && time != this.uniqueId) { | 237 | + if (time != null && time !== this.uniqueId) { |
| 241 | this.uniqueId = time; | 238 | this.uniqueId = time; |
| 242 | this.resetQuery(); | 239 | this.resetQuery(); |
| 243 | } | 240 | } |
| @@ -246,22 +243,25 @@ export default { | @@ -246,22 +243,25 @@ export default { | ||
| 246 | /** 查询表集合 */ | 243 | /** 查询表集合 */ |
| 247 | getList() { | 244 | getList() { |
| 248 | this.loading = true; | 245 | this.loading = true; |
| 249 | - listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 250 | - this.tableList = response.rows; | ||
| 251 | - this.total = response.total; | ||
| 252 | - this.loading = false; | ||
| 253 | - } | 246 | + getCodeGenTablePage(this.addDateRange(this.queryParams, [ |
| 247 | + this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined, | ||
| 248 | + this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined, | ||
| 249 | + ], 'CreateTime')).then(response => { | ||
| 250 | + this.tableList = response.data.list; | ||
| 251 | + this.total = response.data.total; | ||
| 252 | + this.loading = false; | ||
| 253 | + } | ||
| 254 | ); | 254 | ); |
| 255 | }, | 255 | }, |
| 256 | /** 搜索按钮操作 */ | 256 | /** 搜索按钮操作 */ |
| 257 | handleQuery() { | 257 | handleQuery() { |
| 258 | - this.queryParams.pageNum = 1; | 258 | + this.queryParams.pageNo = 1; |
| 259 | this.getList(); | 259 | this.getList(); |
| 260 | }, | 260 | }, |
| 261 | /** 生成代码操作 */ | 261 | /** 生成代码操作 */ |
| 262 | handleGenTable(row) { | 262 | handleGenTable(row) { |
| 263 | const tableNames = row.tableName || this.tableNames; | 263 | const tableNames = row.tableName || this.tableNames; |
| 264 | - if (tableNames == "") { | 264 | + if (tableNames === "") { |
| 265 | this.msgError("请选择要生成的数据"); | 265 | this.msgError("请选择要生成的数据"); |
| 266 | return; | 266 | return; |
| 267 | } | 267 | } |
| @@ -310,16 +310,9 @@ export default { | @@ -310,16 +310,9 @@ export default { | ||
| 310 | const result = hljs.highlight(language, code || "", true); | 310 | const result = hljs.highlight(language, code || "", true); |
| 311 | return result.value || ' '; | 311 | return result.value || ' '; |
| 312 | }, | 312 | }, |
| 313 | - // 多选框选中数据 | ||
| 314 | - handleSelectionChange(selection) { | ||
| 315 | - this.ids = selection.map(item => item.tableId); | ||
| 316 | - this.tableNames = selection.map(item => item.tableName); | ||
| 317 | - this.single = selection.length != 1; | ||
| 318 | - this.multiple = !selection.length; | ||
| 319 | - }, | ||
| 320 | /** 修改按钮操作 */ | 313 | /** 修改按钮操作 */ |
| 321 | handleEditTable(row) { | 314 | handleEditTable(row) { |
| 322 | - const tableId = row.tableId || this.ids[0]; | 315 | + const tableId = row.id; |
| 323 | this.$router.push("/gen/edit/" + tableId); | 316 | this.$router.push("/gen/edit/" + tableId); |
| 324 | }, | 317 | }, |
| 325 | /** 删除按钮操作 */ | 318 | /** 删除按钮操作 */ |
src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigPageReqVO.java
| @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; | @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; | ||
| 5 | import io.swagger.annotations.ApiModelProperty; | 5 | import io.swagger.annotations.ApiModelProperty; |
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | import lombok.EqualsAndHashCode; | 7 | import lombok.EqualsAndHashCode; |
| 8 | +import lombok.ToString; | ||
| 8 | import org.springframework.format.annotation.DateTimeFormat; | 9 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | 10 | ||
| 10 | import java.util.Date; | 11 | import java.util.Date; |
| @@ -14,6 +15,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU | @@ -14,6 +15,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU | ||
| 14 | @ApiModel("参数配置分页 Request VO") | 15 | @ApiModel("参数配置分页 Request VO") |
| 15 | @Data | 16 | @Data |
| 16 | @EqualsAndHashCode(callSuper = true) | 17 | @EqualsAndHashCode(callSuper = true) |
| 18 | +@ToString(callSuper = true) | ||
| 17 | public class InfConfigPageReqVO extends PageParam { | 19 | public class InfConfigPageReqVO extends PageParam { |
| 18 | 20 | ||
| 19 | @ApiModelProperty(value = "参数名称", example = "模糊匹配") | 21 | @ApiModelProperty(value = "参数名称", example = "模糊匹配") |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/ToolCodeGenController.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.controller.codegen; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.dashboard.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodeGenTablePageItemRespVO; | ||
| 6 | -import cn.iocoder.dashboard.modules.tool.service.codegen.ToolCodegenService; | ||
| 7 | -import io.swagger.annotations.ApiOperation; | ||
| 8 | -import org.springframework.web.bind.annotation.*; | ||
| 9 | - | ||
| 10 | -import javax.annotation.Resource; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | ||
| 13 | - | ||
| 14 | -@RestController | ||
| 15 | -@RequestMapping("/tool/codegen") | ||
| 16 | -public class ToolCodeGenController { | ||
| 17 | - | ||
| 18 | - @Resource | ||
| 19 | - private ToolCodegenService codegenService; | ||
| 20 | - | ||
| 21 | - @GetMapping("/table/page") | ||
| 22 | - public CommonResult<PageResult<ToolCodeGenTablePageItemRespVO>> getCodeGenTablePage() { | ||
| 23 | - return success(null); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - @ApiOperation("基于数据库的表结构,创建代码生成器的表定义") | ||
| 27 | - @PostMapping("/table/create") | ||
| 28 | - // TODO 权限 | ||
| 29 | - public CommonResult<Long> createCodeGenTable(@RequestParam("tableName") String tableName) { | ||
| 30 | - return success(codegenService.createCodegenTable(tableName)); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | -} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/ToolCodegenController.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenDetailRespVO; | ||
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTablePageReqVO; | ||
| 7 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTableRespVO; | ||
| 8 | +import cn.iocoder.dashboard.modules.tool.convert.codegen.ToolCodegenConvert; | ||
| 9 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; | ||
| 10 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; | ||
| 11 | +import cn.iocoder.dashboard.modules.tool.service.codegen.ToolCodegenService; | ||
| 12 | +import io.swagger.annotations.Api; | ||
| 13 | +import io.swagger.annotations.ApiOperation; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | +import org.springframework.web.bind.annotation.*; | ||
| 16 | + | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import javax.validation.Valid; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 23 | +@Api(tags = "代码生成器 API") | ||
| 24 | +@RestController | ||
| 25 | +@RequestMapping("/tool/codegen") | ||
| 26 | +@Validated | ||
| 27 | +public class ToolCodegenController { | ||
| 28 | + | ||
| 29 | + @Resource | ||
| 30 | + private ToolCodegenService codegenService; | ||
| 31 | + | ||
| 32 | + @ApiOperation("获得表定义分页") | ||
| 33 | + @GetMapping("/page") | ||
| 34 | + // TODO 权限 @PreAuthorize("@ss.hasPermi('tool:gen:list')") | ||
| 35 | + public CommonResult<PageResult<ToolCodegenTableRespVO>> getCodeGenTablePage(@Valid ToolCodegenTablePageReqVO pageReqVO) { | ||
| 36 | + PageResult<ToolCodegenTableDO> pageResult = codegenService.getCodeGenTablePage(pageReqVO); | ||
| 37 | + return success(ToolCodegenConvert.INSTANCE.convertPage(pageResult)); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @ApiOperation("获得表和字段的明细") | ||
| 41 | + @GetMapping("/detail") | ||
| 42 | +// todo @PreAuthorize("@ss.hasPermi('tool:gen:query')") | ||
| 43 | + public CommonResult<ToolCodegenDetailRespVO> getCodeGenDetail(@RequestParam("tableId") Long tableId) { | ||
| 44 | + ToolCodegenTableDO table = codegenService.getCodeGenTablePage(tableId); | ||
| 45 | + List<ToolCodegenColumnDO> columns = codegenService.getCodegenColumnListByTableId(tableId); | ||
| 46 | + // 拼装返回 | ||
| 47 | + return success(ToolCodegenConvert.INSTANCE.convert(table, columns)); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @ApiOperation("基于数据库的表结构,创建代码生成器的表定义") | ||
| 51 | + @PostMapping("/create") | ||
| 52 | + // TODO 权限 | ||
| 53 | + public CommonResult<Long> createCodeGenTable(@RequestParam("tableName") String tableName) { | ||
| 54 | + return success(codegenService.createCodegenTable(tableName)); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodeGenTableBaseRespVO.java deleted
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodeGenTablePageItemRespVO.java deleted
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenColumnBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModelProperty; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | +* 代码生成字段定义 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | +*/ | ||
| 12 | +@Data | ||
| 13 | +public class ToolCodegenColumnBaseVO { | ||
| 14 | + | ||
| 15 | + @ApiModelProperty(value = "表编号", required = true, example = "1") | ||
| 16 | + @NotNull(message = "表编号不能为空") | ||
| 17 | + private Long tableId; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "字段名", required = true, example = "user_age") | ||
| 20 | + @NotNull(message = "字段名不能为空") | ||
| 21 | + private String columnName; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "字段类型", required = true, example = "int(11)") | ||
| 24 | + @NotNull(message = "字段类型不能为空") | ||
| 25 | + private String columnType; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "字段描述", required = true, example = "年龄") | ||
| 28 | + @NotNull(message = "字段描述不能为空") | ||
| 29 | + private String columnComment; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "是否允许为空", required = true, example = "true") | ||
| 32 | + @NotNull(message = "是否允许为空不能为空") | ||
| 33 | + private Boolean nullable; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "是否主键", required = true, example = "false") | ||
| 36 | + @NotNull(message = "是否主键不能为空") | ||
| 37 | + private Boolean primaryKey; | ||
| 38 | + | ||
| 39 | + @ApiModelProperty(value = "是否自增", required = true, example = "true") | ||
| 40 | + @NotNull(message = "是否自增不能为空") | ||
| 41 | + private String autoIncrement; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty(value = "排序", required = true, example = "10") | ||
| 44 | + @NotNull(message = "排序不能为空") | ||
| 45 | + private Integer ordinalPosition; | ||
| 46 | + | ||
| 47 | + @ApiModelProperty(value = "Java 属性类型", required = true, example = "userAge") | ||
| 48 | + @NotNull(message = "Java 属性类型不能为空") | ||
| 49 | + private String javaType; | ||
| 50 | + | ||
| 51 | + @ApiModelProperty(value = "Java 属性名", required = true, example = "Integer") | ||
| 52 | + @NotNull(message = "Java 属性名不能为空") | ||
| 53 | + private String javaField; | ||
| 54 | + | ||
| 55 | + @ApiModelProperty(value = "字典类型", example = "sys_gender") | ||
| 56 | + private String dictType; | ||
| 57 | + | ||
| 58 | + @ApiModelProperty(value = "数据示例", example = "1024") | ||
| 59 | + private String example; | ||
| 60 | + | ||
| 61 | + @ApiModelProperty(value = "是否为 Create 创建操作的字段", required = true, example = "true") | ||
| 62 | + @NotNull(message = "是否为 Create 创建操作的字段不能为空") | ||
| 63 | + private Boolean createOperation; | ||
| 64 | + | ||
| 65 | + @ApiModelProperty(value = "是否为 Update 更新操作的字段", required = true, example = "false") | ||
| 66 | + @NotNull(message = "是否为 Update 更新操作的字段不能为空") | ||
| 67 | + private Boolean updateOperation; | ||
| 68 | + | ||
| 69 | + @ApiModelProperty(value = "是否为 List 查询操作的字段", required = true, example = "true") | ||
| 70 | + @NotNull(message = "是否为 List 查询操作的字段不能为空") | ||
| 71 | + private Boolean listOperation; | ||
| 72 | + | ||
| 73 | + @ApiModelProperty(value = "List 查询操作的条件类型", required = true, example = "LIKE", notes = "参见 ToolCodegenColumnListConditionEnum 枚举") | ||
| 74 | + @NotNull(message = "List 查询操作的条件类型不能为空") | ||
| 75 | + private String listOperationCondition; | ||
| 76 | + | ||
| 77 | + @ApiModelProperty(value = "是否为 List 查询操作的返回字段", required = true, example = "true") | ||
| 78 | + @NotNull(message = "是否为 List 查询操作的返回字段不能为空") | ||
| 79 | + private Boolean listOperationResult; | ||
| 80 | + | ||
| 81 | + @ApiModelProperty(value = "显示类型", required = true, example = "input") | ||
| 82 | + @NotNull(message = "显示类型不能为空") | ||
| 83 | + private String htmlType; | ||
| 84 | + | ||
| 85 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenColumnRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import java.util.Date; | ||
| 10 | + | ||
| 11 | +@ApiModel("代码生成字段定义 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class ToolCodegenColumnRespVO extends ToolCodegenColumnBaseVO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "编号", required = true, example = "1") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 21 | + private Date createTime; | ||
| 22 | + | ||
| 23 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenDetailRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +@ApiModel("代码生成表和字段的明细 Response VO") | ||
| 10 | +@Data | ||
| 11 | +public class ToolCodegenDetailRespVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty("表定义") | ||
| 14 | + private ToolCodegenTableRespVO table; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("字段定义") | ||
| 17 | + private List<ToolCodegenColumnRespVO> columns; | ||
| 18 | + | ||
| 19 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenTableBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModelProperty; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | +* 代码生成 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | +*/ | ||
| 12 | +@Data | ||
| 13 | +public class ToolCodegenTableBaseVO { | ||
| 14 | + | ||
| 15 | + @ApiModelProperty(value = "表名称", required = true, example = "yudao") | ||
| 16 | + @NotNull(message = "表名称不能为空") | ||
| 17 | + private String tableName; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "表描述", required = true, example = "芋道") | ||
| 20 | + @NotNull(message = "表描述不能为空") | ||
| 21 | + private String tableComment; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "备注", example = "我是备注") | ||
| 24 | + private String remark; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty(value = "模块名", required = true, example = "system") | ||
| 27 | + @NotNull(message = "模块名不能为空") | ||
| 28 | + private String moduleName; | ||
| 29 | + | ||
| 30 | + @ApiModelProperty(value = "业务名", required = true, example = "codegen") | ||
| 31 | + @NotNull(message = "业务名不能为空") | ||
| 32 | + private String businessName; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable") | ||
| 35 | + @NotNull(message = "类名称不能为空") | ||
| 36 | + private String className; | ||
| 37 | + | ||
| 38 | + @ApiModelProperty(value = "类描述", required = true, example = "代码生成器的表定义") | ||
| 39 | + @NotNull(message = "类描述不能为空") | ||
| 40 | + private String classComment; | ||
| 41 | + | ||
| 42 | + @ApiModelProperty(value = "作者", required = true, example = "芋道源码") | ||
| 43 | + @NotNull(message = "作者不能为空") | ||
| 44 | + private String author; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty(value = "模板类型", required = true, example = "1", notes = "参见 ToolCodegenTemplateTypeEnum 枚举") | ||
| 47 | + @NotNull(message = "模板类型不能为空") | ||
| 48 | + private Integer templateType; | ||
| 49 | + | ||
| 50 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenTablePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageParam; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import lombok.EqualsAndHashCode; | ||
| 8 | +import lombok.ToString; | ||
| 9 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | + | ||
| 11 | +import java.util.Date; | ||
| 12 | + | ||
| 13 | +import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 14 | + | ||
| 15 | +@ApiModel("表定义分页 Request VO") | ||
| 16 | +@Data | ||
| 17 | +@EqualsAndHashCode(callSuper = true) | ||
| 18 | +@ToString(callSuper = true) | ||
| 19 | +public class ToolCodegenTablePageReqVO extends PageParam { | ||
| 20 | + | ||
| 21 | + @ApiModelProperty(value = "表名称", example = "yudao", notes = "模糊匹配") | ||
| 22 | + private String tableName; | ||
| 23 | + | ||
| 24 | + @ApiModelProperty(value = "表描述", example = "芋道", notes = "模糊匹配") | ||
| 25 | + private String tableComment; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "开始创建时间", example = "2020-10-24 00:00:00") | ||
| 28 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | + private Date beginCreateTime; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "结束创建时间", example = "2020-10-24 23:59:59") | ||
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 33 | + private Date endCreateTime; | ||
| 34 | + | ||
| 35 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/ToolCodegenTableRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import java.util.Date; | ||
| 10 | + | ||
| 11 | +@ApiModel("代码生成表定义 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class ToolCodegenTableRespVO extends ToolCodegenTableBaseVO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "编号", required = true, example = "1") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 21 | + private Date createTime; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "更新时间", required = true) | ||
| 24 | + private Date updateTime; | ||
| 25 | + | ||
| 26 | +} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.controller.codegen.vo; |
src/main/java/cn/iocoder/dashboard/modules/tool/convert/codegen/CodegenConvert.java renamed to src/main/java/cn/iocoder/dashboard/modules/tool/convert/codegen/ToolCodegenConvert.java
| 1 | package cn.iocoder.dashboard.modules.tool.convert.codegen; | 1 | package cn.iocoder.dashboard.modules.tool.convert.codegen; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenColumnRespVO; | ||
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenDetailRespVO; | ||
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTableRespVO; | ||
| 3 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; | 7 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; |
| 4 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; | 8 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; |
| 5 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolInformationSchemaColumnDO; | 9 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolInformationSchemaColumnDO; |
| @@ -10,12 +14,37 @@ import org.mapstruct.factory.Mappers; | @@ -10,12 +14,37 @@ import org.mapstruct.factory.Mappers; | ||
| 10 | import java.util.List; | 14 | import java.util.List; |
| 11 | 15 | ||
| 12 | @Mapper | 16 | @Mapper |
| 13 | -public interface CodegenConvert { | 17 | +public interface ToolCodegenConvert { |
| 14 | 18 | ||
| 15 | - CodegenConvert INSTANCE = Mappers.getMapper(CodegenConvert.class); | 19 | + ToolCodegenConvert INSTANCE = Mappers.getMapper(ToolCodegenConvert.class); |
| 20 | + | ||
| 21 | + // ========== ToolInformationSchemaTableDO 和 ToolInformationSchemaColumnDO 相关 ========== | ||
| 16 | 22 | ||
| 17 | ToolCodegenTableDO convert(ToolInformationSchemaTableDO bean); | 23 | ToolCodegenTableDO convert(ToolInformationSchemaTableDO bean); |
| 18 | 24 | ||
| 19 | List<ToolCodegenColumnDO> convertList(List<ToolInformationSchemaColumnDO> list); | 25 | List<ToolCodegenColumnDO> convertList(List<ToolInformationSchemaColumnDO> list); |
| 20 | 26 | ||
| 27 | + ToolCodegenTableRespVO convert(ToolInformationSchemaColumnDO bean); | ||
| 28 | + | ||
| 29 | + // ========== ToolCodegenTableDO 相关 ========== | ||
| 30 | + | ||
| 31 | +// List<ToolCodegenTableRespVO> convertList02(List<ToolCodegenTableDO> list); | ||
| 32 | + | ||
| 33 | + ToolCodegenTableRespVO convert(ToolCodegenTableDO bean); | ||
| 34 | + | ||
| 35 | + PageResult<ToolCodegenTableRespVO> convertPage(PageResult<ToolCodegenTableDO> page); | ||
| 36 | + | ||
| 37 | + // ========== ToolCodegenTableDO 相关 ========== | ||
| 38 | + | ||
| 39 | + List<ToolCodegenColumnRespVO> convertList02(List<ToolCodegenColumnDO> list); | ||
| 40 | + | ||
| 41 | + // ========== 其它 ========== | ||
| 42 | + | ||
| 43 | + default ToolCodegenDetailRespVO convert(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) { | ||
| 44 | + ToolCodegenDetailRespVO respVO = new ToolCodegenDetailRespVO(); | ||
| 45 | + respVO.setTable(convert(table)); | ||
| 46 | + respVO.setColumns(convertList02(columns)); | ||
| 47 | + return respVO; | ||
| 48 | + } | ||
| 49 | + | ||
| 21 | } | 50 | } |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/dao/coegen/ToolCodegenColumnMapper.java
| @@ -10,7 +10,7 @@ import java.util.List; | @@ -10,7 +10,7 @@ import java.util.List; | ||
| 10 | @Mapper | 10 | @Mapper |
| 11 | public interface ToolCodegenColumnMapper extends BaseMapperX<ToolCodegenColumnDO> { | 11 | public interface ToolCodegenColumnMapper extends BaseMapperX<ToolCodegenColumnDO> { |
| 12 | 12 | ||
| 13 | - default List<ToolCodegenColumnDO> selectByTableId(Long tableId) { | 13 | + default List<ToolCodegenColumnDO> selectListByTableId(Long tableId) { |
| 14 | return selectList(new QueryWrapper<ToolCodegenColumnDO>() | 14 | return selectList(new QueryWrapper<ToolCodegenColumnDO>() |
| 15 | .eq("table_id", tableId) | 15 | .eq("table_id", tableId) |
| 16 | .orderByAsc("ordinal_position")); | 16 | .orderByAsc("ordinal_position")); |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/dao/coegen/ToolCodegenTableMapper.java
| 1 | package cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen; | 1 | package cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | ||
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTablePageReqVO; | ||
| 4 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; | 7 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; |
| 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| @@ -12,4 +15,11 @@ public interface ToolCodegenTableMapper extends BaseMapperX<ToolCodegenTableDO> | @@ -12,4 +15,11 @@ public interface ToolCodegenTableMapper extends BaseMapperX<ToolCodegenTableDO> | ||
| 12 | return selectOne(new QueryWrapper<ToolCodegenTableDO>().eq("table_name", tableName)); | 15 | return selectOne(new QueryWrapper<ToolCodegenTableDO>().eq("table_name", tableName)); |
| 13 | } | 16 | } |
| 14 | 17 | ||
| 18 | + default PageResult<ToolCodegenTableDO> selectPage(ToolCodegenTablePageReqVO pageReqVO) { | ||
| 19 | + return selectPage(pageReqVO, new QueryWrapperX<ToolCodegenTableDO>() | ||
| 20 | + .likeIfPresent("table_name", pageReqVO.getTableName()) | ||
| 21 | + .likeIfPresent("table_comment", pageReqVO.getTableComment()) | ||
| 22 | + .betweenIfPresent("create_time", pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime())); | ||
| 23 | + } | ||
| 24 | + | ||
| 15 | } | 25 | } |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/dataobject/codegen/ToolCodegenColumnDO.java
| @@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode; | @@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode; | ||
| 15 | * | 15 | * |
| 16 | * @author 芋道源码 | 16 | * @author 芋道源码 |
| 17 | */ | 17 | */ |
| 18 | -@TableName(value = "tool_codegen_table_column", autoResultMap = true) | 18 | +@TableName(value = "tool_codegen_column", autoResultMap = true) |
| 19 | @Data | 19 | @Data |
| 20 | @Builder | 20 | @Builder |
| 21 | @EqualsAndHashCode(callSuper = true) | 21 | @EqualsAndHashCode(callSuper = true) |
| @@ -60,7 +60,7 @@ public class ToolCodegenColumnDO extends BaseDO { | @@ -60,7 +60,7 @@ public class ToolCodegenColumnDO extends BaseDO { | ||
| 60 | */ | 60 | */ |
| 61 | private Boolean autoIncrement; | 61 | private Boolean autoIncrement; |
| 62 | /** | 62 | /** |
| 63 | - * 排序字段 | 63 | + * 排序 |
| 64 | */ | 64 | */ |
| 65 | private Integer ordinalPosition; | 65 | private Integer ordinalPosition; |
| 66 | 66 | ||
| @@ -122,5 +122,4 @@ public class ToolCodegenColumnDO extends BaseDO { | @@ -122,5 +122,4 @@ public class ToolCodegenColumnDO extends BaseDO { | ||
| 122 | */ | 122 | */ |
| 123 | private String htmlType; | 123 | private String htmlType; |
| 124 | 124 | ||
| 125 | - | ||
| 126 | } | 125 | } |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/dataobject/codegen/ToolCodegenTableDO.java
| @@ -28,12 +28,10 @@ public class ToolCodegenTableDO extends BaseDO { | @@ -28,12 +28,10 @@ public class ToolCodegenTableDO extends BaseDO { | ||
| 28 | /** | 28 | /** |
| 29 | * 表名称 | 29 | * 表名称 |
| 30 | */ | 30 | */ |
| 31 | -// @NotBlank(message = "表名称不能为空") | ||
| 32 | private String tableName; | 31 | private String tableName; |
| 33 | /** | 32 | /** |
| 34 | * 表描述 | 33 | * 表描述 |
| 35 | */ | 34 | */ |
| 36 | -// @NotBlank(message = "表描述不能为空") | ||
| 37 | private String tableComment; | 35 | private String tableComment; |
| 38 | /** | 36 | /** |
| 39 | * 备注 | 37 | * 备注 |
| @@ -47,31 +45,26 @@ public class ToolCodegenTableDO extends BaseDO { | @@ -47,31 +45,26 @@ public class ToolCodegenTableDO extends BaseDO { | ||
| 47 | * | 45 | * |
| 48 | * 例如说,infra、system、tool 等等 | 46 | * 例如说,infra、system、tool 等等 |
| 49 | */ | 47 | */ |
| 50 | -// @NotBlank(message = "模块名不能为空") | ||
| 51 | private String moduleName; | 48 | private String moduleName; |
| 52 | /** | 49 | /** |
| 53 | * 业务名,即二级目录 | 50 | * 业务名,即二级目录 |
| 54 | * | 51 | * |
| 55 | * 例如说,user、permission、dict 等等 | 52 | * 例如说,user、permission、dict 等等 |
| 56 | */ | 53 | */ |
| 57 | -// @NotBlank(message = "生成业务名不能为空") | ||
| 58 | private String businessName; | 54 | private String businessName; |
| 59 | /** | 55 | /** |
| 60 | * 类名称(首字母大写) | 56 | * 类名称(首字母大写) |
| 61 | * | 57 | * |
| 62 | * 例如说,SysUser、SysMenu、SysDictData 等等 | 58 | * 例如说,SysUser、SysMenu、SysDictData 等等 |
| 63 | */ | 59 | */ |
| 64 | -// @NotBlank(message = "实体类名称不能为空") | ||
| 65 | private String className; | 60 | private String className; |
| 66 | /** | 61 | /** |
| 67 | * 类描述 | 62 | * 类描述 |
| 68 | */ | 63 | */ |
| 69 | -// @NotBlank(message = "生成功能名不能为空") | ||
| 70 | private String classComment; | 64 | private String classComment; |
| 71 | /** | 65 | /** |
| 72 | * 作者 | 66 | * 作者 |
| 73 | */ | 67 | */ |
| 74 | -// @NotBlank(message = "作者不能为空") | ||
| 75 | private String author; | 68 | private String author; |
| 76 | 69 | ||
| 77 | // ========== 生成相关字段 ========== | 70 | // ========== 生成相关字段 ========== |
src/main/java/cn/iocoder/dashboard/modules/tool/enums/codegen/ToolCodegenTemplateTypeEnum.java
| @@ -14,7 +14,8 @@ public enum ToolCodegenTemplateTypeEnum { | @@ -14,7 +14,8 @@ public enum ToolCodegenTemplateTypeEnum { | ||
| 14 | 14 | ||
| 15 | CRUD(1), // 基础 CRUD | 15 | CRUD(1), // 基础 CRUD |
| 16 | TREE(2), // 树形 CRUD | 16 | TREE(2), // 树形 CRUD |
| 17 | - SUB(3) // 子表 CRUD | 17 | + // TODO 主子表,暂时不考虑支持。原因是较为灵活,形态较多,很难评估。 |
| 18 | + SUB(3) // 主子表 CRUD | ||
| 18 | ; | 19 | ; |
| 19 | 20 | ||
| 20 | /** | 21 | /** |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/ToolCodegenService.java
| 1 | package cn.iocoder.dashboard.modules.tool.service.codegen; | 1 | package cn.iocoder.dashboard.modules.tool.service.codegen; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTablePageReqVO; | ||
| 5 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; | ||
| 6 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 3 | /** | 10 | /** |
| 4 | * 代码生成 Service 接口 | 11 | * 代码生成 Service 接口 |
| 5 | * | 12 | * |
| @@ -15,4 +22,28 @@ public interface ToolCodegenService { | @@ -15,4 +22,28 @@ public interface ToolCodegenService { | ||
| 15 | */ | 22 | */ |
| 16 | Long createCodegenTable(String tableName); | 23 | Long createCodegenTable(String tableName); |
| 17 | 24 | ||
| 25 | + /** | ||
| 26 | + * 获得表定义分页 | ||
| 27 | + * | ||
| 28 | + * @param pageReqVO 分页条件 | ||
| 29 | + * @return 表定义分页 | ||
| 30 | + */ | ||
| 31 | + PageResult<ToolCodegenTableDO> getCodeGenTablePage(ToolCodegenTablePageReqVO pageReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 获得表定义 | ||
| 35 | + * | ||
| 36 | + * @param id 表编号 | ||
| 37 | + * @return 表定义 | ||
| 38 | + */ | ||
| 39 | + ToolCodegenTableDO getCodeGenTablePage(Long id); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 获得指定表的字段定义数组 | ||
| 43 | + * | ||
| 44 | + * @param tableId 表编号 | ||
| 45 | + * @return 字段定义数组 | ||
| 46 | + */ | ||
| 47 | + List<ToolCodegenColumnDO> getCodegenColumnListByTableId(Long tableId); | ||
| 48 | + | ||
| 18 | } | 49 | } |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenBuilder.java
| @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.tool.service.codegen.impl; | @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.tool.service.codegen.impl; | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | 5 | import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; |
| 6 | -import cn.iocoder.dashboard.modules.tool.convert.codegen.CodegenConvert; | 6 | +import cn.iocoder.dashboard.modules.tool.convert.codegen.ToolCodegenConvert; |
| 7 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; | 7 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO; |
| 8 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; | 8 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO; |
| 9 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolInformationSchemaColumnDO; | 9 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolInformationSchemaColumnDO; |
| @@ -113,7 +113,7 @@ public class ToolCodegenBuilder { | @@ -113,7 +113,7 @@ public class ToolCodegenBuilder { | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | public ToolCodegenTableDO buildTable(ToolInformationSchemaTableDO schemaTable) { | 115 | public ToolCodegenTableDO buildTable(ToolInformationSchemaTableDO schemaTable) { |
| 116 | - ToolCodegenTableDO table = CodegenConvert.INSTANCE.convert(schemaTable); | 116 | + ToolCodegenTableDO table = ToolCodegenConvert.INSTANCE.convert(schemaTable); |
| 117 | initTableDefault(table); | 117 | initTableDefault(table); |
| 118 | return table; | 118 | return table; |
| 119 | } | 119 | } |
| @@ -136,7 +136,7 @@ public class ToolCodegenBuilder { | @@ -136,7 +136,7 @@ public class ToolCodegenBuilder { | ||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | public List<ToolCodegenColumnDO> buildColumns(List<ToolInformationSchemaColumnDO> schemaColumns) { | 138 | public List<ToolCodegenColumnDO> buildColumns(List<ToolInformationSchemaColumnDO> schemaColumns) { |
| 139 | - List<ToolCodegenColumnDO> columns = CodegenConvert.INSTANCE.convertList(schemaColumns); | 139 | + List<ToolCodegenColumnDO> columns = ToolCodegenConvert.INSTANCE.convertList(schemaColumns); |
| 140 | columns.forEach(this::initColumnDefault); | 140 | columns.forEach(this::initColumnDefault); |
| 141 | return columns; | 141 | return columns; |
| 142 | } | 142 | } |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java
| @@ -95,12 +95,12 @@ public class ToolCodegenEngine { | @@ -95,12 +95,12 @@ public class ToolCodegenEngine { | ||
| 95 | // String result = templateEngine.getTemplate("codegen/controller/vo/baseVO.vm").render(bindingMap); | 95 | // String result = templateEngine.getTemplate("codegen/controller/vo/baseVO.vm").render(bindingMap); |
| 96 | // String result = templateEngine.getTemplate("codegen/controller/vo/createReqVO.vm").render(bindingMap); | 96 | // String result = templateEngine.getTemplate("codegen/controller/vo/createReqVO.vm").render(bindingMap); |
| 97 | // String result = templateEngine.getTemplate("codegen/controller/vo/updateReqVO.vm").render(bindingMap); | 97 | // String result = templateEngine.getTemplate("codegen/controller/vo/updateReqVO.vm").render(bindingMap); |
| 98 | -// String result = templateEngine.getTemplate("codegen/controller/vo/respVO.vm").render(bindingMap); | 98 | + String result = templateEngine.getTemplate("codegen/controller/vo/respVO.vm").render(bindingMap); |
| 99 | // String result = templateEngine.getTemplate("codegen/convert/convert.vm").render(bindingMap); | 99 | // String result = templateEngine.getTemplate("codegen/convert/convert.vm").render(bindingMap); |
| 100 | // String result = templateEngine.getTemplate("codegen/enums/errorcode.vm").render(bindingMap); | 100 | // String result = templateEngine.getTemplate("codegen/enums/errorcode.vm").render(bindingMap); |
| 101 | // String result = templateEngine.getTemplate("codegen/service/service.vm").render(bindingMap); | 101 | // String result = templateEngine.getTemplate("codegen/service/service.vm").render(bindingMap); |
| 102 | // String result = templateEngine.getTemplate("codegen/service/serviceImpl.vm").render(bindingMap); | 102 | // String result = templateEngine.getTemplate("codegen/service/serviceImpl.vm").render(bindingMap); |
| 103 | - String result = templateEngine.getTemplate("codegen/controller/controller.vm").render(bindingMap); | 103 | +// String result = templateEngine.getTemplate("codegen/controller/controller.vm").render(bindingMap); |
| 104 | System.out.println(result); | 104 | System.out.println(result); |
| 105 | } | 105 | } |
| 106 | 106 |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java
| 1 | package cn.iocoder.dashboard.modules.tool.service.codegen.impl; | 1 | package cn.iocoder.dashboard.modules.tool.service.codegen.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.codegen.vo.ToolCodegenTablePageReqVO; | ||
| 4 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolCodegenColumnMapper; | 6 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolCodegenColumnMapper; |
| 5 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolCodegenTableMapper; | 7 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolCodegenTableMapper; |
| 6 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolInformationSchemaColumnMapper; | 8 | import cn.iocoder.dashboard.modules.tool.dal.mysql.dao.coegen.ToolInformationSchemaColumnMapper; |
| @@ -67,4 +69,19 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { | @@ -67,4 +69,19 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { | ||
| 67 | return table.getId(); | 69 | return table.getId(); |
| 68 | } | 70 | } |
| 69 | 71 | ||
| 72 | + @Override | ||
| 73 | + public PageResult<ToolCodegenTableDO> getCodeGenTablePage(ToolCodegenTablePageReqVO pageReqVO) { | ||
| 74 | + return codegenTableMapper.selectPage(pageReqVO); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public ToolCodegenTableDO getCodeGenTablePage(Long id) { | ||
| 79 | + return codegenTableMapper.selectById(id); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public List<ToolCodegenColumnDO> getCodegenColumnListByTableId(Long tableId) { | ||
| 84 | + return codegenColumnMapper.selectListByTableId(tableId); | ||
| 85 | + } | ||
| 86 | + | ||
| 70 | } | 87 | } |
src/test/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngineTest.java
| @@ -24,8 +24,8 @@ public class ToolCodegenEngineTest { | @@ -24,8 +24,8 @@ public class ToolCodegenEngineTest { | ||
| 24 | 24 | ||
| 25 | @Test | 25 | @Test |
| 26 | public void testExecute() { | 26 | public void testExecute() { |
| 27 | - ToolCodegenTableDO table = codegenTableMapper.selectById(10); | ||
| 28 | - List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectByTableId(table.getId()); | 27 | + ToolCodegenTableDO table = codegenTableMapper.selectById(14); |
| 28 | + List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); | ||
| 29 | codegenEngine.execute(table, columns); | 29 | codegenEngine.execute(table, columns); |
| 30 | } | 30 | } |
| 31 | 31 |
src/test/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImplTest.java
| @@ -16,7 +16,9 @@ class ToolCodegenServiceImplTest { | @@ -16,7 +16,9 @@ class ToolCodegenServiceImplTest { | ||
| 16 | 16 | ||
| 17 | @Test | 17 | @Test |
| 18 | public void tetCreateCodegenTable() { | 18 | public void tetCreateCodegenTable() { |
| 19 | - toolCodegenService.createCodegenTable("sys_test_demo"); | 19 | +// toolCodegenService.createCodegenTable("sys_test_demo"); |
| 20 | +// toolCodegenService.createCodegenTable("tool_codegen_table"); | ||
| 21 | + toolCodegenService.createCodegenTable("tool_codegen_column"); | ||
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | } | 24 | } |