Skip to content

Commit f75e9c5

Browse files
author
Weasley
committed
- oracle等默认表字段大写的数据增加表名称大小写配置,减少性能开销
- mybatis-orm-support开关优化,当alphahub.dtt.is-enable=false时mybatis-orm-support设置为禁用 - mybatis-plus代码生成优化
1 parent 32d18cf commit f75e9c5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

dtt-spring-boot-starter/src/main/java/cn/alphahub/dtt/plus/config/support/MyBatisPlusCodeGeneratorConfigurer.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package cn.alphahub.dtt.plus.config.support;
22

33
import cn.alphahub.dtt.plus.config.DttProperties;
4+
import cn.alphahub.dtt.plus.entity.ContextWrapper;
45
import cn.alphahub.dtt.plus.entity.ModelEntity;
56
import cn.alphahub.dtt.plus.framework.ClassScanningProvider;
67
import cn.alphahub.dtt.plus.framework.annotations.EnableDtt;
7-
import cn.alphahub.dtt.plus.framework.core.DefaultJavaDocParser;
8+
import cn.alphahub.dtt.plus.framework.core.DttCommentParser;
89
import cn.alphahub.dtt.plus.framework.core.ParseFactory;
910
import lombok.AllArgsConstructor;
1011
import lombok.Builder;
@@ -78,10 +79,10 @@ public class MyBatisPlusCodeGeneratorConfigurer {
7879
* @return The class of mybatis-plus code generator
7980
*/
8081
@Bean
81-
@ConditionalOnBean({VelocityEngine.class, DefaultJavaDocParser.class, ClassScanningProvider.class})
82+
@ConditionalOnBean({VelocityEngine.class, ContextWrapper.class, ClassScanningProvider.class})
8283
public MyBatisPlusCodeGeneratorPlaceholder myBatisPlusCodeGeneratorPlaceholder(CodeGeneratorProperties cgProperties,
84+
ContextWrapper contextWrapper,
8385
VelocityEngine velocityEngine,
84-
DefaultJavaDocParser javaDocParser,
8586
ClassScanningProvider classScanningProvider
8687
) {
8788
MyBatisPlusCodeGeneratorPlaceholder placeholder = new MyBatisPlusCodeGeneratorPlaceholder();
@@ -97,7 +98,7 @@ public MyBatisPlusCodeGeneratorPlaceholder myBatisPlusCodeGeneratorPlaceholder(C
9798
return placeholder;
9899
}
99100

100-
List<MyBatisPlusCodeWrapper> codeWrappers = getMyBatisPlusCodeWrappers(cgProperties, javaDocParser, classScanningProvider);
101+
List<MyBatisPlusCodeWrapper> codeWrappers = getMyBatisPlusCodeWrappers(cgProperties, contextWrapper.getCommentParser(), classScanningProvider);
101102

102103
if (CollectionUtils.isEmpty(codeWrappers)) return placeholder;
103104

@@ -141,19 +142,19 @@ public MyBatisPlusCodeGeneratorPlaceholder myBatisPlusCodeGeneratorPlaceholder(C
141142
* Get mybatis-plus code wrappers
142143
*
143144
* @param cgProperties The given MyBatis-Plus code generation configuration properties
144-
* @param javaDocParser The java doc parser
145+
* @param commentParser The comment parser
145146
* @param classScanningProvider The Class scanning provider
146147
* @return mybatis-plus code wrappers
147148
*/
148-
private List<MyBatisPlusCodeWrapper> getMyBatisPlusCodeWrappers(CodeGeneratorProperties cgProperties, DefaultJavaDocParser javaDocParser, ClassScanningProvider classScanningProvider) {
149+
private List<MyBatisPlusCodeWrapper> getMyBatisPlusCodeWrappers(CodeGeneratorProperties cgProperties, DttCommentParser<ModelEntity> commentParser, ClassScanningProvider classScanningProvider) {
149150
List<MyBatisPlusCodeWrapper> codeWrappers = new ArrayList<>();
150151

151152
if (StringUtils.isNoneBlank(cgProperties.getBasePackage())) {
152153
codeWrappers = classScanningProvider.scanBasePackage(cgProperties.getBasePackage()).stream()
153154
.filter(className -> !className.getName().endsWith("Builder"))
154155
.map(aClass -> {
155156
String modelComment = "";
156-
ParseFactory<ModelEntity> parseFactory = javaDocParser.parse(aClass.getName());
157+
ParseFactory<ModelEntity> parseFactory = commentParser.parse(aClass.getName());
157158
if (null != parseFactory.getModel())
158159
modelComment = StringUtils.defaultIfBlank(parseFactory.getModel().getModelComment(), "");
159160
return MyBatisPlusCodeWrapper.builder()
@@ -168,7 +169,7 @@ private List<MyBatisPlusCodeWrapper> getMyBatisPlusCodeWrappers(CodeGeneratorPro
168169
if (ObjectUtils.isNotEmpty(cgProperties.getBaseClasses())) {
169170
for (Class<? extends Serializable> aClass : cgProperties.getBaseClasses()) {
170171
String modelComment = "";
171-
ParseFactory<ModelEntity> parseFactory = javaDocParser.parse(aClass.getName());
172+
ParseFactory<ModelEntity> parseFactory = commentParser.parse(aClass.getName());
172173
if (null != parseFactory.getModel())
173174
modelComment = StringUtils.defaultIfBlank(parseFactory.getModel().getModelComment(), "");
174175
codeWrappers.add(MyBatisPlusCodeWrapper.builder()

0 commit comments

Comments
 (0)