refactor: 优化代码生成配置相关表名、 API 地址及相关描述
1、列映射表重命名为字段配置表
This commit is contained in:
parent
241a9cf85b
commit
2d0e1f42d4
@ -16,13 +16,29 @@
|
||||
|
||||
package top.charles7c.cnadmin.tool.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
|
||||
/**
|
||||
* 列映射 Mapper
|
||||
* 字段配置 Mapper
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/4/12 23:56
|
||||
*/
|
||||
public interface ColumnMappingMapper extends BaseMapper<ColumnMappingDO> {}
|
||||
public interface FieldConfigMapper extends BaseMapper<FieldConfigDO> {
|
||||
|
||||
/**
|
||||
* 根据表名称查询
|
||||
*
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @return 字段配置信息
|
||||
*/
|
||||
@Select("SELECT * FROM `gen_field_config` WHERE `table_name` = #{tableName}")
|
||||
List<FieldConfigDO> selectListByTableName(@Param("tableName") String tableName);
|
||||
}
|
@ -42,17 +42,17 @@ import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
||||
import top.charles7c.cnadmin.tool.enums.FormTypeEnum;
|
||||
|
||||
/**
|
||||
* 列映射实体
|
||||
* 字段配置实体
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/4/12 20:21
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_column_mapping")
|
||||
@TableName("gen_field_config")
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "列映射信息")
|
||||
public class ColumnMappingDO implements Serializable {
|
||||
@Schema(description = "字段配置信息")
|
||||
public class FieldConfigDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -140,7 +140,7 @@ public class ColumnMappingDO implements Serializable {
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public ColumnMappingDO(@NonNull Column column) {
|
||||
public FieldConfigDO(@NonNull Column column) {
|
||||
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConsts.SPACE)[0].toLowerCase();
|
||||
boolean isRequired = !column.isPk() && !column.isNullable();
|
||||
this.tableName = column.getTableName();
|
||||
@ -150,13 +150,13 @@ public class ColumnMappingDO implements Serializable {
|
||||
this.setQueryType("String".equals(this.getFieldType()) ? QueryTypeEnum.INNER_LIKE : QueryTypeEnum.EQUAL);
|
||||
}
|
||||
|
||||
public ColumnMappingDO setColumnName(String columnName) {
|
||||
public FieldConfigDO setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
this.fieldName = StrUtil.toCamelCase(this.columnName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnMappingDO setColumnType(String columnType) {
|
||||
public FieldConfigDO setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
Props generatorProp = PropsUtil.get("generator");
|
||||
this.fieldType = generatorProp.getStr(columnType);
|
@ -27,7 +27,7 @@ import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
|
||||
/**
|
||||
@ -43,16 +43,16 @@ public class GenConfigRequest implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 列映射信息列表
|
||||
* 字段配置
|
||||
*/
|
||||
@Schema(description = "列映射信息列表")
|
||||
@NotEmpty(message = "列映射信息不能为空")
|
||||
private List<ColumnMappingDO> columnMappings = new ArrayList<>();
|
||||
@Schema(description = "字段配置")
|
||||
@NotEmpty(message = "字段配置不能为空")
|
||||
private List<FieldConfigDO> fieldConfigs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 生成配置信息
|
||||
* 生成配置
|
||||
*/
|
||||
@Schema(description = "生成配置信息")
|
||||
@NotNull(message = "生成配置信息不能为空")
|
||||
@Schema(description = "生成配置")
|
||||
@NotNull(message = "生成配置不能为空")
|
||||
private GenConfigDO genConfig;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||
import top.charles7c.cnadmin.tool.model.request.GenConfigRequest;
|
||||
@ -60,15 +60,15 @@ public interface GeneratorService {
|
||||
GenConfigDO getGenConfig(String tableName) throws SQLException;
|
||||
|
||||
/**
|
||||
* 查询列映射信息列表
|
||||
* 查询字段配置列表
|
||||
*
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @param requireSync
|
||||
* 是否需要同步
|
||||
* @return 列映射信息列表
|
||||
* @return 字段配置列表
|
||||
*/
|
||||
List<ColumnMappingDO> listColumnMapping(String tableName, Boolean requireSync);
|
||||
List<FieldConfigDO> listFieldConfig(String tableName, Boolean requireSync);
|
||||
|
||||
/**
|
||||
* 保存代码生成配置信息
|
||||
|
@ -44,9 +44,9 @@ import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
||||
import top.charles7c.cnadmin.tool.config.properties.GeneratorProperties;
|
||||
import top.charles7c.cnadmin.tool.mapper.ColumnMappingMapper;
|
||||
import top.charles7c.cnadmin.tool.mapper.FieldConfigMapper;
|
||||
import top.charles7c.cnadmin.tool.mapper.GenConfigMapper;
|
||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||
import top.charles7c.cnadmin.tool.model.request.GenConfigRequest;
|
||||
@ -68,7 +68,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
private final DataSource dataSource;
|
||||
private final GeneratorProperties generatorProperties;
|
||||
private final ColumnMappingMapper columnMappingMapper;
|
||||
private final FieldConfigMapper fieldConfigMapper;
|
||||
private final GenConfigMapper genConfigMapper;
|
||||
|
||||
@Override
|
||||
@ -113,67 +113,65 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ColumnMappingDO> listColumnMapping(String tableName, Boolean requireSync) {
|
||||
List<ColumnMappingDO> columnMappingList = columnMappingMapper
|
||||
.selectList(Wrappers.lambdaQuery(ColumnMappingDO.class).eq(ColumnMappingDO::getTableName, tableName));
|
||||
if (CollUtil.isEmpty(columnMappingList)) {
|
||||
public List<FieldConfigDO> listFieldConfig(String tableName, Boolean requireSync) {
|
||||
List<FieldConfigDO> fieldConfigList = fieldConfigMapper.selectListByTableName(tableName);
|
||||
if (CollUtil.isEmpty(fieldConfigList)) {
|
||||
Collection<Column> columnList = MetaUtils.getColumns(dataSource, tableName);
|
||||
return columnList.stream().map(ColumnMappingDO::new).collect(Collectors.toList());
|
||||
return columnList.stream().map(FieldConfigDO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 同步最新数据表列信息
|
||||
if (requireSync) {
|
||||
Collection<Column> columnList = MetaUtils.getColumns(dataSource, tableName);
|
||||
// 移除已不存在的列映射信息
|
||||
// 移除已不存在的字段配置
|
||||
List<String> columnNameList = columnList.stream().map(Column::getName).collect(Collectors.toList());
|
||||
columnMappingList.removeIf(column -> !columnNameList.contains(column.getColumnName()));
|
||||
// 新增或更新列映射信息
|
||||
Map<String, ColumnMappingDO> columnMappingMap = columnMappingList.stream()
|
||||
.collect(Collectors.toMap(ColumnMappingDO::getColumnName, Function.identity(), (key1, key2) -> key2));
|
||||
fieldConfigList.removeIf(column -> !columnNameList.contains(column.getColumnName()));
|
||||
// 新增或更新字段配置
|
||||
Map<String, FieldConfigDO> fieldConfigMap = fieldConfigList.stream()
|
||||
.collect(Collectors.toMap(FieldConfigDO::getColumnName, Function.identity(), (key1, key2) -> key2));
|
||||
for (Column column : columnList) {
|
||||
ColumnMappingDO columnMapping = columnMappingMap.get(column.getName());
|
||||
if (null != columnMapping) {
|
||||
// 更新已有列映射信息
|
||||
FieldConfigDO fieldConfig = fieldConfigMap.get(column.getName());
|
||||
if (null != fieldConfig) {
|
||||
// 更新已有字段配置
|
||||
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConsts.SPACE)[0].toLowerCase();
|
||||
columnMapping.setColumnType(columnType).setComment(column.getComment());
|
||||
fieldConfig.setColumnType(columnType).setComment(column.getComment());
|
||||
} else {
|
||||
// 新增列映射信息
|
||||
columnMapping = new ColumnMappingDO(column);
|
||||
columnMappingList.add(columnMapping);
|
||||
// 新增字段配置
|
||||
fieldConfig = new FieldConfigDO(column);
|
||||
fieldConfigList.add(fieldConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
return columnMappingList;
|
||||
return fieldConfigList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveConfig(GenConfigRequest request, String tableName) {
|
||||
// 保存列映射信息
|
||||
columnMappingMapper
|
||||
.delete(Wrappers.lambdaQuery(ColumnMappingDO.class).eq(ColumnMappingDO::getTableName, tableName));
|
||||
List<ColumnMappingDO> columnMappingList = request.getColumnMappings();
|
||||
for (ColumnMappingDO columnMapping : columnMappingList) {
|
||||
if (columnMapping.getShowInForm()) {
|
||||
CheckUtils.throwIfNull(columnMapping.getFormType(), "字段 [{}] 的表单类型不能为空", columnMapping.getFieldName());
|
||||
// 保存字段配置
|
||||
fieldConfigMapper.delete(Wrappers.lambdaQuery(FieldConfigDO.class).eq(FieldConfigDO::getTableName, tableName));
|
||||
List<FieldConfigDO> fieldConfigList = request.getFieldConfigs();
|
||||
for (FieldConfigDO fieldConfig : fieldConfigList) {
|
||||
if (fieldConfig.getShowInForm()) {
|
||||
CheckUtils.throwIfNull(fieldConfig.getFormType(), "字段 [{}] 的表单类型不能为空", fieldConfig.getFieldName());
|
||||
} else {
|
||||
// 在表单中不显示,不需要设置必填
|
||||
columnMapping.setIsRequired(false);
|
||||
fieldConfig.setIsRequired(false);
|
||||
}
|
||||
if (columnMapping.getShowInQuery()) {
|
||||
CheckUtils.throwIfNull(columnMapping.getFormType(), "字段 [{}] 的表单类型不能为空", columnMapping.getFieldName());
|
||||
CheckUtils.throwIfNull(columnMapping.getQueryType(), "字段 [{}] 的查询方式不能为空", columnMapping.getFieldName());
|
||||
if (fieldConfig.getShowInQuery()) {
|
||||
CheckUtils.throwIfNull(fieldConfig.getFormType(), "字段 [{}] 的表单类型不能为空", fieldConfig.getFieldName());
|
||||
CheckUtils.throwIfNull(fieldConfig.getQueryType(), "字段 [{}] 的查询方式不能为空", fieldConfig.getFieldName());
|
||||
} else {
|
||||
// 在查询中不显示,不需要设置查询方式
|
||||
columnMapping.setQueryType(null);
|
||||
fieldConfig.setQueryType(null);
|
||||
}
|
||||
// 既不在表单也不在查询中显示,不需要设置表单类型
|
||||
if (!columnMapping.getShowInForm() && !columnMapping.getShowInQuery()) {
|
||||
columnMapping.setFormType(null);
|
||||
if (!fieldConfig.getShowInForm() && !fieldConfig.getShowInQuery()) {
|
||||
fieldConfig.setFormType(null);
|
||||
}
|
||||
columnMapping.setTableName(tableName);
|
||||
fieldConfig.setTableName(tableName);
|
||||
}
|
||||
columnMappingMapper.insertBatch(columnMappingList);
|
||||
fieldConfigMapper.insertBatch(fieldConfigList);
|
||||
|
||||
// 保存或更新生成配置信息
|
||||
GenConfigDO newGenConfig = request.getGenConfig();
|
||||
|
@ -29,7 +29,7 @@ export function listTable(params: TableParam) {
|
||||
});
|
||||
}
|
||||
|
||||
export interface ColumnMappingRecord {
|
||||
export interface FieldConfigRecord {
|
||||
tableName: string;
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
@ -45,8 +45,8 @@ export interface ColumnMappingRecord {
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export function listColumnMapping(tableName: string, requireSync: boolean) {
|
||||
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}?requireSync=${requireSync}`);
|
||||
export function listFieldConfig(tableName: string, requireSync: boolean) {
|
||||
return axios.get<FieldConfigRecord[]>(`${BASE_URL}/field/${tableName}?requireSync=${requireSync}`);
|
||||
}
|
||||
|
||||
export interface GenConfigRecord {
|
||||
@ -63,14 +63,14 @@ export interface GenConfigRecord {
|
||||
}
|
||||
|
||||
export function getGenConfig(tableName: string) {
|
||||
return axios.get<GenConfigRecord>(`${BASE_URL}/table/${tableName}`);
|
||||
return axios.get<GenConfigRecord>(`${BASE_URL}/config/${tableName}`);
|
||||
}
|
||||
|
||||
export interface GeneratorConfigRecord {
|
||||
genConfig: GenConfigRecord;
|
||||
columnMappings: ColumnMappingRecord[];
|
||||
fieldConfigs: FieldConfigRecord[];
|
||||
}
|
||||
|
||||
export function saveConfig(tableName: string, req: GeneratorConfigRecord) {
|
||||
return axios.post(`${BASE_URL}/table/${tableName}`, req);
|
||||
return axios.post(`${BASE_URL}/config/${tableName}`, req);
|
||||
}
|
||||
|
@ -28,24 +28,6 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<!-- 操作栏 -->
|
||||
<div class="header-operation">
|
||||
<a-row>
|
||||
<a-col :span="12">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="toGenerate(ids[0])">
|
||||
<template #icon><icon-robot-add /></template>代码生成
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<right-toolbar
|
||||
v-model:show-query="showQuery"
|
||||
@refresh="getList"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表区域 -->
|
||||
@ -54,11 +36,6 @@
|
||||
row-key="tableName"
|
||||
:data="tableList"
|
||||
:loading="loading"
|
||||
:row-selection="{
|
||||
type: 'checkbox',
|
||||
showCheckedAll: true,
|
||||
onlyCurrent: false,
|
||||
}"
|
||||
:pagination="{
|
||||
showTotal: true,
|
||||
showPageSize: true,
|
||||
@ -71,7 +48,6 @@
|
||||
size="large"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<template #columns>
|
||||
<a-table-column title="序号">
|
||||
@ -103,13 +79,20 @@
|
||||
type="text"
|
||||
size="small"
|
||||
title="生成"
|
||||
@click="toGenerate(record.tableName)"
|
||||
@click="handleGenerate(record.tableName)"
|
||||
>
|
||||
<template #icon><icon-robot-add /></template>生成
|
||||
</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
<template #pagination-left>
|
||||
<a-tooltip content="刷新">
|
||||
<div class="action-icon" @click="handleQuery">
|
||||
<icon-refresh size="18" />
|
||||
</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
@ -138,8 +121,8 @@
|
||||
size="small"
|
||||
title="同步"
|
||||
:disabled="
|
||||
columnMappingList.length !== 0 &&
|
||||
columnMappingList[0].createTime === null
|
||||
fieldConfigList.length !== 0 &&
|
||||
fieldConfigList[0].createTime === null
|
||||
"
|
||||
>
|
||||
<template #icon><icon-sync /></template>同步
|
||||
@ -148,9 +131,9 @@
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
<a-table
|
||||
ref="columnMappingRef"
|
||||
:data="columnMappingList"
|
||||
:loading="columnMappingLoading"
|
||||
ref="fieldConfigRef"
|
||||
:data="fieldConfigList"
|
||||
:loading="fieldConfigLoading"
|
||||
:pagination="false"
|
||||
:bordered="false"
|
||||
size="large"
|
||||
@ -307,10 +290,10 @@
|
||||
import {
|
||||
TableRecord,
|
||||
TableParam,
|
||||
ColumnMappingRecord,
|
||||
FieldConfigRecord,
|
||||
GenConfigRecord,
|
||||
listTable,
|
||||
listColumnMapping,
|
||||
listFieldConfig,
|
||||
getGenConfig,
|
||||
GeneratorConfigRecord,
|
||||
saveConfig,
|
||||
@ -323,16 +306,13 @@
|
||||
);
|
||||
|
||||
const tableList = ref<TableRecord[]>([]);
|
||||
const columnMappingList = ref<ColumnMappingRecord[]>([]);
|
||||
const fieldConfigList = ref<FieldConfigRecord[]>([]);
|
||||
const total = ref(0);
|
||||
const ids = ref<Array<string>>([]);
|
||||
const title = ref('');
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const showQuery = ref(true);
|
||||
const loading = ref(false);
|
||||
const visible = ref(false);
|
||||
const columnMappingLoading = ref(false);
|
||||
const fieldConfigLoading = ref(false);
|
||||
|
||||
const data = reactive({
|
||||
// 查询参数
|
||||
@ -344,6 +324,7 @@
|
||||
},
|
||||
// 表单数据
|
||||
form: {} as GenConfigRecord,
|
||||
// 代码生成配置数据
|
||||
config: {} as GeneratorConfigRecord,
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
@ -385,8 +366,8 @@
|
||||
tableComment = tableComment ? `(${tableComment})` : ' ';
|
||||
title.value = `${tableName}${tableComment}配置`;
|
||||
visible.value = true;
|
||||
// 查询列映射信息
|
||||
getColumnMappingList(tableName, false);
|
||||
// 查询字段配置
|
||||
getFieldConfig(tableName, false);
|
||||
// 查询生成配置
|
||||
getGenConfig(tableName).then((res) => {
|
||||
form.value = res.data;
|
||||
@ -400,24 +381,23 @@
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const handleRefresh = (tableName: string) => {
|
||||
getColumnMappingList(tableName, true);
|
||||
getFieldConfig(tableName, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询列映射信息
|
||||
* 查询字段配置
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param requireSync 是否需要同步
|
||||
*/
|
||||
const getColumnMappingList = (tableName: string, requireSync: boolean) => {
|
||||
// 查询列映射信息
|
||||
columnMappingLoading.value = true;
|
||||
listColumnMapping(tableName, requireSync)
|
||||
const getFieldConfig = (tableName: string, requireSync: boolean) => {
|
||||
fieldConfigLoading.value = true;
|
||||
listFieldConfig(tableName, requireSync)
|
||||
.then((res) => {
|
||||
columnMappingList.value = res.data;
|
||||
fieldConfigList.value = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
columnMappingLoading.value = false;
|
||||
fieldConfigLoading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
@ -427,7 +407,7 @@
|
||||
const handleOk = () => {
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
config.value.columnMappings = columnMappingList.value;
|
||||
config.value.fieldConfigs = fieldConfigList.value;
|
||||
config.value.genConfig = form.value;
|
||||
saveConfig(form.value.tableName, config.value).then((res) => {
|
||||
handleCancel();
|
||||
@ -444,29 +424,18 @@
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
proxy.$refs.formRef?.resetFields();
|
||||
columnMappingList.value = [];
|
||||
fieldConfigList.value = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 代码生成
|
||||
* 生成代码
|
||||
*
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const toGenerate = (tableName: string) => {
|
||||
const handleGenerate = (tableName: string) => {
|
||||
proxy.$message.info('功能尚在开发中');
|
||||
};
|
||||
|
||||
/**
|
||||
* 已选择的数据行发生改变时触发
|
||||
*
|
||||
* @param rowKeys ID 列表
|
||||
*/
|
||||
const handleSelectionChange = (rowKeys: Array<any>) => {
|
||||
ids.value = rowKeys;
|
||||
single.value = rowKeys.length !== 1;
|
||||
multiple.value = !rowKeys.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@ -517,4 +486,13 @@
|
||||
:deep(.gen-config.arco-form) {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.action-icon {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.action-icon:hover {
|
||||
color: #0960bd;
|
||||
}
|
||||
</style>
|
||||
|
@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.common.model.vo.R;
|
||||
import top.charles7c.cnadmin.tool.model.entity.ColumnMappingDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||
import top.charles7c.cnadmin.tool.model.request.GenConfigRequest;
|
||||
@ -58,21 +58,21 @@ public class GeneratorController {
|
||||
return R.ok(generatorService.pageTable(query, pageQuery));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询字段配置列表", description = "查询字段配置列表")
|
||||
@GetMapping("/field/{tableName}")
|
||||
public R<List<FieldConfigDO>> listFieldConfig(@PathVariable String tableName,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
|
||||
return R.ok(generatorService.listFieldConfig(tableName, requireSync));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
|
||||
@GetMapping("/table/{tableName}")
|
||||
@GetMapping("/config/{tableName}")
|
||||
public R<GenConfigDO> getGenConfig(@PathVariable String tableName) throws SQLException {
|
||||
return R.ok(generatorService.getGenConfig(tableName));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询列映射信息列表", description = "查询列映射信息列表")
|
||||
@GetMapping("/column/{tableName}")
|
||||
public R<List<ColumnMappingDO>> listColumnMapping(@PathVariable String tableName,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
|
||||
return R.ok(generatorService.listColumnMapping(tableName, requireSync));
|
||||
}
|
||||
|
||||
@Operation(summary = "保存配置信息", description = "保存配置信息")
|
||||
@PostMapping("/table/{tableName}")
|
||||
@PostMapping("/config/{tableName}")
|
||||
public R saveConfig(@Validated @RequestBody GenConfigRequest request, @PathVariable String tableName) {
|
||||
generatorService.saveConfig(request, tableName);
|
||||
return R.ok("保存成功");
|
||||
|
@ -52,7 +52,7 @@ generator:
|
||||
- DATABASECHANGELOG
|
||||
- DATABASECHANGELOGLOCK
|
||||
- gen_config
|
||||
- gen_column_mapping
|
||||
- gen_field_config
|
||||
|
||||
--- ### 接口文档配置
|
||||
springdoc:
|
||||
|
@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS `gen_config` (
|
||||
PRIMARY KEY (`table_name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='生成配置表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gen_column_mapping` (
|
||||
CREATE TABLE IF NOT EXISTS `gen_field_config` (
|
||||
`table_name` varchar(64) NOT NULL COMMENT '表名称',
|
||||
`column_name` varchar(64) NOT NULL COMMENT '列名称',
|
||||
`column_type` varchar(25) NOT NULL COMMENT '列类型',
|
||||
@ -30,4 +30,4 @@ CREATE TABLE IF NOT EXISTS `gen_column_mapping` (
|
||||
`query_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '查询方式',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
INDEX `idx_table_name`(`table_name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='列映射表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字段配置表';
|
Loading…
Reference in New Issue
Block a user