-
Notifications
You must be signed in to change notification settings - Fork 0
/
article.go
36 lines (32 loc) · 1.24 KB
/
article.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package domain
import (
"context"
"time"
)
// Article is representing the Article data struct
type Article struct {
ID int64 `json:"id"`
Title string `json:"title" validate:"required"`
Content string `json:"content" validate:"required"`
Author Author `json:"author"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
}
// ArticleUsecase represent the article's usecases
type ArticleUsecase interface {
Fetch(ctx context.Context, cursor string, num int64) ([]Article, string, error)
GetByID(ctx context.Context, id int64) (Article, error)
Update(ctx context.Context, ar *Article) error
GetByTitle(ctx context.Context, title string) (Article, error)
Store(context.Context, *Article) error
Delete(ctx context.Context, id int64) error
}
// ArticleRepository represent the article's repository contract
type ArticleRepository interface {
Fetch(ctx context.Context, cursor string, num int64) (res []Article, nextCursor string, err error)
GetByID(ctx context.Context, id int64) (Article, error)
GetByTitle(ctx context.Context, title string) (Article, error)
Update(ctx context.Context, ar *Article) error
Store(ctx context.Context, a *Article) error
Delete(ctx context.Context, id int64) error
}