Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | package repository |
||
2 | |||
3 | import ( |
||
4 | "github.com/architectv/estate-task/pkg/model" |
||
5 | "github.com/jmoiron/sqlx" |
||
6 | ) |
||
7 | |||
8 | type Room interface { |
||
9 | Create(room *model.Room) (int, error) |
||
10 | Delete(id int) error |
||
11 | GetAll(sortField string, desc bool) ([]*model.Room, error) |
||
12 | GetById(id int) (*model.Room, error) |
||
13 | } |
||
14 | |||
15 | type Booking interface { |
||
16 | Create(booking *model.Booking) (int, error) |
||
17 | Delete(id int) error |
||
18 | GetByRoomId(roomId int) ([]*model.Booking, error) |
||
19 | GetById(id int) (*model.Booking, error) |
||
20 | } |
||
21 | |||
22 | type Repository struct { |
||
23 | Room |
||
24 | Booking |
||
25 | } |
||
26 | |||
27 | func NewRepository(db *sqlx.DB) *Repository { |
||
28 | return &Repository{ |
||
29 | Room: NewRoomPostgres(db), |
||
30 | Booking: NewBookingPostgres(db), |
||
31 | } |
||
33 |