Procházet zdrojové kódy

完成网关一对一demo

yjp před 1 rokem
rodič
revize
60596bee71

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

@@ -13,4 +13,5 @@ func InitRouter(builder *gateway.Builder) {
 	studentService(builder)
 	familyService(builder)
 	identityService(builder)
+	studentAndFamilyService(builder)
 }

+ 14 - 0
project/gateway/api/v1/demo_server/student_and_family.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 studentAndFamilyService(builder *gateway.Builder) {
+	gwtools.One2One(builder, &gwtools.One2OneParams{
+		ServiceVersionedUrl:  baseUrl,
+		LeftDomainCamelName:  "Student",
+		RightDomainCamelName: "Family",
+	})
+}

+ 35 - 0
project/gateway/main.go

@@ -42,6 +42,41 @@ import (
 // curl -X GET "http://localhost:32000/gateway/api/v1/identity/get?id=cc591981a91c412a9e20be5eec683121"
 // curl -X DELETE "http://localhost:32000/gateway/api/v1/identity/delete?id=cc591981a91c412a9e20be5eec683121"
 
+// Class-Student
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"a38786c698904224a6fc36a23c2eec1e", "studentIds": ["00254b4a7102429db35e6edc8e47a764"]}' "http://localhost:31000/example/api/v1/class/student/update"
+// curl -X GET "http://localhost:31000/example/api/v1/class/student/query?id=a38786c698904224a6fc36a23c2eec1e"
+
+// Student-Class
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"00254b4a7102429db35e6edc8e47a764", "classId": "a38786c698904224a6fc36a23c2eec1e"}' "http://localhost:31000/example/api/v1/student/class/update"
+// curl -X GET "http://localhost:31000/example/api/v1/student/class/query?id=00254b4a7102429db35e6edc8e47a764"
+// curl -X GET "http://localhost:31000/example/api/v1/student/class/queryWith?name=test"
+
+// Student-Family
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"33d5538ee04843b59db1560b7ab65427", "familyId": "848d175d04e74e64a90cc9ccb4f4fcaf"}' "http://localhost:31000/example/api/v1/student/family/update"
+// curl -X GET "http://localhost:31000/example/api/v1/student/family/query?id=33d5538ee04843b59db1560b7ab65427"
+// curl -X GET "http://localhost:31000/example/api/v1/student/family/queryWith?name=test"
+
+// Family-Student
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"848d175d04e74e64a90cc9ccb4f4fcaf", "studentId": "33d5538ee04843b59db1560b7ab65427"}' "http://localhost:31000/example/api/v1/family/student/update"
+// curl -X GET "http://localhost:31000/example/api/v1/family/student/query?id=848d175d04e74e64a90cc9ccb4f4fcaf"
+// 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"
+
+// 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"
+
+// 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"
+
+// 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 GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
+
 func main() {
 	api.NewGateway()
 	defer api.DestroyGateway()

+ 2 - 2
project/server/main.go

@@ -54,12 +54,12 @@ import (
 // Student-Family
 // curl -X POST -H "Content-Type: application/json" -d '{"id":"00254b4a7102429db35e6edc8e47a764", "familyId": "df3aeee04ce94c17878bbb5383d15f18"}' "http://localhost:31000/example/api/v1/student/family/update"
 // curl -X GET "http://localhost:31000/example/api/v1/student/family/query?id=00254b4a7102429db35e6edc8e47a764"
-// curl -X GET "http://localhost:31000/example/api/v1/student/family/queryWith?father=test"
+// curl -X GET "http://localhost:31000/example/api/v1/student/family/queryWith?name=test"
 
 // Family-Student
 // curl -X POST -H "Content-Type: application/json" -d '{"id":"df3aeee04ce94c17878bbb5383d15f18", "studentId": "00254b4a7102429db35e6edc8e47a764"}' "http://localhost:31000/example/api/v1/family/student/update"
 // curl -X GET "http://localhost:31000/example/api/v1/family/student/query?id=df3aeee04ce94c17878bbb5383d15f18"
-// curl -X GET "http://localhost:31000/example/api/v1/family/student/queryWith?father=test"
+// 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"