Skip to content

Commit 90d93a0

Browse files
committed
1. 驼峰命名和下划线的一些转换bug
1 parent 5100f64 commit 90d93a0

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/main/java/com/tml/otowbackend/engine/generator/template/java/InitTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private ServiceImplTemplate getServiceImplTemplate() {
156156
}
157157

158158
private ControllerTemplate getControllerTemplate() {
159-
ControllerTemplate userController = new ControllerTemplate(prefix + controllerPackagePath, className, "/" + className.toLowerCase());
159+
ControllerTemplate userController = new ControllerTemplate(prefix + controllerPackagePath, className, "/" + StringUtils.firstToLowerCase(className));
160160
userController.addService(serviceTemplate);
161161
String classLower = StringUtils.firstToLowerCase(serviceTemplate.getClassName());
162162
for (String featureId : featureIds) {

src/main/java/com/tml/otowbackend/engine/generator/template/java/service/ControllerTemplate.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.tml.otowbackend.engine.generator.template.java.service;
2+
23
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
34
import com.tml.otowbackend.engine.generator.template.java.ClassTemplate;
45
import com.tml.otowbackend.engine.generator.template.meta.MetaAnnotation;
@@ -33,19 +34,20 @@ public ControllerTemplate(String packagePath, String className, String urlPath)
3334
addAnnotation(new MetaAnnotation(RequestMapping.class, urlPath));
3435
}
3536

36-
public static String getControllerClassName(String className){
37-
return className+"Controller";
37+
public static String getControllerClassName(String className) {
38+
return className + "Controller";
3839
}
3940

4041
public String getUrlPath() {
4142
return urlPath;
4243
}
4344

44-
public void setCommonResult(String commonResult,Class<?> clazz){
45+
public void setCommonResult(String commonResult, Class<?> clazz) {
4546
this.commonResult = commonResult;
4647
addImportClazz(clazz);
4748
}
48-
public void addService(ServiceTemplate serviceTemplate){
49+
50+
public void addService(ServiceTemplate serviceTemplate) {
4951
this.services.add(serviceTemplate);
5052
String serviceClass = serviceTemplate.getClassName();
5153
String servicePackage = serviceTemplate.getAllPackagePath();
@@ -56,27 +58,28 @@ public void addService(ServiceTemplate serviceTemplate){
5658
this.addImportPath(servicePackage);
5759
}
5860

59-
public void addPostMethod(MetaMethod method, String path){
61+
public void addPostMethod(MetaMethod method, String path) {
6062
method.addAnnotations(List.of(new MetaAnnotation(PostMapping.class, path)));
6163
this.addMethod(method);
6264
}
6365

64-
public void addGetMethod(MetaMethod method, String path){
66+
public void addGetMethod(MetaMethod method, String path) {
6567
method.addAnnotations(List.of(new MetaAnnotation(GetMapping.class, path)));
6668
this.addMethod(method);
6769
}
6870

69-
public void addDeleteMethod(MetaMethod method, String path){
71+
public void addDeleteMethod(MetaMethod method, String path) {
7072
method.addAnnotations(List.of(new MetaAnnotation(DeleteMapping.class, path)));
7173
this.addMethod(method);
7274
}
7375

74-
public void addMethod(MetaMethod method){
76+
public void addMethod(MetaMethod method) {
7577
this.apiMethod.add(method);
7678
super.addMethod(method);
7779
}
80+
7881
@Override
79-
public void initAnnotations(){
82+
public void initAnnotations() {
8083
addAnnotations(MetaAnnotation.convertByClazz(CONTROLLER_ANNOTATION));
8184
}
8285
}

src/test/java/com/tml/otowbackend/GenerateTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tml.otowbackend;
22

33
import cn.hutool.core.bean.BeanUtil;
4+
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
45
import com.tml.otowbackend.engine.ai.result.EntityClassDefinition;
56
import com.tml.otowbackend.engine.generator.funpack.FuncPackManager;
67
import com.tml.otowbackend.engine.generator.template.java.InitConfigTemplate;
@@ -82,7 +83,7 @@ public void testGenerate() throws Exception {
8283
if (entityClassDefinitions != null) {
8384
for (EntityClassDefinition definition : entityClassDefinitions) {
8485
String className = definition.getClassName();
85-
String tableName = className.toLowerCase();
86+
String tableName = StringUtils.camelToUnderline(className);
8687
String describe = definition.getCdesc();
8788

8889
LinkedList<MetalField> fields = new LinkedList<>();

0 commit comments

Comments
 (0)