version.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package service
  2. import (
  3. "git.sxidc.com/go-framework/baize/framework/binding"
  4. "git.sxidc.com/go-framework/baize/framework/core/api"
  5. "git.sxidc.com/go-framework/baize/framework/core/api/request"
  6. "git.sxidc.com/go-framework/baize/framework/core/api/response"
  7. "git.sxidc.com/go-framework/baize/framework/core/application"
  8. "git.sxidc.com/go-framework/baize/framework/core/domain"
  9. "git.sxidc.com/go-framework/baize/framework/core/infrastructure"
  10. )
  11. var versionService = &VersionService{}
  12. type VersionService struct{}
  13. func (svc *VersionService) Init(appInstance *application.App) error {
  14. svc.prefixRoot(appInstance)
  15. return nil
  16. }
  17. func (svc *VersionService) Destroy() error {
  18. return nil
  19. }
  20. func (svc *VersionService) prefixRoot(appInstance *application.App) {
  21. prefixRootBinder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, ""), appInstance.Infrastructure())
  22. binding.GetBind(prefixRootBinder, &binding.SimpleBindItem[map[string]any]{
  23. Path: "/version",
  24. SendResponseFunc: response.SendMapResponse,
  25. ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
  26. return map[string]any{
  27. "version": "v1.0.0",
  28. }, nil
  29. },
  30. })
  31. }