|
|
@@ -0,0 +1,34 @@
|
|
|
+package service
|
|
|
+
|
|
|
+import (
|
|
|
+ "git.sxidc.com/go-framework/baize/convenient/relation/one2many"
|
|
|
+ "git.sxidc.com/go-framework/baize/examples/examples/project/application/domain/class"
|
|
|
+ "git.sxidc.com/go-framework/baize/examples/examples/project/application/domain/student"
|
|
|
+ "git.sxidc.com/go-framework/baize/framwork/application"
|
|
|
+)
|
|
|
+
|
|
|
+type ClassAndStudent struct{}
|
|
|
+
|
|
|
+func (app *ClassAndStudent) Init(appInstance *application.App) error {
|
|
|
+ app.v1(appInstance)
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (app *ClassAndStudent) Destroy() error {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (app *ClassAndStudent) v1(appInstance *application.App) {
|
|
|
+ v1Binder := appInstance.Binder(application.RouterPrefix, "v1")
|
|
|
+
|
|
|
+ one2many.BindSimple(v1Binder, &one2many.Simple[class.Info, student.Info]{
|
|
|
+ Left: &class.Entity{},
|
|
|
+ Right: &student.Entity{},
|
|
|
+ Schema: dbSchema,
|
|
|
+ LeftUpdateJsonBody: &class.UpdateStudentsOfClassJsonBody{},
|
|
|
+ LeftQueryQueryParams: &class.QueryStudentsOfClassQueryParams{},
|
|
|
+ RightUpdateJsonBody: &student.UpdateClassOfStudentJsonBody{},
|
|
|
+ RightQueryQueryParams: &student.QueryClassOfStudentQueryParams{},
|
|
|
+ RightQueryWithLeftQueryParams: &student.QueryStudentWithClassQueryParams{},
|
|
|
+ })
|
|
|
+}
|