Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/book/bookrepo/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/book/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
//go:generate go tool gorm gen -i repository.go -o bookrepo
type IBookRepo interface {
// SELECT * FROM books LIMIT @limit OFFSET @offset
ListBooks(ctx context.Context, limit int64, offset int64) (model.Books, error)
ListBooks(ctx context.Context, limit int64, offset int64) ([]*model.Book, error)

// INSERT INTO books (id, created_at, updated_at, title, author, published_date, image_url, description) VALUES (@data.ID, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, @data.Title, @data.Author, @data.PublishedDate, @data.ImageURL, @data.Description)
// RETURNING *
Expand Down
23 changes: 10 additions & 13 deletions model/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import (
"github.com/google/uuid"
)

type (
Books []*Book
Book struct {
ID uuid.UUID `json:"id" gorm:"primarykey"`
Title string `json:"title"`
Author string `json:"author"`
PublishedDate time.Time `json:"published_date,format:'2006-01-02'"`
ImageURL string `json:"image_url"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at,format:RFC3339" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at,format:RFC3339" gorm:"autoUpdateTime"`
}
)
type Book struct {
ID uuid.UUID `json:"id" gorm:"primarykey"`
Title string `json:"title"`
Author string `json:"author"`
PublishedDate time.Time `json:"published_date,format:'2006-01-02'"`
ImageURL string `json:"image_url"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at,format:RFC3339" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at,format:RFC3339" gorm:"autoUpdateTime"`
}