فهرست منبع

完成一对多

yjp 1 سال پیش
والد
کامیت
ec9e16febb

+ 14 - 0
project/gateway/api/v1/demo_server/class_and_student.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 classAndStudentService(builder *gateway.Builder) {
+	gwtools.One2Many(builder, &gwtools.One2ManyParams{
+		ServiceVersionedUrl:  baseUrl,
+		LeftDomainCamelName:  "Class",
+		RightDomainCamelName: "Student",
+	})
+}

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

@@ -16,4 +16,5 @@ func InitRouter(builder *gateway.Builder) {
 	studentAndFamilyService(builder)
 	studentAndIdentityService(builder)
 	studentAndHobbyService(builder)
+	classAndStudentService(builder)
 }

+ 4 - 4
project/server/main.go

@@ -43,12 +43,12 @@ import (
 // curl -X DELETE "http://localhost:31000/example/api/v1/identity/delete?id=6e12ee71397746b8920fa94e5f229366"
 
 // 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"
+// curl -X POST -H "Content-Type: application/json" -d '{"id":"a365856f8440481ab7ccc93885620ad0", "studentIds": ["27b18d3ac2eb40adbdf9ba11b2e0e4b5"]}' "http://localhost:31000/example/api/v1/class/student/update"
+// curl -X GET "http://localhost:31000/example/api/v1/class/student/query?id=a365856f8440481ab7ccc93885620ad0"
 
 // 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 POST -H "Content-Type: application/json" -d '{"id":"27b18d3ac2eb40adbdf9ba11b2e0e4b5", "classId": "a365856f8440481ab7ccc93885620ad0"}' "http://localhost:31000/example/api/v1/student/class/update"
+// curl -X GET "http://localhost:31000/example/api/v1/student/class/query?id=27b18d3ac2eb40adbdf9ba11b2e0e4b5"
 // curl -X GET "http://localhost:31000/example/api/v1/student/class/queryWith?name=test"
 
 // Student-Family