First local go service
This commit is contained in:
28
api/internal/core/entities/download.go
Normal file
28
api/internal/core/entities/download.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"downloader/pkg/common/uuid"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Download struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Link string `json:"link"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func NewDownload(link string, data string) func(uuidGen uuid.Gen) (*Download, error) {
|
||||
return func(uuidGen uuid.Gen) (*Download, error) {
|
||||
if link == "" || data == "" {
|
||||
return nil, errors.New("A field was not valid")
|
||||
}
|
||||
|
||||
return &Download{
|
||||
ID: uuidGen.Create(),
|
||||
Status: "scheduled",
|
||||
Link: link,
|
||||
Data: data,
|
||||
}, nil
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user