student_and_family.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "baize-demo/project/server/application/domain/family"
  4. "baize-demo/project/server/application/domain/student"
  5. "git.sxidc.com/go-framework/baize/convenient/relation/one2one"
  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 studentAndFamilyService = &StudentAndFamilyService{}
  11. type StudentAndFamilyService struct{}
  12. func (svc *StudentAndFamilyService) Init(appInstance *application.App) error {
  13. svc.v1(appInstance)
  14. return nil
  15. }
  16. func (svc *StudentAndFamilyService) Destroy() error {
  17. return nil
  18. }
  19. func (svc *StudentAndFamilyService) v1(appInstance *application.App) {
  20. v1Binder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, "v1"), appInstance.Infrastructure())
  21. one2one.BindSimple(v1Binder, &one2one.Simple[student.Info, family.Info]{
  22. Left: &student.Entity{},
  23. Right: &family.Entity{},
  24. Schema: dbSchema,
  25. LeftUpdateJsonBody: &student.UpdateFamilyOfStudentJsonBody{},
  26. LeftQueryQueryParams: &student.QueryFamilyOfStudentQueryParams{},
  27. LeftQueryWithRightQueryParams: &student.QueryStudentWithFamilyQueryParams{},
  28. RightUpdateJsonBody: &family.UpdateStudentOfFamilyJsonBody{},
  29. RightQueryQueryParams: &family.QueryStudentOfFamilyQueryParams{},
  30. RightQueryWithLeftQueryParams: &family.QueryFamilyWithStudentQueryParams{},
  31. })
  32. }