mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 09:38:26 +08:00
feat: 生成的每类文件,单独支持是否覆盖源文件。
This commit is contained in:
parent
ed1a3c0938
commit
0cc1ba76d8
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -39,6 +39,11 @@ public class ControllerConfig {
|
|||||||
*/
|
*/
|
||||||
private Class<?> supperClass;
|
private Class<?> supperClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成 REST 风格的 Controller。
|
* 生成 REST 风格的 Controller。
|
||||||
*/
|
*/
|
||||||
@ -79,6 +84,15 @@ public class ControllerConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRestStyle() {
|
public boolean isRestStyle() {
|
||||||
return restStyle;
|
return restStyle;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -41,6 +41,11 @@ public class EntityConfig {
|
|||||||
*/
|
*/
|
||||||
private Class<?> supperClass;
|
private Class<?> supperClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity 默认实现的接口。
|
* Entity 默认实现的接口。
|
||||||
*/
|
*/
|
||||||
@ -78,6 +83,15 @@ public class EntityConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Class<?>[] getImplInterfaces() {
|
public Class<?>[] getImplInterfaces() {
|
||||||
return implInterfaces;
|
return implInterfaces;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -41,6 +41,11 @@ public class MapperConfig {
|
|||||||
*/
|
*/
|
||||||
private Class<?> supperClass = BaseMapper.class;
|
private Class<?> supperClass = BaseMapper.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
public String buildSuperClassImport() {
|
public String buildSuperClassImport() {
|
||||||
return supperClass.getName();
|
return supperClass.getName();
|
||||||
}
|
}
|
||||||
@ -76,4 +81,13 @@ public class MapperConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapperConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -34,6 +34,11 @@ public class MapperXmlConfig {
|
|||||||
*/
|
*/
|
||||||
private String fileSuffix = "Mapper";
|
private String fileSuffix = "Mapper";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
public String getFilePrefix() {
|
public String getFilePrefix() {
|
||||||
return filePrefix;
|
return filePrefix;
|
||||||
}
|
}
|
||||||
@ -52,4 +57,13 @@ public class MapperXmlConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapperXmlConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -41,6 +41,11 @@ public class ServiceConfig {
|
|||||||
*/
|
*/
|
||||||
private Class<?> supperClass = IService.class;
|
private Class<?> supperClass = IService.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
public String buildSuperClassImport() {
|
public String buildSuperClassImport() {
|
||||||
return supperClass.getName();
|
return supperClass.getName();
|
||||||
}
|
}
|
||||||
@ -76,4 +81,13 @@ public class ServiceConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -41,6 +41,11 @@ public class ServiceImplConfig {
|
|||||||
*/
|
*/
|
||||||
private Class<?> supperClass = ServiceImpl.class;
|
private Class<?> supperClass = ServiceImpl.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
public String buildSuperClassImport() {
|
public String buildSuperClassImport() {
|
||||||
return supperClass.getName();
|
return supperClass.getName();
|
||||||
}
|
}
|
||||||
@ -76,4 +81,13 @@ public class ServiceImplConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceImplConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package com.mybatisflex.codegen.config;
|
package com.mybatisflex.codegen.config;
|
||||||
|
|
||||||
import com.mybatisflex.codegen.template.ITemplate;
|
|
||||||
import com.mybatisflex.codegen.template.impl.EnjoyTemplate;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -33,11 +30,6 @@ import java.util.Set;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class StrategyConfig {
|
public class StrategyConfig {
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用哪个模板引擎来生成代码。
|
|
||||||
*/
|
|
||||||
protected ITemplate templateEngine;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库表前缀,多个前缀用英文逗号(,) 隔开。
|
* 数据库表前缀,多个前缀用英文逗号(,) 隔开。
|
||||||
*/
|
*/
|
||||||
@ -58,11 +50,6 @@ public class StrategyConfig {
|
|||||||
*/
|
*/
|
||||||
private boolean generateForView;
|
private boolean generateForView;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否覆盖之前生成的文件。
|
|
||||||
*/
|
|
||||||
private boolean overwriteEnable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单独为某张表添加独立的配置。
|
* 单独为某张表添加独立的配置。
|
||||||
*/
|
*/
|
||||||
@ -185,18 +172,6 @@ public class StrategyConfig {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITemplate getTemplateEngine() {
|
|
||||||
if (templateEngine == null) {
|
|
||||||
templateEngine = new EnjoyTemplate();
|
|
||||||
}
|
|
||||||
return templateEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StrategyConfig setTemplateEngine(ITemplate templateEngine) {
|
|
||||||
this.templateEngine = templateEngine;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTablePrefix() {
|
public String getTablePrefix() {
|
||||||
return tablePrefix;
|
return tablePrefix;
|
||||||
}
|
}
|
||||||
@ -233,15 +208,6 @@ public class StrategyConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOverwriteEnable() {
|
|
||||||
return overwriteEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StrategyConfig setOverwriteEnable(boolean overwriteEnable) {
|
|
||||||
this.overwriteEnable = overwriteEnable;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, TableConfig> getTableConfigMap() {
|
public Map<String, TableConfig> getTableConfigMap() {
|
||||||
return tableConfigMap;
|
return tableConfigMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -34,6 +34,11 @@ public class TableDefConfig {
|
|||||||
*/
|
*/
|
||||||
private String classSuffix = "Def";
|
private String classSuffix = "Def";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否覆盖之前生成的文件。
|
||||||
|
*/
|
||||||
|
private boolean overwriteEnable;
|
||||||
|
|
||||||
public String getClassPrefix() {
|
public String getClassPrefix() {
|
||||||
return classPrefix;
|
return classPrefix;
|
||||||
}
|
}
|
||||||
@ -52,4 +57,13 @@ public class TableDefConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOverwriteEnable() {
|
||||||
|
return overwriteEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableDefConfig setOverwriteEnable(boolean overwriteEnable) {
|
||||||
|
this.overwriteEnable = overwriteEnable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.codegen.generator.impl;
|
package com.mybatisflex.codegen.generator.impl;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.ControllerConfig;
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,14 +52,14 @@ public class ControllerGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
ControllerConfig controllerConfig = globalConfig.getControllerConfig();
|
||||||
|
|
||||||
String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/");
|
String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/");
|
||||||
File controllerJavaFile = new File(packageConfig.getSourceDir(), controllerPackagePath + "/" +
|
File controllerJavaFile = new File(packageConfig.getSourceDir(), controllerPackagePath + "/" +
|
||||||
table.buildControllerClassName() + ".java");
|
table.buildControllerClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (controllerJavaFile.exists() && strategyConfig.isOverwriteEnable()) {
|
if (controllerJavaFile.exists() && controllerConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class ControllerGenerator implements IGenerator {
|
|||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("controllerConfig", controllerConfig);
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
params.put("controllerConfig", globalConfig.getControllerConfig());
|
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, controllerJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, controllerJavaFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.codegen.generator.impl;
|
package com.mybatisflex.codegen.generator.impl;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,22 +52,22 @@ public class EntityGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/");
|
String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/");
|
||||||
File entityJavaFile = new File(packageConfig.getSourceDir(), entityPackagePath + "/" +
|
File entityJavaFile = new File(packageConfig.getSourceDir(), entityPackagePath + "/" +
|
||||||
table.buildEntityClassName() + ".java");
|
table.buildEntityClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (entityJavaFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (entityJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
params.put("entityConfig", globalConfig.getEntityConfig());
|
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, entityJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, entityJavaFile);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -16,8 +16,8 @@
|
|||||||
package com.mybatisflex.codegen.generator.impl;
|
package com.mybatisflex.codegen.generator.impl;
|
||||||
|
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.MapperConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,22 +52,22 @@ public class MapperGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
MapperConfig mapperConfig = globalConfig.getMapperConfig();
|
||||||
|
|
||||||
String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/");
|
String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/");
|
||||||
File mapperJavaFile = new File(packageConfig.getSourceDir(), mapperPackagePath + "/" +
|
File mapperJavaFile = new File(packageConfig.getSourceDir(), mapperPackagePath + "/" +
|
||||||
table.buildMapperClassName() + ".java");
|
table.buildMapperClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (mapperJavaFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (mapperJavaFile.exists() && !mapperConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
|
params.put("mapperConfig", mapperConfig);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
params.put("mapperConfig", globalConfig.getMapperConfig());
|
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, mapperJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, mapperJavaFile);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -16,8 +16,8 @@
|
|||||||
package com.mybatisflex.codegen.generator.impl;
|
package com.mybatisflex.codegen.generator.impl;
|
||||||
|
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.MapperXmlConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,13 +52,13 @@ public class MapperXmlGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
MapperXmlConfig mapperXmlConfig = globalConfig.getMapperXmlConfig();
|
||||||
|
|
||||||
File mapperXmlFile = new File(packageConfig.getMapperXmlPath() + "/" +
|
File mapperXmlFile = new File(packageConfig.getMapperXmlPath() + "/" +
|
||||||
table.buildMapperXmlFileName() + ".xml");
|
table.buildMapperXmlFileName() + ".xml");
|
||||||
|
|
||||||
|
|
||||||
if (mapperXmlFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (mapperXmlFile.exists() && !mapperXmlConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -17,7 +17,7 @@ package com.mybatisflex.codegen.generator.impl;
|
|||||||
|
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
import com.mybatisflex.codegen.config.ServiceConfig;
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,22 +52,22 @@ public class ServiceGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
ServiceConfig serviceConfig = globalConfig.getServiceConfig();
|
||||||
|
|
||||||
String servicePackagePath = packageConfig.getServicePackage().replace(".", "/");
|
String servicePackagePath = packageConfig.getServicePackage().replace(".", "/");
|
||||||
File serviceJavaFile = new File(packageConfig.getSourceDir(), servicePackagePath + "/" +
|
File serviceJavaFile = new File(packageConfig.getSourceDir(), servicePackagePath + "/" +
|
||||||
table.buildServiceClassName() + ".java");
|
table.buildServiceClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (serviceJavaFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (serviceJavaFile.exists() && !serviceConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
|
params.put("serviceConfig", serviceConfig);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
params.put("serviceConfig", globalConfig.getServiceConfig());
|
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, serviceJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, serviceJavaFile);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -17,7 +17,7 @@ package com.mybatisflex.codegen.generator.impl;
|
|||||||
|
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
import com.mybatisflex.codegen.config.ServiceImplConfig;
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,14 +52,14 @@ public class ServiceImplGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
|
||||||
|
|
||||||
String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/");
|
String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/");
|
||||||
File serviceImplJavaFile = new File(packageConfig.getSourceDir(), serviceImplPackagePath + "/" +
|
File serviceImplJavaFile = new File(packageConfig.getSourceDir(), serviceImplPackagePath + "/" +
|
||||||
table.buildServiceImplClassName() + ".java");
|
table.buildServiceImplClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (serviceImplJavaFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (serviceImplJavaFile.exists() && !serviceImplConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class ServiceImplGenerator implements IGenerator {
|
|||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("serviceImplConfig", serviceImplConfig);
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
params.put("serviceImplConfig", globalConfig.getServiceImplConfig());
|
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, serviceImplJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, serviceImplJavaFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, 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");
|
||||||
@ -17,7 +17,7 @@ package com.mybatisflex.codegen.generator.impl;
|
|||||||
|
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.config.PackageConfig;
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
import com.mybatisflex.codegen.config.StrategyConfig;
|
import com.mybatisflex.codegen.config.TableDefConfig;
|
||||||
import com.mybatisflex.codegen.constant.TemplateConst;
|
import com.mybatisflex.codegen.constant.TemplateConst;
|
||||||
import com.mybatisflex.codegen.entity.Table;
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
import com.mybatisflex.codegen.generator.IGenerator;
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
@ -52,14 +52,14 @@ public class TableDefGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
TableDefConfig tableDefConfig = globalConfig.getTableDefConfig();
|
||||||
|
|
||||||
String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/");
|
String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/");
|
||||||
File tableDefJavaFile = new File(packageConfig.getSourceDir(), tableDefPackagePath + "/" +
|
File tableDefJavaFile = new File(packageConfig.getSourceDir(), tableDefPackagePath + "/" +
|
||||||
table.buildTableDefClassName() + ".java");
|
table.buildTableDefClassName() + ".java");
|
||||||
|
|
||||||
|
|
||||||
if (tableDefJavaFile.exists() && !strategyConfig.isOverwriteEnable()) {
|
if (tableDefJavaFile.exists() && !tableDefConfig.isOverwriteEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class TableDefGenerator implements IGenerator {
|
|||||||
Map<String, Object> params = new HashMap<>(4);
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
params.put("table", table);
|
params.put("table", table);
|
||||||
params.put("packageConfig", packageConfig);
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("tableDefConfig", tableDefConfig);
|
||||||
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
params.put("tableDefConfig", globalConfig.getTableDefConfig());
|
|
||||||
|
|
||||||
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, tableDefJavaFile);
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, tableDefJavaFile);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user