优化结构
This commit is contained in:
@@ -3,11 +3,9 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"kra/app/system/internal/dto"
|
||||
)
|
||||
|
||||
func (s *MediaService) InitUpload(ctx context.Context, userID uint, name, hash string, size, chunkSize int64, total int) (*dto.InitUploadResponse, error) {
|
||||
func (s *MediaService) InitUpload(ctx context.Context, userID uint, name, hash string, size, chunkSize int64, total int) (*InitUploadResponse, error) {
|
||||
session, media, chunks, err := s.uc.InitUpload(ctx, userID, name, hash, size, chunkSize, total)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -15,14 +13,14 @@ func (s *MediaService) InitUpload(ctx context.Context, userID uint, name, hash s
|
||||
if media != nil {
|
||||
// The compatible response leaves UploadedChunks nil on an instant-upload hit, producing
|
||||
// JSON null while still returning uploadId: 0.
|
||||
return &dto.InitUploadResponse{Instant: true, Media: mediaDTO(media)}, nil
|
||||
return &InitUploadResponse{Instant: true, Media: mediaDTO(media)}, nil
|
||||
}
|
||||
return &dto.InitUploadResponse{Instant: false, UploadID: session.ID, UploadedChunks: chunks, Media: nil}, nil
|
||||
return &InitUploadResponse{Instant: false, UploadID: session.ID, UploadedChunks: chunks, Media: nil}, nil
|
||||
}
|
||||
func (s *MediaService) SaveChunk(ctx context.Context, userID, uploadID uint, index int, hash string, reader io.Reader) error {
|
||||
return s.uc.SaveChunk(ctx, userID, uploadID, index, hash, reader)
|
||||
}
|
||||
func (s *MediaService) CompleteUpload(ctx context.Context, userID, uploadID uint) (*dto.MediaResponse, error) {
|
||||
func (s *MediaService) CompleteUpload(ctx context.Context, userID, uploadID uint) (*MediaResponse, error) {
|
||||
v, err := s.uc.CompleteUpload(ctx, userID, uploadID, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user