mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
feat: 添加 Kotlin 代码生成。
This commit is contained in:
parent
2c205fc8db
commit
b5a1ee6521
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2024, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.codegen.config;
|
package com.mybatisflex.codegen.config;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.template.ITemplate;
|
import com.mybatisflex.codegen.template.ITemplate;
|
||||||
|
|
||||||
@ -35,10 +36,16 @@ import java.util.function.UnaryOperator;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class GlobalConfig implements Serializable {
|
public class GlobalConfig implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5033600623041298000L;
|
private static final long serialVersionUID = 5033600623041298000L;
|
||||||
|
|
||||||
|
private final FileType fileType;
|
||||||
|
|
||||||
// === 必须配置 ===
|
// === 必须配置 ===
|
||||||
|
|
||||||
|
public GlobalConfig() {
|
||||||
|
this(FileType.JAVA);
|
||||||
|
}
|
||||||
private final JavadocConfig javadocConfig;
|
private final JavadocConfig javadocConfig;
|
||||||
private final PackageConfig packageConfig;
|
private final PackageConfig packageConfig;
|
||||||
private final StrategyConfig strategyConfig;
|
private final StrategyConfig strategyConfig;
|
||||||
@ -69,11 +76,46 @@ public class GlobalConfig implements Serializable {
|
|||||||
private boolean packageInfoGenerateEnable;
|
private boolean packageInfoGenerateEnable;
|
||||||
|
|
||||||
|
|
||||||
public GlobalConfig() {
|
public GlobalConfig(FileType fileType) {
|
||||||
|
this.fileType = fileType;
|
||||||
this.javadocConfig = new JavadocConfig();
|
this.javadocConfig = new JavadocConfig();
|
||||||
this.packageConfig = new PackageConfig();
|
this.packageConfig = new PackageConfig();
|
||||||
this.strategyConfig = new StrategyConfig();
|
this.strategyConfig = new StrategyConfig();
|
||||||
this.templateConfig = new TemplateConfig();
|
this.templateConfig = new TemplateConfig();
|
||||||
|
this.setTemplatePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileType getFileType() {
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTemplatePath() {
|
||||||
|
if (fileType == FileType.KOTLIN) {
|
||||||
|
setEntityTemplatePath(TemplateConst.ENTITY_KOTLIN);
|
||||||
|
setMapperTemplatePath(TemplateConst.MAPPER_KOTLIN);
|
||||||
|
setServiceTemplatePath(TemplateConst.SERVICE_KOTLIN);
|
||||||
|
setServiceImplTemplatePath(TemplateConst.SERVICE_IMPL_KOTLIN);
|
||||||
|
setControllerTemplatePath(TemplateConst.CONTROLLER_KOTLIN);
|
||||||
|
setTableDefTemplatePath(TemplateConst.TABLE_DEF_KOTLIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FileType {
|
||||||
|
|
||||||
|
JAVA(".java"),
|
||||||
|
KOTLIN(".kt");
|
||||||
|
|
||||||
|
private final String suffix;
|
||||||
|
|
||||||
|
FileType(String suffix) {
|
||||||
|
this.suffix = suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return suffix;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 分类配置 ===
|
// === 分类配置 ===
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user