Explorar el Código

完成多对多和关联实体

yjp hace 1 año
padre
commit
d4f9b5869b

+ 1 - 1
project/gateway/api/root/demo_server/configuration.go

@@ -9,5 +9,5 @@ func configurationService(builder *gateway.Builder) {
 	gwtools.CRUD(builder, &gwtools.CRUDParams{
 		ServiceVersionedUrl: baseUrl,
 		DomainCamelName:     "Configuration",
-	}, gwtools.WithDisableUpdate())
+	}, gwtools.WithCRUDDisableUpdate())
 }

+ 2 - 0
project/gateway/api/v1/demo_server/demo_server.go

@@ -14,4 +14,6 @@ func InitRouter(builder *gateway.Builder) {
 	familyService(builder)
 	identityService(builder)
 	studentAndFamilyService(builder)
+	studentAndIdentityService(builder)
+	studentAndHobbyService(builder)
 }

+ 14 - 0
project/gateway/api/v1/demo_server/student_and_hobby.go

@@ -0,0 +1,14 @@
+package demo_server
+
+import (
+	"git.sxidc.com/go-framework/baize/convenient/gwtools"
+	"git.sxidc.com/go-framework/baize/framework/gateway"
+)
+
+func studentAndHobbyService(builder *gateway.Builder) {
+	gwtools.Many2Many(builder, &gwtools.Many2ManyParams{
+		ServiceVersionedUrl:  baseUrl,
+		LeftDomainCamelName:  "Student",
+		RightDomainCamelName: "Hobby",
+	})
+}

+ 14 - 0
project/gateway/api/v1/demo_server/student_and_identity.go

@@ -0,0 +1,14 @@
+package demo_server
+
+import (
+	"git.sxidc.com/go-framework/baize/convenient/gwtools"
+	"git.sxidc.com/go-framework/baize/framework/gateway"
+)
+
+func studentAndIdentityService(builder *gateway.Builder) {
+	gwtools.Many2Many(builder, &gwtools.Many2ManyParams{
+		ServiceVersionedUrl:  baseUrl,
+		LeftDomainCamelName:  "Student",
+		RightDomainCamelName: "Identity",
+	})
+}

+ 7 - 7
project/gateway/main.go

@@ -62,19 +62,19 @@ import (
 // curl -X GET "http://localhost:31000/example/api/v1/family/student/queryWith?father=father"
 
 // Student-Identity
-// curl -X POST -H "Content-Type: application/json" -d '{"id":"00254b4a7102429db35e6edc8e47a764", "identityIds": ["4481fd110a5f46d2babe52b650981384"]}' "http://localhost:31000/example/api/v1/student/identity/update"
-// curl -X GET "http://localhost:31000/example/api/v1/student/identity/query?id=00254b4a7102429db35e6edc8e47a764"
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"7880acb4f5df40a2b98055d15858f13d", "identityIds": ["58ab7e64e8ea46b5982aedca0d2fa5d0"]}' "http://localhost:31000/example/api/v1/student/identity/update"
+// curl -X GET "http://localhost:31000/example/api/v1/student/identity/query?id=7880acb4f5df40a2b98055d15858f13d"
 
 // Identity-Student
-// curl -X POST -H "Content-Type: application/json" -d '{"id":"4481fd110a5f46d2babe52b650981384", "studentIds": ["00254b4a7102429db35e6edc8e47a764"]}' "http://localhost:31000/example/api/v1/identity/student/update"
-// curl -X GET "http://localhost:31000/example/api/v1/identity/student/query?id=4481fd110a5f46d2babe52b650981384"
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"58ab7e64e8ea46b5982aedca0d2fa5d0", "studentIds": ["7880acb4f5df40a2b98055d15858f13d"]}' "http://localhost:31000/example/api/v1/identity/student/update"
+// curl -X GET "http://localhost:31000/example/api/v1/identity/student/query?id=58ab7e64e8ea46b5982aedca0d2fa5d0"
 
 // Student-Hobby
-// curl -X POST -H "Content-Type: application/json" -d '{"id":"a3f28141a96e4cec850b485bd9c38813", "hobbyIds": ["42b305bb292c4082a3e91a2967f11111"]}' "http://localhost:31000/example/api/v1/student/hobby/update"
-// curl -X GET "http://localhost:31000/example/api/v1/student/hobby/query?id=a3f28141a96e4cec850b485bd9c38813"
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"7880acb4f5df40a2b98055d15858f13d", "hobbyIds": ["42b305bb292c4082a3e91a2967f11111"]}' "http://localhost:31000/example/api/v1/student/hobby/update"
+// curl -X GET "http://localhost:31000/example/api/v1/student/hobby/query?id=7880acb4f5df40a2b98055d15858f13d"
 
 // Hobby-Student
-// curl -X POST -H "Content-Type: application/json" -d '{"id":"42b305bb292c4082a3e91a2967f11111", "studentIds": ["00254b4a7102429db35e6edc8e47a764"]}' "http://localhost:31000/example/api/v1/hobby/student/update"
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"42b305bb292c4082a3e91a2967f11111", "studentIds": ["7880acb4f5df40a2b98055d15858f13d"]}' "http://localhost:31000/example/api/v1/hobby/student/update"
 // curl -X GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
 
 func main() {