Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件上传、删除、预览功能实现 #206

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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