feat: use workspace setting service in frontend

This commit is contained in:
Steven
2023-09-12 21:34:05 +08:00
parent aa247ccef2
commit 8992d48b3e
11 changed files with 120 additions and 301 deletions

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"os"
storepb "github.com/boojack/slash/proto/gen/store"
"github.com/boojack/slash/server/profile"
"github.com/boojack/slash/store"
"github.com/h2non/filetype"
@@ -30,16 +31,16 @@ func (s *ResourceService) Register(g *echo.Group) {
ctx := c.Request().Context()
resourceID := c.Param("resourceId")
resourceRelativePathSetting, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
Key: store.WorkspaceResourceRelativePath,
Key: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_RESOURCE_RELATIVE_PATH,
})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "failed to workspace resource relative path setting").SetInternal(err)
}
if resourceRelativePathSetting == nil || resourceRelativePathSetting.Value == "" {
if resourceRelativePathSetting == nil {
return echo.NewHTTPError(http.StatusBadRequest, "found no workspace resource relative path setting")
}
resourceRelativePath := resourceRelativePathSetting.Value
resourceRelativePath := resourceRelativePathSetting.GetResourceRelativePath()
resourcePath := fmt.Sprintf("%s/%s", resourceRelativePath, resourceID)
buf, err := os.ReadFile(resourcePath)
if err != nil {