feat: 新增查询生成配置信息接口
This commit is contained in:
parent
f4c6d83ff5
commit
abae964970
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.tool.mapper;
|
package top.charles7c.cnadmin.tool.mapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||||
|
|
||||||
@ -25,4 +29,14 @@ import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
|||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 2023/4/12 23:56
|
* @since 2023/4/12 23:56
|
||||||
*/
|
*/
|
||||||
public interface GenConfigMapper extends BaseMapper<GenConfigDO> {}
|
public interface GenConfigMapper extends BaseMapper<GenConfigDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询推荐作者名
|
||||||
|
*
|
||||||
|
* @param lessThanDate
|
||||||
|
* 截止时间
|
||||||
|
* @return 推荐作者名
|
||||||
|
*/
|
||||||
|
String selectRecommendAuthor(@Param("lessThanDate") Date lessThanDate);
|
||||||
|
}
|
||||||
|
@ -112,16 +112,10 @@ public class ColumnMappingDO implements Serializable {
|
|||||||
private Boolean showInList;
|
private Boolean showInList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在新增中显示
|
* 是否在表单中显示
|
||||||
*/
|
*/
|
||||||
@Schema(description = "是否在新增中显示")
|
@Schema(description = "是否在表单中显示")
|
||||||
private Boolean showInAdd;
|
private Boolean showInForm;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否在修改中显示
|
|
||||||
*/
|
|
||||||
@Schema(description = "是否在修改中显示")
|
|
||||||
private Boolean showInUpdate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在查询中显示
|
* 是否在查询中显示
|
||||||
|
@ -20,6 +20,9 @@ import java.io.Serializable;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
@ -34,6 +37,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("gen_config")
|
@TableName("gen_config")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Schema(description = "生成配置信息")
|
||||||
public class GenConfigDO implements Serializable {
|
public class GenConfigDO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -42,57 +47,68 @@ public class GenConfigDO implements Serializable {
|
|||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
|
@Schema(description = "ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表名称
|
* 表名称
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "表名称")
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模块名称
|
* 模块名称
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "模块名称")
|
||||||
private String moduleName;
|
private String moduleName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包名称
|
* 包名称
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "包名称")
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端路径
|
||||||
|
*/
|
||||||
|
@Schema(description = "前端路径")
|
||||||
|
private String frontendPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务名称
|
* 业务名称
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "业务名称")
|
||||||
private String businessName;
|
private String businessName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作者
|
* 作者
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "作者")
|
||||||
private String author;
|
private String author;
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端路径
|
|
||||||
*/
|
|
||||||
private String frontendPath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表前缀
|
* 表前缀
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "表前缀")
|
||||||
private String tablePrefix;
|
private String tablePrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否覆盖
|
* 是否覆盖
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "是否覆盖")
|
||||||
private Boolean isOverride;
|
private Boolean isOverride;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "创建时间")
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改时间
|
* 修改时间
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "修改时间")
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||||
|
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||||
|
|
||||||
@ -41,9 +42,22 @@ public interface GeneratorService {
|
|||||||
* @param pageQuery
|
* @param pageQuery
|
||||||
* 分页查询条件
|
* 分页查询条件
|
||||||
* @return 表信息分页列表
|
* @return 表信息分页列表
|
||||||
|
* @throws SQLException
|
||||||
|
* /
|
||||||
*/
|
*/
|
||||||
PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException;
|
PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询生成配置信息
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* 表名称
|
||||||
|
* @return 生成配置信息
|
||||||
|
* @throws SQLException
|
||||||
|
* /
|
||||||
|
*/
|
||||||
|
GenConfigDO getGenConfig(String tableName) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列映射信息列表
|
* 查询列映射信息列表
|
||||||
*
|
*
|
||||||
|
@ -32,6 +32,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ClassUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.db.meta.Column;
|
import cn.hutool.db.meta.Column;
|
||||||
|
|
||||||
@ -42,7 +44,9 @@ import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
|||||||
import top.charles7c.cnadmin.tool.config.properties.GeneratorProperties;
|
import top.charles7c.cnadmin.tool.config.properties.GeneratorProperties;
|
||||||
import top.charles7c.cnadmin.tool.enums.FormTypeEnum;
|
import top.charles7c.cnadmin.tool.enums.FormTypeEnum;
|
||||||
import top.charles7c.cnadmin.tool.mapper.ColumnMappingMapper;
|
import top.charles7c.cnadmin.tool.mapper.ColumnMappingMapper;
|
||||||
|
import top.charles7c.cnadmin.tool.mapper.GenConfigMapper;
|
||||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||||
|
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||||
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
||||||
@ -63,6 +67,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final GeneratorProperties generatorProperties;
|
private final GeneratorProperties generatorProperties;
|
||||||
private final ColumnMappingMapper columnMappingMapper;
|
private final ColumnMappingMapper columnMappingMapper;
|
||||||
|
private final GenConfigMapper genConfigMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException {
|
public PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException {
|
||||||
@ -76,6 +81,31 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
return PageDataVO.build(pageQuery.getPage(), pageQuery.getSize(), tableVOList);
|
return PageDataVO.build(pageQuery.getPage(), pageQuery.getSize(), tableVOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GenConfigDO getGenConfig(String tableName) throws SQLException {
|
||||||
|
GenConfigDO genConfig =
|
||||||
|
genConfigMapper.selectOne(Wrappers.lambdaQuery(GenConfigDO.class).eq(GenConfigDO::getTableName, tableName));
|
||||||
|
if (null == genConfig) {
|
||||||
|
genConfig = new GenConfigDO().setTableName(tableName);
|
||||||
|
String packageName = ClassUtil.getPackage(GeneratorService.class);
|
||||||
|
genConfig.setPackageName(StrUtil.subBefore(packageName, StringConsts.DOT, true));
|
||||||
|
List<Table> tableList = MetaUtils.getTables(dataSource, tableName);
|
||||||
|
if (CollUtil.isNotEmpty(tableList)) {
|
||||||
|
Table table = tableList.get(0);
|
||||||
|
genConfig.setBusinessName(StrUtil.replace(table.getComment(), "表", StringConsts.EMPTY));
|
||||||
|
}
|
||||||
|
String recommendAuthor = genConfigMapper.selectRecommendAuthor(DateUtil.lastWeek().toJdkDate());
|
||||||
|
if (StrUtil.isNotBlank(recommendAuthor)) {
|
||||||
|
genConfig.setAuthor(recommendAuthor);
|
||||||
|
}
|
||||||
|
int underLineIndex = StrUtil.indexOf(tableName, StringConsts.C_UNDERLINE);
|
||||||
|
if (-1 != underLineIndex) {
|
||||||
|
genConfig.setTablePrefix(StrUtil.subPre(tableName, underLineIndex + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return genConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ColumnMappingDO> listColumnMapping(String tableName) {
|
public List<ColumnMappingDO> listColumnMapping(String tableName) {
|
||||||
List<ColumnMappingDO> columnMappingList = columnMappingMapper
|
List<ColumnMappingDO> columnMappingList = columnMappingMapper
|
||||||
@ -89,8 +119,9 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
ColumnMappingDO columnMapping = new ColumnMappingDO().setTableName(tableName)
|
ColumnMappingDO columnMapping = new ColumnMappingDO().setTableName(tableName)
|
||||||
.setColumnName(column.getName()).setColumnType(columnType.toLowerCase())
|
.setColumnName(column.getName()).setColumnType(columnType.toLowerCase())
|
||||||
.setComment(column.getComment()).setIsRequired(isRequired).setShowInList(true)
|
.setComment(column.getComment()).setIsRequired(isRequired).setShowInList(true)
|
||||||
.setShowInAdd(isRequired).setShowInUpdate(isRequired).setShowInQuery(isRequired)
|
.setShowInForm(isRequired).setShowInQuery(isRequired).setFormType(FormTypeEnum.TEXT);
|
||||||
.setFormType(FormTypeEnum.TEXT).setQueryType(QueryTypeEnum.EQUAL);
|
columnMapping.setQueryType(
|
||||||
|
"String".equals(columnMapping.getFieldType()) ? QueryTypeEnum.INNER_LIKE : QueryTypeEnum.EQUAL);
|
||||||
columnMappingList.add(columnMapping);
|
columnMappingList.add(columnMapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.db.Db;
|
import cn.hutool.db.Db;
|
||||||
import cn.hutool.db.Entity;
|
import cn.hutool.db.Entity;
|
||||||
import cn.hutool.db.meta.Column;
|
import cn.hutool.db.meta.Column;
|
||||||
@ -49,7 +50,27 @@ public class MetaUtils {
|
|||||||
* @return 表信息列表
|
* @return 表信息列表
|
||||||
*/
|
*/
|
||||||
public static List<Table> getTables(DataSource dataSource) throws SQLException {
|
public static List<Table> getTables(DataSource dataSource) throws SQLException {
|
||||||
List<Entity> tableEntityList = Db.use(dataSource).query("SHOW TABLE STATUS");
|
return getTables(dataSource, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有表信息
|
||||||
|
*
|
||||||
|
* @param dataSource
|
||||||
|
* 数据源
|
||||||
|
* @param tableName
|
||||||
|
* 表名称
|
||||||
|
* @return 表信息列表
|
||||||
|
*/
|
||||||
|
public static List<Table> getTables(DataSource dataSource, String tableName) throws SQLException {
|
||||||
|
String querySql = "SHOW TABLE STATUS";
|
||||||
|
List<Entity> tableEntityList;
|
||||||
|
Db db = Db.use(dataSource);
|
||||||
|
if (StrUtil.isNotBlank(tableName)) {
|
||||||
|
tableEntityList = db.query(String.format("%s WHERE NAME = ?", querySql), tableName);
|
||||||
|
} else {
|
||||||
|
tableEntityList = db.query(querySql);
|
||||||
|
}
|
||||||
List<Table> tableList = new ArrayList<>(tableEntityList.size());
|
List<Table> tableList = new ArrayList<>(tableEntityList.size());
|
||||||
for (Entity tableEntity : tableEntityList) {
|
for (Entity tableEntity : tableEntityList) {
|
||||||
Table table = new Table(tableEntity.getStr("NAME"));
|
Table table = new Table(tableEntity.getStr("NAME"));
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="top.charles7c.cnadmin.tool.mapper.GenConfigMapper">
|
||||||
|
<select id="selectRecommendAuthor" resultType="java.lang.String">
|
||||||
|
SELECT `author`
|
||||||
|
FROM `gen_config`
|
||||||
|
WHERE #{lessThanDate} > `create_time`
|
||||||
|
GROUP BY `author`
|
||||||
|
ORDER BY COUNT(*) DESC
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -40,8 +40,7 @@ export interface ColumnMappingRecord {
|
|||||||
sort: number;
|
sort: number;
|
||||||
isRequired: boolean;
|
isRequired: boolean;
|
||||||
showInList: boolean;
|
showInList: boolean;
|
||||||
showInAdd: boolean;
|
showInForm: boolean;
|
||||||
showInUpdate: boolean;
|
|
||||||
showInQuery: boolean;
|
showInQuery: boolean;
|
||||||
formType: string;
|
formType: string;
|
||||||
queryType: string;
|
queryType: string;
|
||||||
@ -49,6 +48,10 @@ export interface ColumnMappingRecord {
|
|||||||
updateTime: string;
|
updateTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listColumnMapping(tableName: string) {
|
||||||
|
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}`);
|
||||||
|
}
|
||||||
|
|
||||||
export interface GenConfigRecord {
|
export interface GenConfigRecord {
|
||||||
id: string;
|
id: string;
|
||||||
tableName: string;
|
tableName: string;
|
||||||
@ -63,6 +66,6 @@ export interface GenConfigRecord {
|
|||||||
updateTime: string;
|
updateTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listColumnMapping(tableName: string) {
|
export function getGenConfig(tableName: string) {
|
||||||
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}`);
|
return axios.get<GenConfigRecord>(`${BASE_URL}/table/${tableName}`);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,19 @@
|
|||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
>
|
>
|
||||||
<a-card title="字段配置" class="field-config">
|
<a-card title="字段配置" class="field-config">
|
||||||
|
<template #extra>
|
||||||
|
<a-space>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
status="success"
|
||||||
|
size="small"
|
||||||
|
title="同步"
|
||||||
|
disabled
|
||||||
|
>
|
||||||
|
<template #icon><icon-sync /></template>同步
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
<a-table
|
<a-table
|
||||||
ref="columnMappingRef"
|
ref="columnMappingRef"
|
||||||
:data="columnMappingList"
|
:data="columnMappingList"
|
||||||
@ -156,16 +169,6 @@
|
|||||||
<a-input v-model="record.comment" />
|
<a-input v-model="record.comment" />
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column
|
|
||||||
title="必填"
|
|
||||||
data-index="isRequired"
|
|
||||||
:width="60"
|
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
<template #cell="{ record }">
|
|
||||||
<a-checkbox v-model="record.isRequired" value="true" />
|
|
||||||
</template>
|
|
||||||
</a-table-column>
|
|
||||||
<a-table-column
|
<a-table-column
|
||||||
title="列表"
|
title="列表"
|
||||||
data-index="showInList"
|
data-index="showInList"
|
||||||
@ -177,23 +180,34 @@
|
|||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column
|
<a-table-column
|
||||||
title="新增"
|
title="表单"
|
||||||
data-index="showInAdd"
|
data-index="showInForm"
|
||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<a-checkbox v-model="record.showInAdd" value="true" />
|
<a-checkbox v-model="record.showInForm" value="true" />
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column
|
<a-table-column
|
||||||
title="修改"
|
title="必填"
|
||||||
data-index="showInUpdate"
|
data-index="isRequired"
|
||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<a-checkbox v-model="record.showInUpdate" value="true" />
|
<a-checkbox v-if="record.showInForm" v-model="record.isRequired" value="true" />
|
||||||
|
<a-checkbox v-else disabled />
|
||||||
|
</template>
|
||||||
|
</a-table-column>
|
||||||
|
<a-table-column
|
||||||
|
title="查询"
|
||||||
|
data-index="showInQuery"
|
||||||
|
:width="60"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<template #cell="{ record }">
|
||||||
|
<a-checkbox v-model="record.showInQuery" value="true" />
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column
|
<a-table-column
|
||||||
@ -203,19 +217,23 @@
|
|||||||
>
|
>
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<a-select
|
<a-select
|
||||||
|
v-if="record.showInForm || record.showInQuery"
|
||||||
v-model="record.formType"
|
v-model="record.formType"
|
||||||
:options="FormTypeEnum"
|
:options="FormTypeEnum"
|
||||||
placeholder="请选择表单类型"
|
placeholder="请选择表单类型"
|
||||||
/>
|
/>
|
||||||
|
<span v-else>无需设置</span>
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column title="查询方式" data-index="queryType">
|
<a-table-column title="查询方式" data-index="queryType">
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<a-select
|
<a-select
|
||||||
|
v-if="record.showInQuery"
|
||||||
v-model="record.queryType"
|
v-model="record.queryType"
|
||||||
:options="QueryTypeEnum"
|
:options="QueryTypeEnum"
|
||||||
placeholder="请选择查询方式"
|
placeholder="请选择查询方式"
|
||||||
/>
|
/>
|
||||||
|
<span v-else>无需设置</span>
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
</template>
|
</template>
|
||||||
@ -284,6 +302,7 @@
|
|||||||
GenConfigRecord,
|
GenConfigRecord,
|
||||||
listTable,
|
listTable,
|
||||||
listColumnMapping,
|
listColumnMapping,
|
||||||
|
getGenConfig,
|
||||||
} from '@/api/tool/generator';
|
} from '@/api/tool/generator';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
@ -348,10 +367,13 @@
|
|||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
*/
|
*/
|
||||||
const toConfig = (tableName: string) => {
|
const toConfig = (tableName: string) => {
|
||||||
title.value = `${tableName} 配置`;
|
let tableComment = tableList.value.filter(
|
||||||
form.value.isOverride = false;
|
(t) => t.tableName === tableName
|
||||||
|
)[0].comment;
|
||||||
|
tableComment = tableComment ? `(${tableComment})` : ' ';
|
||||||
|
title.value = `${tableName}${tableComment}配置`;
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
// 查询所有字段信息
|
// 查询列映射信息
|
||||||
columnMappingLoading.value = true;
|
columnMappingLoading.value = true;
|
||||||
listColumnMapping(tableName)
|
listColumnMapping(tableName)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -360,6 +382,11 @@
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
columnMappingLoading.value = false;
|
columnMappingLoading.value = false;
|
||||||
});
|
});
|
||||||
|
// 查询生成配置
|
||||||
|
getGenConfig(tableName).then((res) => {
|
||||||
|
form.value = res.data;
|
||||||
|
form.value.isOverride = false;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +34,7 @@ import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|||||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
import top.charles7c.cnadmin.common.model.vo.R;
|
||||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||||
|
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||||
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
||||||
@ -59,6 +60,12 @@ public class GeneratorController {
|
|||||||
return R.ok(generatorService.pageTable(query, pageQuery));
|
return R.ok(generatorService.pageTable(query, pageQuery));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
|
||||||
|
@GetMapping("/table/{tableName}")
|
||||||
|
public R<GenConfigDO> getGenConfig(@PathVariable String tableName) throws SQLException {
|
||||||
|
return R.ok(generatorService.getGenConfig(tableName));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询列映射信息列表", description = "查询列映射信息列表")
|
@Operation(summary = "查询列映射信息列表", description = "查询列映射信息列表")
|
||||||
@GetMapping("/column/{tableName}")
|
@GetMapping("/column/{tableName}")
|
||||||
public R<List<ColumnMappingDO>> listColumnMapping(@PathVariable String tableName) {
|
public R<List<ColumnMappingDO>> listColumnMapping(@PathVariable String tableName) {
|
||||||
|
@ -28,8 +28,7 @@ CREATE TABLE IF NOT EXISTS `gen_column_mapping` (
|
|||||||
`sort` int(11) UNSIGNED DEFAULT 999 COMMENT '排序',
|
`sort` int(11) UNSIGNED DEFAULT 999 COMMENT '排序',
|
||||||
`is_required` bit(1) DEFAULT b'1' COMMENT '是否必填',
|
`is_required` bit(1) DEFAULT b'1' COMMENT '是否必填',
|
||||||
`show_in_list` bit(1) DEFAULT b'1' COMMENT '是否在列表中显示',
|
`show_in_list` bit(1) DEFAULT b'1' COMMENT '是否在列表中显示',
|
||||||
`show_in_add` bit(1) DEFAULT b'1' COMMENT '是否在新增中显示',
|
`show_in_form` bit(1) DEFAULT b'1' COMMENT '是否在表单中显示',
|
||||||
`show_in_update` bit(1) DEFAULT b'1' COMMENT '是否在修改中显示',
|
|
||||||
`show_in_query` bit(1) DEFAULT b'1' COMMENT '是否在查询中显示',
|
`show_in_query` bit(1) DEFAULT b'1' COMMENT '是否在查询中显示',
|
||||||
`form_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '表单类型',
|
`form_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '表单类型',
|
||||||
`query_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '查询方式',
|
`query_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '查询方式',
|
||||||
|
Loading…
Reference in New Issue
Block a user