initial commit
This commit is contained in:
60
file/fileclient/file.go
Normal file
60
file/fileclient/file.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.8.3
|
||||
// Source: file.proto
|
||||
|
||||
package fileclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"godemo/file/file"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type (
|
||||
DeleteRequest = file.DeleteRequest
|
||||
DeleteResponse = file.DeleteResponse
|
||||
GetFileUrlRequest = file.GetFileUrlRequest
|
||||
GetFileUrlResponse = file.GetFileUrlResponse
|
||||
UploadRequest = file.UploadRequest
|
||||
UploadResponse = file.UploadResponse
|
||||
|
||||
File interface {
|
||||
// 上传文件(图片/头像/壁纸等)
|
||||
Upload(ctx context.Context, in *UploadRequest, opts ...grpc.CallOption) (*UploadResponse, error)
|
||||
// 获取文件访问链接(带签名,防盗链)
|
||||
GetFileUrl(ctx context.Context, in *GetFileUrlRequest, opts ...grpc.CallOption) (*GetFileUrlResponse, error)
|
||||
// 删除文件
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error)
|
||||
}
|
||||
|
||||
defaultFile struct {
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewFile(cli zrpc.Client) File {
|
||||
return &defaultFile{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
// 上传文件(图片/头像/壁纸等)
|
||||
func (m *defaultFile) Upload(ctx context.Context, in *UploadRequest, opts ...grpc.CallOption) (*UploadResponse, error) {
|
||||
client := file.NewFileClient(m.cli.Conn())
|
||||
return client.Upload(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 获取文件访问链接(带签名,防盗链)
|
||||
func (m *defaultFile) GetFileUrl(ctx context.Context, in *GetFileUrlRequest, opts ...grpc.CallOption) (*GetFileUrlResponse, error) {
|
||||
client := file.NewFileClient(m.cli.Conn())
|
||||
return client.GetFileUrl(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 删除文件
|
||||
func (m *defaultFile) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) {
|
||||
client := file.NewFileClient(m.cli.Conn())
|
||||
return client.Delete(ctx, in, opts...)
|
||||
}
|
||||
Reference in New Issue
Block a user