/
repository.go
73 lines (63 loc) · 1.86 KB
/
repository.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package repository
import (
webApi "github.com/4from5/TimeHack-webapi"
"github.com/jmoiron/sqlx"
)
type Repository struct {
Authorization
Category
Task
Event
Notion
User
Week
}
type Authorization interface {
CreateUser(user webApi.User) (int, error)
GetUser(username, password string) (webApi.User, error)
}
type Week interface {
GetDays(userId int, input webApi.WeekRequest) ([]webApi.Day, error)
}
type User interface {
Get(userId int) (webApi.UsernameInfo, error)
}
type Category interface {
Create(userId int, category webApi.Category) (int, error)
GetAll(userId int) ([]webApi.Category, error)
GetById(userId, id int) (webApi.Category, error)
Delete(userId, id int) error
Update(userId, id int, input webApi.UpdateCategoryInput) error
}
type Event interface {
Create(userId int, category webApi.Event) (int, error)
GetAll(userId int) ([]webApi.Event, error)
GetById(userId, id int) (webApi.Event, error)
Delete(userId, id int) error
Update(userId, id int, input webApi.UpdateEventInput) error
}
type Notion interface {
GetAll(userId int) ([]webApi.Notion, error)
GetById(userId int, id int) (webApi.Notion, error)
Create(userId int, notion webApi.Notion) (int, error)
Delete(userId, id int) error
Update(userId, id int, input webApi.UpdateNotionInput) error
}
type Task interface {
GetAll(userId int) ([]webApi.Task, error)
GetById(userId int, id int) (webApi.Task, error)
Create(userId int, notion webApi.Task) (int, error)
Delete(userId, id int) error
Update(userId, id int, input webApi.UpdateTaskInput) error
}
func NewRepository(db *sqlx.DB) *Repository {
return &Repository{
Authorization: NewAuthPostgress(db),
Category: NewCategoryPostgres(db),
Event: NewEventPostgres(db),
Notion: NewNotionPostgres(db),
Task: NewTaskPostgres(db),
User: NewUserPostgres(db),
Week: NewWeekPostgres(db),
}
}