48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.10.1
|
|
|
|
package file
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"sundynix-micro-go/app/file/api/internal/svc"
|
|
"sundynix-micro-go/app/file/api/internal/types"
|
|
"sundynix-micro-go/app/file/rpc/fileservice"
|
|
)
|
|
|
|
type GetFileByIdLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// 获取文件信息
|
|
func NewGetFileByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFileByIdLogic {
|
|
return &GetFileByIdLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetFileByIdLogic) GetFileById(req *types.FileIdReq) (resp *types.FileInfo, err error) {
|
|
respRpc, err := l.svcCtx.FileRpc.GetFileById(l.ctx, &fileservice.GetFileByIdReq{
|
|
Id: req.Id,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &types.FileInfo{
|
|
Id: respRpc.File.Id,
|
|
Name: respRpc.File.Name,
|
|
Url: respRpc.File.Url,
|
|
Tag: respRpc.File.Tag,
|
|
Key: respRpc.File.Key,
|
|
Suffix: respRpc.File.Suffix,
|
|
Md5: respRpc.File.Md5,
|
|
}, nil
|
|
}
|