initial commit
This commit is contained in:
17
internal/domain/asset/artifact.go
Normal file
17
internal/domain/asset/artifact.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Artifact struct {
|
||||
ID uuid.UUID
|
||||
AssetID uuid.UUID
|
||||
Type string
|
||||
DownloadURL string
|
||||
Price int // in cents or smallest currency unit
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
|
||||
36
internal/domain/asset/asset.go
Normal file
36
internal/domain/asset/asset.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=Status
|
||||
type Status int
|
||||
|
||||
const (
|
||||
StatusPublished Status = iota
|
||||
StatusDisabled
|
||||
StatusPending
|
||||
StatusDeleted
|
||||
)
|
||||
|
||||
type Asset struct {
|
||||
ID uuid.UUID
|
||||
ProfileID uuid.UUID
|
||||
Status Status
|
||||
AssetCategoryID uuid.UUID
|
||||
AssetCategory Category
|
||||
Title string
|
||||
Description string
|
||||
Link string
|
||||
Analytics json.RawMessage
|
||||
Reports []Report
|
||||
AssetArtifacts []Artifact
|
||||
Comments []Comment
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
17
internal/domain/asset/category.go
Normal file
17
internal/domain/asset/category.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Category struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Icon string
|
||||
Color string
|
||||
CardType string
|
||||
Featured bool
|
||||
Description string
|
||||
}
|
||||
|
||||
|
||||
22
internal/domain/asset/comment.go
Normal file
22
internal/domain/asset/comment.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Comment struct {
|
||||
ID uuid.UUID
|
||||
AssetID uuid.UUID
|
||||
Content string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
WriterID uuid.UUID
|
||||
WriterType string
|
||||
ParentID *uuid.UUID
|
||||
Replies []Comment
|
||||
}
|
||||
|
||||
|
||||
|
||||
51
internal/domain/asset/report.go
Normal file
51
internal/domain/asset/report.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=ReportStatus
|
||||
type ReportStatus int
|
||||
|
||||
const (
|
||||
ReportStatusPending ReportStatus = iota
|
||||
ReportStatusReviewed
|
||||
ReportStatusResolved
|
||||
ReportStatusDismissed
|
||||
)
|
||||
|
||||
type Report struct {
|
||||
ID uuid.UUID
|
||||
AssetID uuid.UUID
|
||||
ReportedBy ReportedBy
|
||||
ReportedAt time.Time
|
||||
Reason ReportReason
|
||||
Status ReportStatus
|
||||
Notes string
|
||||
Attachments []Attachment
|
||||
}
|
||||
|
||||
type ReportedBy struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Description string
|
||||
RestOfFields json.RawMessage
|
||||
}
|
||||
|
||||
type ReportReason struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Description string
|
||||
RestOfFields json.RawMessage
|
||||
}
|
||||
|
||||
type Attachment struct {
|
||||
ID uuid.UUID
|
||||
URL string
|
||||
Type string
|
||||
}
|
||||
|
||||
|
||||
29
internal/domain/asset/repository.go
Normal file
29
internal/domain/asset/repository.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type AssetRepository interface {
|
||||
Create(ctx context.Context, asset *Asset) error
|
||||
FindByID(ctx context.Context, id uuid.UUID) (*Asset, error)
|
||||
Update(ctx context.Context, asset *Asset) error
|
||||
Delete(ctx context.Context, asset *Asset) error
|
||||
FindByProfileID(ctx context.Context, profileID uuid.UUID) ([]*Asset, error)
|
||||
FindLatest(ctx context.Context, limit, offset int) ([]*Asset, error)
|
||||
FindLatestByCategory(ctx context.Context, categoryID uuid.UUID, limit int) ([]*Asset, error)
|
||||
FindLatestByCategoryPaginated(ctx context.Context, categoryID uuid.UUID, limit, offset int) ([]*Asset, error)
|
||||
CountByCategory(ctx context.Context, categoryID uuid.UUID) (int, error)
|
||||
Count(ctx context.Context) (int, error)
|
||||
}
|
||||
|
||||
type CategoryRepository interface {
|
||||
Create(ctx context.Context, category *Category) error
|
||||
FindByID(ctx context.Context, id uuid.UUID) (*Category, error)
|
||||
Update(ctx context.Context, category *Category) error
|
||||
Delete(ctx context.Context, id uuid.UUID) error
|
||||
FindAll(ctx context.Context) ([]*Category, error)
|
||||
FindByIDs(ctx context.Context, ids []uuid.UUID) ([]*Category, error)
|
||||
}
|
||||
Reference in New Issue
Block a user