feat: 新增保存代码生成配置信息接口
This commit is contained in:
parent
abae964970
commit
0fae13e779
@ -16,10 +16,6 @@
|
||||
|
||||
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.tool.model.entity.GenConfigDO;
|
||||
|
||||
@ -29,14 +25,4 @@ import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
* @author Charles7c
|
||||
* @since 2023/4/12 23:56
|
||||
*/
|
||||
public interface GenConfigMapper extends BaseMapper<GenConfigDO> {
|
||||
|
||||
/**
|
||||
* 查询推荐作者名
|
||||
*
|
||||
* @param lessThanDate
|
||||
* 截止时间
|
||||
* @return 推荐作者名
|
||||
*/
|
||||
String selectRecommendAuthor(@Param("lessThanDate") Date lessThanDate);
|
||||
}
|
||||
public interface GenConfigMapper extends BaseMapper<GenConfigDO> {}
|
||||
|
@ -19,14 +19,16 @@ package top.charles7c.cnadmin.tool.model.entity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -44,47 +46,46 @@ import top.charles7c.cnadmin.tool.enums.FormTypeEnum;
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_column_mapping")
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "列映射信息")
|
||||
public class ColumnMappingDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@Schema(description = "表名称")
|
||||
@NotBlank(message = "表名称不能为空")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
@Schema(description = "列名称")
|
||||
@NotBlank(message = "列名称不能为空")
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
@Schema(description = "列类型")
|
||||
@NotBlank(message = "列类型不能为空")
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
@Schema(description = "字段名称")
|
||||
@NotBlank(message = "字段名称不能为空")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*/
|
||||
@Schema(description = "字段类型")
|
||||
@NotBlank(message = "字段类型不能为空")
|
||||
private String fieldType;
|
||||
|
||||
/**
|
||||
@ -93,12 +94,6 @@ public class ColumnMappingDO implements Serializable {
|
||||
@Schema(description = "注释")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*/
|
||||
@ -142,12 +137,9 @@ public class ColumnMappingDO implements Serializable {
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
public ColumnMappingDO(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public ColumnMappingDO setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
|
@ -19,15 +19,16 @@ package top.charles7c.cnadmin.tool.model.entity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
/**
|
||||
* 生成配置实体
|
||||
@ -37,35 +38,33 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_config")
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "生成配置信息")
|
||||
public class GenConfigDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@Schema(description = "表名称")
|
||||
@NotBlank(message = "表名称不能为空")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
@Schema(description = "模块名称")
|
||||
@NotBlank(message = "模块名称不能为空")
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 包名称
|
||||
*/
|
||||
@Schema(description = "包名称")
|
||||
@NotBlank(message = "包名称不能为空")
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
@ -78,12 +77,14 @@ public class GenConfigDO implements Serializable {
|
||||
* 业务名称
|
||||
*/
|
||||
@Schema(description = "业务名称")
|
||||
@NotBlank(message = "业务名称不能为空")
|
||||
private String businessName;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
@Schema(description = "作者")
|
||||
@NotBlank(message = "作者名称不能为空")
|
||||
private String author;
|
||||
|
||||
/**
|
||||
@ -96,6 +97,7 @@ public class GenConfigDO implements Serializable {
|
||||
* 是否覆盖
|
||||
*/
|
||||
@Schema(description = "是否覆盖")
|
||||
@NotNull(message = "是否覆盖不能为空")
|
||||
private Boolean isOverride;
|
||||
|
||||
/**
|
||||
@ -111,4 +113,8 @@ public class GenConfigDO implements Serializable {
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
public GenConfigDO(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.tool.model.request;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.GenConfigDO;
|
||||
|
||||
/**
|
||||
* 代码生成配置信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/8/8 20:40
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "代码生成配置信息")
|
||||
public class GenConfigRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 列映射信息列表
|
||||
*/
|
||||
@Schema(description = "列映射信息列表")
|
||||
private List<ColumnMappingDO> columnMappings = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 生成配置信息
|
||||
*/
|
||||
@Schema(description = "生成配置信息")
|
||||
private GenConfigDO genConfig;
|
||||
}
|
@ -24,6 +24,7 @@ import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
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.request.GenConfigRequest;
|
||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||
|
||||
/**
|
||||
@ -66,4 +67,14 @@ public interface GeneratorService {
|
||||
* @return 列映射信息列表
|
||||
*/
|
||||
List<ColumnMappingDO> listColumnMapping(String tableName);
|
||||
|
||||
/**
|
||||
* 保存代码生成配置信息
|
||||
*
|
||||
* @param request
|
||||
* 代码生成配置信息
|
||||
* @param tableName
|
||||
* 表名称
|
||||
*/
|
||||
void saveConfig(GenConfigRequest request, String tableName);
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.db.meta.Column;
|
||||
@ -41,6 +41,7 @@ import top.charles7c.cnadmin.common.constant.StringConsts;
|
||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
||||
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.enums.FormTypeEnum;
|
||||
import top.charles7c.cnadmin.tool.mapper.ColumnMappingMapper;
|
||||
@ -48,6 +49,7 @@ import top.charles7c.cnadmin.tool.mapper.GenConfigMapper;
|
||||
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.request.GenConfigRequest;
|
||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
||||
import top.charles7c.cnadmin.tool.util.MetaUtils;
|
||||
@ -83,21 +85,25 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
@Override
|
||||
public GenConfigDO getGenConfig(String tableName) throws SQLException {
|
||||
GenConfigDO genConfig =
|
||||
genConfigMapper.selectOne(Wrappers.lambdaQuery(GenConfigDO.class).eq(GenConfigDO::getTableName, tableName));
|
||||
GenConfigDO genConfig = genConfigMapper.selectById(tableName);
|
||||
if (null == genConfig) {
|
||||
genConfig = new GenConfigDO().setTableName(tableName);
|
||||
genConfig = new GenConfigDO(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);
|
||||
// 默认作者名称(上次保存使用的作者名称)
|
||||
GenConfigDO lastGenConfig = genConfigMapper.selectOne(
|
||||
Wrappers.lambdaQuery(GenConfigDO.class).orderByDesc(GenConfigDO::getCreateTime).last("LIMIT 1"));
|
||||
if (null != lastGenConfig) {
|
||||
genConfig.setAuthor(lastGenConfig.getAuthor());
|
||||
}
|
||||
// 默认表前缀(sys_user -> sys_)
|
||||
int underLineIndex = StrUtil.indexOf(tableName, StringConsts.C_UNDERLINE);
|
||||
if (-1 != underLineIndex) {
|
||||
genConfig.setTablePrefix(StrUtil.subPre(tableName, underLineIndex + 1));
|
||||
@ -116,10 +122,10 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
for (Column column : columnList) {
|
||||
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConsts.SPACE)[0];
|
||||
boolean isRequired = !column.isPk() && !column.isNullable();
|
||||
ColumnMappingDO columnMapping = new ColumnMappingDO().setTableName(tableName)
|
||||
.setColumnName(column.getName()).setColumnType(columnType.toLowerCase())
|
||||
.setComment(column.getComment()).setIsRequired(isRequired).setShowInList(true)
|
||||
.setShowInForm(isRequired).setShowInQuery(isRequired).setFormType(FormTypeEnum.TEXT);
|
||||
ColumnMappingDO columnMapping = new ColumnMappingDO(tableName).setColumnName(column.getName())
|
||||
.setColumnType(columnType.toLowerCase()).setComment(column.getComment()).setIsRequired(isRequired)
|
||||
.setShowInList(true).setShowInForm(isRequired).setShowInQuery(isRequired)
|
||||
.setFormType(FormTypeEnum.TEXT);
|
||||
columnMapping.setQueryType(
|
||||
"String".equals(columnMapping.getFieldType()) ? QueryTypeEnum.INNER_LIKE : QueryTypeEnum.EQUAL);
|
||||
columnMappingList.add(columnMapping);
|
||||
@ -127,4 +133,44 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
}
|
||||
return columnMappingList;
|
||||
}
|
||||
|
||||
@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());
|
||||
} else {
|
||||
// 在表单中不显示,不需要设置必填
|
||||
columnMapping.setIsRequired(false);
|
||||
}
|
||||
if (columnMapping.getShowInQuery()) {
|
||||
CheckUtils.throwIfNull(columnMapping.getFormType(), "字段 [{}] 的表单类型不能为空", columnMapping.getFieldName());
|
||||
CheckUtils.throwIfNull(columnMapping.getQueryType(), "字段 [{}] 的查询方式不能为空", columnMapping.getFieldName());
|
||||
} else {
|
||||
// 在查询中不显示,不需要设置查询方式
|
||||
columnMapping.setQueryType(null);
|
||||
}
|
||||
// 既不在表单也不在查询中显示,不需要设置表单类型
|
||||
if (!columnMapping.getShowInForm() && !columnMapping.getShowInQuery()) {
|
||||
columnMapping.setFormType(null);
|
||||
}
|
||||
columnMapping.setTableName(tableName);
|
||||
}
|
||||
columnMappingMapper.insertBatch(columnMappingList);
|
||||
|
||||
// 保存或更新生成配置信息
|
||||
GenConfigDO newGenConfig = request.getGenConfig();
|
||||
GenConfigDO oldGenConfig = genConfigMapper.selectById(tableName);
|
||||
if (null != oldGenConfig) {
|
||||
BeanUtil.copyProperties(newGenConfig, oldGenConfig);
|
||||
genConfigMapper.updateById(oldGenConfig);
|
||||
} else {
|
||||
genConfigMapper.insert(newGenConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="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>
|
@ -30,14 +30,12 @@ export function listTable(params: TableParam) {
|
||||
}
|
||||
|
||||
export interface ColumnMappingRecord {
|
||||
id: string;
|
||||
tableName: string;
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
fieldName: string;
|
||||
fieldType: string;
|
||||
comment: string;
|
||||
sort: number;
|
||||
isRequired: boolean;
|
||||
showInList: boolean;
|
||||
showInForm: boolean;
|
||||
@ -53,7 +51,6 @@ export function listColumnMapping(tableName: string) {
|
||||
}
|
||||
|
||||
export interface GenConfigRecord {
|
||||
id: string;
|
||||
tableName: string;
|
||||
moduleName: string;
|
||||
packageName: string;
|
||||
@ -69,3 +66,12 @@ export interface GenConfigRecord {
|
||||
export function getGenConfig(tableName: string) {
|
||||
return axios.get<GenConfigRecord>(`${BASE_URL}/table/${tableName}`);
|
||||
}
|
||||
|
||||
export interface GeneratorConfigRecord {
|
||||
genConfig: GenConfigRecord;
|
||||
columnMappings: ColumnMappingRecord[];
|
||||
}
|
||||
|
||||
export function saveConfig(tableName: string, req: GeneratorConfigRecord) {
|
||||
return axios.post(`${BASE_URL}/table/${tableName}`, req);
|
||||
}
|
||||
|
@ -153,14 +153,14 @@
|
||||
<a-table-column
|
||||
title="名称"
|
||||
data-index="fieldName"
|
||||
:width="130"
|
||||
:width="125"
|
||||
ellipsis
|
||||
tooltip
|
||||
/>
|
||||
<a-table-column
|
||||
title="类型"
|
||||
data-index="fieldType"
|
||||
:width="90"
|
||||
:width="95"
|
||||
ellipsis
|
||||
tooltip
|
||||
/>
|
||||
@ -303,6 +303,8 @@
|
||||
listTable,
|
||||
listColumnMapping,
|
||||
getGenConfig,
|
||||
GeneratorConfigRecord,
|
||||
saveConfig,
|
||||
} from '@/api/tool/generator';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
@ -333,15 +335,16 @@
|
||||
},
|
||||
// 表单数据
|
||||
form: {} as GenConfigRecord,
|
||||
config: {} as GeneratorConfigRecord,
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
author: [{ required: true, message: '请输入作者名称' }],
|
||||
moduleName: [{ required: true, message: '请输入模块名称' }],
|
||||
packageName: [{ required: true, message: '请输入包名称' }],
|
||||
moduleName: [{ required: true, message: '请输入所属模块' }],
|
||||
packageName: [{ required: true, message: '请输入模块包名' }],
|
||||
businessName: [{ required: true, message: '请输入业务名称' }],
|
||||
},
|
||||
});
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const { queryParams, form, rules, config } = toRefs(data);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
@ -393,8 +396,17 @@
|
||||
* 确定
|
||||
*/
|
||||
const handleOk = () => {
|
||||
visible.value = false;
|
||||
proxy.$message.info('功能尚在开发中');
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
config.value.columnMappings = columnMappingList.value;
|
||||
config.value.genConfig = form.value;
|
||||
saveConfig(form.value.tableName, config.value).then((res) => {
|
||||
handleCancel();
|
||||
getList();
|
||||
proxy.$message.success(res.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -402,6 +414,8 @@
|
||||
*/
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
proxy.$refs.formRef?.resetFields();
|
||||
columnMappingList.value = [];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -410,7 +424,7 @@
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const toGenerate = (tableName: string) => {
|
||||
proxy.$message.info(tableName);
|
||||
proxy.$message.info('功能尚在开发中');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -25,10 +25,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
@ -36,6 +33,7 @@ import top.charles7c.cnadmin.common.model.vo.R;
|
||||
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.request.GenConfigRequest;
|
||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
||||
|
||||
@ -71,4 +69,11 @@ public class GeneratorController {
|
||||
public R<List<ColumnMappingDO>> listColumnMapping(@PathVariable String tableName) {
|
||||
return R.ok(generatorService.listColumnMapping(tableName));
|
||||
}
|
||||
|
||||
@Operation(summary = "保存配置信息", description = "保存配置信息")
|
||||
@PostMapping("/table/{tableName}")
|
||||
public R saveConfig(@Validated @RequestBody GenConfigRequest request, @PathVariable String tableName) {
|
||||
generatorService.saveConfig(request, tableName);
|
||||
return R.ok("保存成功");
|
||||
}
|
||||
}
|
||||
|
@ -2,30 +2,26 @@
|
||||
|
||||
-- changeset Charles7c:1
|
||||
CREATE TABLE IF NOT EXISTS `gen_config` (
|
||||
`id` bigint(20) UNSIGNED AUTO_INCREMENT COMMENT 'ID',
|
||||
`table_name` varchar(100) NOT NULL COMMENT '表名称',
|
||||
`table_name` varchar(100) COMMENT '表名称',
|
||||
`module_name` varchar(50) NOT NULL COMMENT '模块名称',
|
||||
`package_name` varchar(50) NOT NULL COMMENT '包名称',
|
||||
`frontend_path` varchar(255) NOT NULL COMMENT '前端路径',
|
||||
`frontend_path` varchar(255) DEFAULT NULL COMMENT '前端路径',
|
||||
`business_name` varchar(50) NOT NULL COMMENT '业务名称',
|
||||
`author` varchar(100) NOT NULL COMMENT '作者',
|
||||
`table_prefix` varchar(20) DEFAULT NULL COMMENT '表前缀',
|
||||
`is_override` bit(1) DEFAULT b'0' COMMENT '是否覆盖',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_table_name`(`table_name`) USING BTREE
|
||||
PRIMARY KEY (`table_name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='生成配置表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gen_column_mapping` (
|
||||
`id` bigint(20) UNSIGNED AUTO_INCREMENT COMMENT 'ID',
|
||||
`table_name` varchar(100) NOT NULL COMMENT '表名称',
|
||||
`column_name` varchar(50) NOT NULL COMMENT '列名称',
|
||||
`column_type` varchar(25) NOT NULL COMMENT '列类型',
|
||||
`field_name` varchar(50) NOT NULL COMMENT '字段名称',
|
||||
`field_type` varchar(25) NOT NULL COMMENT '字段类型',
|
||||
`comment` varchar(512) DEFAULT NULL COMMENT '注释',
|
||||
`sort` int(11) UNSIGNED DEFAULT 999 COMMENT '排序',
|
||||
`is_required` bit(1) DEFAULT b'1' COMMENT '是否必填',
|
||||
`show_in_list` bit(1) DEFAULT b'1' COMMENT '是否在列表中显示',
|
||||
`show_in_form` bit(1) DEFAULT b'1' COMMENT '是否在表单中显示',
|
||||
@ -33,7 +29,5 @@ CREATE TABLE IF NOT EXISTS `gen_column_mapping` (
|
||||
`form_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '表单类型',
|
||||
`query_type` tinyint(1) UNSIGNED DEFAULT NULL COMMENT '查询方式',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_table_name`(`table_name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='列映射表';
|
Loading…
Reference in New Issue
Block a user