student_and_identity.go 1.3 KB

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