Skip to content

Commit

Permalink
文件上传、删除、预览功能实现 (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
veeding authored and hetao92 committed May 26, 2022
1 parent 09a4b20 commit ace6164
Show file tree
Hide file tree
Showing 13 changed files with 498 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server-v2/api/studio/etc/studio-api.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Name: studio-api
Host: 0.0.0.0
Port: 7002
MaxBytes: 1073741824
Debug:
Enable: false
Auth:
AccessSecret: "login_secret"
AccessExpire: 7200
File:
UploadDir: "./upload/"
4 changes: 4 additions & 0 deletions server-v2/api/studio/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ type Config struct {
AccessSecret string
AccessExpire int64
}

File struct {
UploadDir string
}
}
33 changes: 33 additions & 0 deletions server-v2/api/studio/internal/handler/file/filedestroyhandler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions server-v2/api/studio/internal/handler/file/filesindexhandler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions server-v2/api/studio/internal/handler/file/fileuploadhandler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions server-v2/api/studio/internal/handler/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions server-v2/api/studio/internal/logic/file/filedestroylogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package file

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type FileDestroyLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewFileDestroyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FileDestroyLogic {
return &FileDestroyLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *FileDestroyLogic) FileDestroy(req types.FileDestroyRequest) error {
return service.NewFileService(nil, l.ctx, l.svcCtx).FileDestroy(req.Name)
}
29 changes: 29 additions & 0 deletions server-v2/api/studio/internal/logic/file/filesindexlogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package file

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type FilesIndexLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewFilesIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FilesIndexLogic {
return &FilesIndexLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *FilesIndexLogic) FilesIndex() (resp *types.FilesIndexData, err error) {
return service.NewFileService(nil, l.ctx, l.svcCtx).FilesIndex()
}
27 changes: 27 additions & 0 deletions server-v2/api/studio/internal/logic/file/fileuploadlogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package file

import (
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"
"net/http"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)

type FileUploadLogic struct {
logx.Logger
r *http.Request
svcCtx *svc.ServiceContext
}

func NewFileUploadLogic(r *http.Request, svcCtx *svc.ServiceContext) *FileUploadLogic {
return &FileUploadLogic{
Logger: logx.WithContext(r.Context()),
r: r,
svcCtx: svcCtx,
}
}

func (l *FileUploadLogic) FileUpload() error {
return service.NewFileService(l.r, nil, l.svcCtx).FileUpload()
}
Loading

0 comments on commit ace6164

Please sign in to comment.