fix: api descript
This commit is contained in:
@@ -5,9 +5,13 @@ package file
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"juwan-backend/app/objectstory/api/internal/svc"
|
||||
"juwan-backend/app/objectstory/api/internal/types"
|
||||
"juwan-backend/app/objectstory/rpc/fileservice"
|
||||
"juwan-backend/common/utils/contextx"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -27,8 +31,26 @@ func NewGetFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFileLo
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetFileLogic) GetFile(req *types.GetFileReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
func (l *GetFileLogic) GetFile(req *types.GetFileReq) (string, error) {
|
||||
if req == nil || req.FileId == "" {
|
||||
return "", errors.New("file id is required")
|
||||
}
|
||||
|
||||
return nil
|
||||
userID, err := contextx.UserIDFrom(l.ctx)
|
||||
if err != nil {
|
||||
return "", contextx.ERRILLEGALUSER
|
||||
}
|
||||
|
||||
rpcResp, err := l.svcCtx.FileRpc.GetFileUrl(l.ctx, &fileservice.GetFileUrlReq{
|
||||
FileId: req.FileId,
|
||||
UserId: strconv.FormatInt(userID, 10),
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if rpcResp.GetUrl() == "" {
|
||||
return "", errors.New("file url is empty")
|
||||
}
|
||||
|
||||
return rpcResp.GetUrl(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user