Browse Source

修改idbug

yjp 3 months ago
parent
commit
5125889f23
1 changed files with 9 additions and 13 deletions
  1. 9 13
      template/template_func.go

+ 9 - 13
template/template_func.go

@@ -63,19 +63,15 @@ func UpperShort(s string) string {
 }
 
 func Id(s string) string {
-	if s == "ID" {
-		return "id"
-	}
-
-	if strings.Contains(s, "ID") {
+	if strings.HasSuffix(s, "ID") {
 		return strings.ReplaceAll(s, "ID", "Id")
 	}
 
-	if strings.Contains(s, "id") {
+	if strings.HasSuffix(s, "id") {
 		return strings.ReplaceAll(s, "id", "Id")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "Id")
 	}
 
@@ -83,15 +79,15 @@ func Id(s string) string {
 }
 
 func ID(s string) string {
-	if strings.Contains(s, "Id") {
+	if strings.HasSuffix(s, "Id") {
 		return strings.ReplaceAll(s, "Id", "ID")
 	}
 
-	if strings.Contains(s, "id") {
+	if strings.HasSuffix(s, "id") {
 		return strings.ReplaceAll(s, "id", "ID")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "ID")
 	}
 
@@ -99,15 +95,15 @@ func ID(s string) string {
 }
 
 func id(s string) string {
-	if strings.Contains(s, "Id") {
+	if strings.HasSuffix(s, "Id") {
 		return strings.ReplaceAll(s, "Id", "id")
 	}
 
-	if strings.Contains(s, "ID") {
+	if strings.HasSuffix(s, "ID") {
 		return strings.ReplaceAll(s, "ID", "id")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "id")
 	}