student_and_hobby.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package service
  2. import (
  3. "baize-demo/project/server/application/domain/hobby"
  4. "baize-demo/project/server/application/domain/student"
  5. "git.sxidc.com/go-framework/baize/convenient/relation/remote"
  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 studentAndHobbyService = &StudentAndHobbyService{}
  11. type StudentAndHobbyService struct{}
  12. func (svc *StudentAndHobbyService) Init(appInstance *application.App) error {
  13. svc.v1(appInstance)
  14. return nil
  15. }
  16. func (svc *StudentAndHobbyService) Destroy() error {
  17. return nil
  18. }
  19. func (svc *StudentAndHobbyService) v1(appInstance *application.App) {
  20. v1Binder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, "v1"), appInstance.Infrastructure())
  21. remote.BindSimple(v1Binder, &remote.Simple[student.Info, string]{
  22. Left: &student.Entity{},
  23. Right: &hobby.Entity{},
  24. Schema: dbSchema,
  25. LeftUpdateJsonBody: &student.UpdateHobbiesOfStudentJsonBody{},
  26. LeftQueryQueryParams: &student.QueryHobbiesOfStudentQueryParams{},
  27. RightUpdateJsonBody: &hobby.UpdateStudentsOfHobbyJsonBody{},
  28. RightQueryQueryParams: &hobby.QueryStudentsOfHobbyQueryParams{},
  29. })
  30. }