!349 代码生成 从对应数据源加载表结构信息 存储到主数据源 实现存储统一
* 数据库脚本修改,gen_table增加data_name字段,存储对应数据源名称
* 代码生成 从对应数据源加载表结构信息 存储到主数据源 实现存储统一(表结构需要增加对应的数据来源字段) https://gitee.com/…
| | |
| | | import java.sql.Connection; |
| | | import java.sql.DatabaseMetaData; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 数据库助手 |
| | |
| | | // find_in_set(100 , '0,100,101') |
| | | return "find_in_set('%s' , %s) <> 0".formatted(var, var2); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前加载的数据库名 |
| | | */ |
| | | public static List<String> getDataSourceNameList() { |
| | | return new ArrayList<>(DS.getDataSources().keySet()); |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | |
| | | @SaCheckPermission("tool:gen:import") |
| | | @Log(title = "代码生成", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importTable") |
| | | public R<Void> importTableSave(String tables) { |
| | | public R<Void> importTableSave(String tables, String dataName) { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | // 查询表信息 |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); |
| | | genTableService.importGenTable(tableList); |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames, dataName); |
| | | genTableService.importGenTable(tableList, dataName); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableName 表名 |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/download/{tableName}") |
| | | public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { |
| | | byte[] data = genTableService.downloadCode(tableName); |
| | | @GetMapping("/download/{tableId}") |
| | | public void download(HttpServletResponse response, @PathVariable("tableId") Long tableId) throws IOException { |
| | | byte[] data = genTableService.downloadCode(tableId); |
| | | genCode(response, data); |
| | | } |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableName 表名 |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/genCode/{tableName}") |
| | | public R<Void> genCode(@PathVariable("tableName") String tableName) { |
| | | genTableService.generatorCode(tableName); |
| | | @GetMapping("/genCode/{tableId}") |
| | | public R<Void> genCode(@PathVariable("tableId") Long tableId) { |
| | | genTableService.generatorCode(tableId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableName 表名 |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/synchDb/{tableName}") |
| | | public R<Void> synchDb(@PathVariable("tableName") String tableName) { |
| | | genTableService.synchDb(tableName); |
| | | @GetMapping("/synchDb/{tableId}") |
| | | public R<Void> synchDb(@PathVariable("tableId") Long tableId) { |
| | | genTableService.synchDb(tableId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 批量生成代码 |
| | | * |
| | | * @param tables 表名串 |
| | | * @param tableIdStr 表ID串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/batchGenCode") |
| | | public void batchGenCode(HttpServletResponse response, String tables) throws IOException { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | byte[] data = genTableService.downloadCode(tableNames); |
| | | public void batchGenCode(HttpServletResponse response, String tableIdStr) throws IOException { |
| | | String[] tableIds = Convert.toStrArray(tableIdStr); |
| | | byte[] data = genTableService.downloadCode(tableIds); |
| | | genCode(response, data); |
| | | } |
| | | |
| | |
| | | response.setContentType("application/octet-stream; charset=UTF-8"); |
| | | IoUtil.write(response.getOutputStream(), false, data); |
| | | } |
| | | |
| | | /** |
| | | * 查询数据源名称列表 |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping(value = "/getDataNames") |
| | | public R<Object> getCurrentDataSourceNameList(){ |
| | | return R.ok(DataBaseHelper.getDataSourceNameList()); |
| | | } |
| | | } |
| | |
| | | private Long tableId; |
| | | |
| | | /** |
| | | * 数据源名称 |
| | | */ |
| | | @NotBlank(message = "数据源名称不能为空") |
| | | private String dataName; |
| | | |
| | | /** |
| | | * 表名称 |
| | | */ |
| | | @NotBlank(message = "表名称不能为空") |
| | |
| | | package org.dromara.generator.mapper; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.generator.domain.GenTableColumn; |
| | |
| | | * 根据表名称查询列信息 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param dataName |
| | | * @return 列信息 |
| | | */ |
| | | List<GenTableColumn> selectDbTableColumnsByName(String tableName); |
| | | @DS("#dataName") |
| | | List<GenTableColumn> selectDbTableColumnsByName(String tableName, String dataName); |
| | | |
| | | } |
| | |
| | | package org.dromara.generator.mapper; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | |
| | | */ |
| | | GenTable selectGenTableByName(String tableName); |
| | | |
| | | @DS("") |
| | | List<String> selectTableNameList(String dataName); |
| | | } |
| | |
| | | import cn.hutool.core.lang.Dict; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.generator.constant.GenConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.generator.constant.GenConstants; |
| | | import org.dromara.generator.domain.GenTable; |
| | | import org.dromara.generator.domain.GenTableColumn; |
| | | import org.dromara.generator.mapper.GenTableColumnMapper; |
| | |
| | | import org.dromara.generator.util.GenUtils; |
| | | import org.dromara.generator.util.VelocityInitializer; |
| | | import org.dromara.generator.util.VelocityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.io.IOException; |
| | | import java.io.StringWriter; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @DS("#header.datasource") |
| | | // @DS("#header.datasource") |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | |
| | | private QueryWrapper<GenTable> buildGenTableQueryWrapper(GenTable genTable) { |
| | | Map<String, Object> params = genTable.getParams(); |
| | | QueryWrapper<GenTable> wrapper = Wrappers.query(); |
| | | wrapper.like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName())) |
| | | wrapper |
| | | .eq(StringUtils.isNotEmpty(genTable.getDataName()),"data_name", genTable.getDataName()) |
| | | .like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName())) |
| | | .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment())) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | "create_time", params.get("beginTime"), params.get("endTime")); |
| | | return wrapper; |
| | | } |
| | | |
| | | |
| | | @DS("#genTable.dataName") |
| | | @Override |
| | | public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) { |
| | | genTable.getParams().put("genTableNames",baseMapper.selectTableNameList(genTable.getDataName())); |
| | | Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable); |
| | | return TableDataInfo.build(page); |
| | | } |
| | |
| | | * 查询据库列表 |
| | | * |
| | | * @param tableNames 表名称组 |
| | | * @param dataName |
| | | * @return 数据库表集合 |
| | | */ |
| | | @DS("#dataName") |
| | | @Override |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames) { |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName) { |
| | | return baseMapper.selectDbTableListByNames(tableNames); |
| | | } |
| | | |
| | |
| | | * 导入表结构 |
| | | * |
| | | * @param tableList 导入表列表 |
| | | * @param dataName |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DSTransactional |
| | | @Override |
| | | public void importGenTable(List<GenTable> tableList) { |
| | | public void importGenTable(List<GenTable> tableList, String dataName) { |
| | | String operName = LoginHelper.getUsername(); |
| | | try { |
| | | for (GenTable table : tableList) { |
| | | String tableName = table.getTableName(); |
| | | GenUtils.initTable(table, operName); |
| | | table.setDataName(dataName); |
| | | int row = baseMapper.insert(table); |
| | | if (row > 0) { |
| | | // 保存列信息 |
| | | List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
| | | List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dataName); |
| | | List<GenTableColumn> saveColumns = new ArrayList<>(); |
| | | for (GenTableColumn column : genTableColumns) { |
| | | GenUtils.initColumnField(column, table); |
| | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | * @return 数据 |
| | | */ |
| | | @Override |
| | | public byte[] downloadCode(String tableName) { |
| | | public byte[] downloadCode(Long tableId) { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | generatorCode(tableName, zip); |
| | | generatorCode(tableId, zip); |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | */ |
| | | @Override |
| | | public void generatorCode(String tableName) { |
| | | public void generatorCode(Long tableId) { |
| | | // 查询表信息 |
| | | GenTable table = baseMapper.selectGenTableByName(tableName); |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | // 设置主键列信息 |
| | | setPkColumn(table); |
| | | |
| | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DSTransactional |
| | | @Override |
| | | public void synchDb(String tableName) { |
| | | GenTable table = baseMapper.selectGenTableByName(tableName); |
| | | public void synchDb(Long tableId) { |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | List<GenTableColumn> tableColumns = table.getColumns(); |
| | | Map<String, GenTableColumn> tableColumnMap = StreamUtils.toIdentityMap(tableColumns, GenTableColumn::getColumnName); |
| | | |
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(table.getTableName(), table.getDataName()); |
| | | if (CollUtil.isEmpty(dbTableColumns)) { |
| | | throw new ServiceException("同步数据失败,原表结构不存在"); |
| | | } |
| | |
| | | List<GenTableColumn> delColumns = StreamUtils.filter(tableColumns, column -> !dbTableColumnNames.contains(column.getColumnName())); |
| | | if (CollUtil.isNotEmpty(delColumns)) { |
| | | List<Long> ids = StreamUtils.toList(delColumns, GenTableColumn::getColumnId); |
| | | genTableColumnMapper.deleteBatchIds(ids); |
| | | if (CollUtil.isNotEmpty(ids)) { |
| | | genTableColumnMapper.deleteBatchIds(ids); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量生成代码(下载方式) |
| | | * |
| | | * @param tableNames 表数组 |
| | | * @param tableIds 表ID数组 |
| | | * @return 数据 |
| | | */ |
| | | @Override |
| | | public byte[] downloadCode(String[] tableNames) { |
| | | public byte[] downloadCode(String[] tableIds) { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | for (String tableName : tableNames) { |
| | | generatorCode(tableName, zip); |
| | | for (String tableId : tableIds) { |
| | | generatorCode(Long.parseLong(tableId), zip); |
| | | } |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | |
| | | /** |
| | | * 查询表信息并生成代码 |
| | | */ |
| | | private void generatorCode(String tableName, ZipOutputStream zip) { |
| | | private void generatorCode(Long tableId, ZipOutputStream zip) { |
| | | // 查询表信息 |
| | | GenTable table = baseMapper.selectGenTableByName(tableName); |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | List<Long> menuIds = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | menuIds.add(identifierGenerator.nextId(null).longValue()); |
| | |
| | | * 查询据库列表 |
| | | * |
| | | * @param tableNames 表名称组 |
| | | * @param dataName |
| | | * @return 数据库表集合 |
| | | */ |
| | | List<GenTable> selectDbTableListByNames(String[] tableNames); |
| | | List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName); |
| | | |
| | | /** |
| | | * 查询所有表信息 |
| | |
| | | * 导入表结构 |
| | | * |
| | | * @param tableList 导入表列表 |
| | | * @param dataName |
| | | */ |
| | | void importGenTable(List<GenTable> tableList); |
| | | void importGenTable(List<GenTable> tableList, String dataName); |
| | | |
| | | /** |
| | | * 预览代码 |
| | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | * @return 数据 |
| | | */ |
| | | byte[] downloadCode(String tableName); |
| | | byte[] downloadCode(Long tableId); |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | * @return 数据 |
| | | */ |
| | | void generatorCode(String tableName); |
| | | void generatorCode(Long tableId); |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param tableId 表名称 |
| | | */ |
| | | void synchDb(String tableName); |
| | | void synchDb(Long tableId); |
| | | |
| | | /** |
| | | * 批量生成代码(下载方式) |
| | | * |
| | | * @param tableNames 表数组 |
| | | * @param tableIds 表ID数组 |
| | | * @return 数据 |
| | | */ |
| | | byte[] downloadCode(String[] tableNames); |
| | | byte[] downloadCode(String[] tableIds); |
| | | |
| | | /** |
| | | * 修改保存参数校验 |
| | |
| | | from information_schema.tables |
| | | where table_schema = (select database()) |
| | | AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT IN (select table_name from gen_table) |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND table_name NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) |
| | | </if> |
| | |
| | | and dt.table_name = uo.object_name |
| | | and uo.object_type = 'TABLE' |
| | | AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%' |
| | | AND lower(dt.table_name) NOT IN (select table_name from gen_table) |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND lower(dt.table_name) NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(dt.table_name) like lower(concat(concat('%', #{genTable.tableName}), '%')) |
| | | </if> |
| | |
| | | AND n.nspname <![CDATA[ <> ]]> ''::name |
| | | ) list_table |
| | | where table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT IN (select table_name from gen_table) |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND table_name NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) |
| | | </if> |
| | |
| | | INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID |
| | | AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES' |
| | | AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%' |
| | | AND D.NAME NOT IN (select table_name from gen_table) |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND D.NAME NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(D.NAME) like lower(concat(N'%', N'${genTable.tableName}', N'%')) |
| | | </if> |
| | |
| | | </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.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | 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 |
| | |
| | | </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.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | 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 |
| | |
| | | </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.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.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> |
| | | |
| | | <select id="selectTableNameList" resultType="java.lang.String"> |
| | | select table_name from gen_table where data_name = #{dataName,jdbcType=VARCHAR} |
| | | </select> |
| | | </mapper> |
| | |
| | | -- ---------------------------- |
| | | create table gen_table ( |
| | | table_id number(20) not null, |
| | | data_name varchar2(200) default '', |
| | | table_name varchar2(200) default '', |
| | | table_comment varchar2(500) default '', |
| | | sub_table_name varchar(64) default null, |
| | |
| | | |
| | | comment on table gen_table is '代码生成业务表'; |
| | | comment on column gen_table.table_id is '编号'; |
| | | comment on column gen_table.data_name is '数据源名称'; |
| | | comment on column gen_table.table_name is '表名称'; |
| | | comment on column gen_table.table_comment is '表描述'; |
| | | comment on column gen_table.sub_table_name is '关联子表的表名'; |
| | |
| | | create table if not exists gen_table |
| | | ( |
| | | table_id int8, |
| | | data_name varchar(200) default ''::varchar, |
| | | table_name varchar(200) default ''::varchar, |
| | | table_comment varchar(500) default ''::varchar, |
| | | sub_table_name varchar(64) default ''::varchar, |
| | |
| | | |
| | | comment on table gen_table is '代码生成业务表'; |
| | | comment on column gen_table.table_id is '编号'; |
| | | comment on column gen_table.data_name is '数据源名称'; |
| | | comment on column gen_table.table_name is '表名称'; |
| | | comment on column gen_table.table_comment is '表描述'; |
| | | comment on column gen_table.sub_table_name is '关联子表的表名'; |
| | |
| | | drop table if exists gen_table; |
| | | create table gen_table ( |
| | | table_id bigint(20) not null comment '编号', |
| | | data_name varchar(200) default '' comment '数据源名称', |
| | | table_name varchar(200) default '' comment '表名称', |
| | | table_comment varchar(500) default '' comment '表描述', |
| | | sub_table_name varchar(64) default null comment '关联子表的表名', |
| | |
| | | CREATE TABLE gen_table |
| | | ( |
| | | table_id bigint NOT NULL, |
| | | data_name nvarchar(200) DEFAULT '' NULL, |
| | | table_name nvarchar(200) DEFAULT '' NULL, |
| | | table_comment nvarchar(500) DEFAULT '' NULL, |
| | | sub_table_name nvarchar(64) NULL, |
| | |
| | | 'COLUMN', N'table_id' |
| | | GO |
| | | EXEC sys.sp_addextendedproperty |
| | | 'MS_Description', N'数据源名称' , |
| | | 'SCHEMA', N'dbo', |
| | | 'TABLE', N'gen_table', |
| | | 'COLUMN', N'data_name' |
| | | GO |
| | | EXEC sys.sp_addextendedproperty |
| | | 'MS_Description', N'表名称' , |
| | | 'SCHEMA', N'dbo', |
| | | 'TABLE', N'gen_table', |