version.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "git.sxidc.com/go-framework/baize/framework/binding"
  4. "git.sxidc.com/go-framework/baize/framework/core/api/request"
  5. "git.sxidc.com/go-framework/baize/framework/core/api/response"
  6. "git.sxidc.com/go-framework/baize/framework/core/api"
  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, ""),
  22. appInstance.Infrastructure())
  23. binding.GetBind(prefixRootBinder, &binding.SimpleBindItem[map[string]any]{
  24. Path: "/version",
  25. SendResponseFunc: response.SendMapResponse,
  26. ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
  27. return map[string]any{
  28. "version": "v1.0.0",
  29. }, nil
  30. },
  31. })
  32. }