class_and_student.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package service
  2. import (
  3. "baize-demo/project/server/application/domain/class"
  4. "baize-demo/project/server/application/domain/student"
  5. "git.sxidc.com/go-framework/baize/convenient/relation/one2many"
  6. "git.sxidc.com/go-framework/baize/framework/binding"
  7. "git.sxidc.com/go-framework/baize/framework/core/api"
  8. "git.sxidc.com/go-framework/baize/framework/core/application"
  9. )
  10. var classAndStudentService = &ClassAndStudentService{}
  11. type ClassAndStudentService struct{}
  12. func (svc *ClassAndStudentService) Init(appInstance *application.App) error {
  13. svc.v1(appInstance)
  14. return nil
  15. }
  16. func (svc *ClassAndStudentService) Destroy() error {
  17. return nil
  18. }
  19. func (svc *ClassAndStudentService) v1(appInstance *application.App) {
  20. v1Binder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, "v1"), appInstance.Infrastructure())
  21. one2many.BindSimple(v1Binder, &one2many.Simple[class.Info, student.Info]{
  22. Left: &class.Entity{},
  23. Right: &student.Entity{},
  24. Schema: dbSchema,
  25. LeftUpdateJsonBody: &class.UpdateStudentsOfClassJsonBody{},
  26. LeftQueryQueryParams: &class.QueryStudentsOfClassQueryParams{},
  27. RightUpdateJsonBody: &student.UpdateClassOfStudentJsonBody{},
  28. RightQueryQueryParams: &student.QueryClassOfStudentQueryParams{},
  29. RightQueryWithLeftQueryParams: &student.QueryStudentWithClassQueryParams{},
  30. })
  31. }