Documentation
¶
Index ¶
- type Book
- type Favorite
- type Handler
- func (h *Handler) AddToFavorites(c echo.Context) error
- func (h *Handler) CreateBook(c echo.Context) error
- func (h *Handler) DeleteBook(c echo.Context) error
- func (h *Handler) GetBookByID(c echo.Context) error
- func (h *Handler) GetFavoritesByUser(c echo.Context) error
- func (h *Handler) ListBooks(c echo.Context) error
- func (h *Handler) RegisterRoutes(e *echo.Echo)
- func (h *Handler) SearchBooks(c echo.Context) error
- func (h *Handler) UpdateBook(c echo.Context) error
- type Repository
- func (r *Repository) AddToFavorites(ctx context.Context, userID, bookID uint) error
- func (r *Repository) CreateBook(ctx context.Context, book *Book) error
- func (r *Repository) DeleteBook(ctx context.Context, id uint) error
- func (r *Repository) Exists(ctx context.Context, id uint) (bool, error)
- func (r *Repository) FindBookByID(ctx context.Context, id uint) (*Book, error)
- func (r *Repository) GetBookByID(ctx context.Context, id uint) (*Book, error)
- func (r *Repository) GetFavoritesByUser(ctx context.Context, userID int) ([]Book, error)
- func (r *Repository) ListBooks(ctx context.Context) ([]Book, error)
- func (r *Repository) SaveBook(ctx context.Context, book *Book) error
- func (r *Repository) SearchBooks(ctx context.Context, q string) ([]Book, error)
- func (r *Repository) UpdateBook(ctx context.Context, book *Book) error
- type Service
- func (s *Service) AddToFavorites(ctx context.Context, userID, bookID uint) error
- func (s *Service) CreateBook(ctx context.Context, book *Book) error
- func (s *Service) DeleteBook(ctx context.Context, id uint) error
- func (s *Service) GetBookByID(ctx context.Context, id uint) (*Book, error)
- func (s *Service) GetFavoritesByUser(ctx context.Context, userID int) ([]Book, error)
- func (s *Service) ListBooks(ctx context.Context) ([]Book, error)
- func (s *Service) SearchBooks(ctx context.Context, q string) ([]Book, error)
- func (s *Service) UpdateBook(ctx context.Context, book *Book) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"type:varchar(200);not null" json:"title"`
Author string `gorm:"type:varchar(150);not null" json:"author"`
ISBN string `gorm:"type:varchar(20);uniqueIndex" json:"isbn"`
Publisher string `gorm:"type:varchar(150)" json:"publisher"`
YearOfPublication int `gorm:"type:int" json:"year_of_publication"`
Edition string `gorm:"type:varchar(50)" json:"edition"`
Genre string `gorm:"type:varchar(100)" json:"genre"`
Language string `gorm:"type:varchar(50);default:'fa'" json:"language"`
Description string `gorm:"type:text" json:"description"`
Stock int `gorm:"not null;default:1" json:"stock"`
ReservationStatus string `gorm:"type:enum('available','reserved');default:'available'" json:"reservation_status"`
SellingStatus string `gorm:"type:enum('available','sold_out');default:'available'" json:"selling_status"`
CoverImage string `gorm:"type:varchar(255)" json:"cover_image"`
Tags string `gorm:"type:varchar(255)" json:"tags"`
Price float64 `gorm:"default:0" json:"price"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `gorm:"index" json:"deleted_at"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) RegisterRoutes ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
func (*Repository) AddToFavorites ¶
func (r *Repository) AddToFavorites(ctx context.Context, userID, bookID uint) error
func (*Repository) CreateBook ¶
func (r *Repository) CreateBook(ctx context.Context, book *Book) error
func (*Repository) DeleteBook ¶
func (r *Repository) DeleteBook(ctx context.Context, id uint) error
func (*Repository) FindBookByID ¶
func (*Repository) GetBookByID ¶
func (*Repository) GetFavoritesByUser ¶
func (*Repository) SearchBooks ¶
func (*Repository) UpdateBook ¶
func (r *Repository) UpdateBook(ctx context.Context, book *Book) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo *Repository, cache *redis.Client) *Service
func (*Service) AddToFavorites ¶
func (*Service) CreateBook ¶
CreateBook — هم دیتا ذخیره میشه، هم کش پاک میشه
func (*Service) GetBookByID ¶
func (*Service) GetFavoritesByUser ¶
func (*Service) SearchBooks ¶
Click to show internal directories.
Click to hide internal directories.