package model

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

type BookRecommendation struct {
	g.Meta    `orm:"table:book_recommendations"`
	Id        int64       `json:"id"         orm:"id"`
	BookId    int64       `json:"bookId"     orm:"book_id"`
	Book      SimpleBook  `json:"book"       orm:"with:id=book_id"`
	Type      int         `json:"type"       orm:"type"` // 推荐类型：1=首页Banner，2=编辑推荐，3=分类推荐等
	CoverUrl  string      `json:"coverUrl"  orm:"cover_url"`
	SortOrder int         `json:"sortOrder" orm:"sort_order"`
	Status    int         `json:"status"    orm:"status"` // 1=启用，0=禁用
	CreatedAt *gtime.Time `json:"createdAt" orm:"created_at"`
	UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at"`
	DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at"`
}

type BookRecommendationsListIn struct {
	Page   int   `json:"page"`
	Size   int   `json:"size"`
	Type   int   `json:"type"`
	Status int   `json:"status"`
	BookId int64 `json:"bookId"`
}
type BookRecommendationsListOut struct {
	Total int                  `json:"total"`
	List  []BookRecommendation `json:"list"`
}

type BookRecommendationsCreateIn struct {
	BookId    int64  `json:"bookId"`
	Type      int    `json:"type"`
	CoverUrl  string `json:"coverUrl"`
	SortOrder int    `json:"sortOrder"`
	Status    int    `json:"status"`
}
type BookRecommendationsUpdateIn struct {
	Id        int64  `json:"id"`
	BookId    int64  `json:"bookId"`
	Type      int    `json:"type"`
	CoverUrl  string `json:"coverUrl"`
	SortOrder int    `json:"sortOrder"`
	Status    int    `json:"status"`
}
type BookRecommendationsDeleteIn struct {
	Id int64 `json:"id"`
}
type BookRecommendationsCRUDOut struct {
	Success bool `json:"success"`
}
type BookRecommendationsSetStatusIn struct {
	Id     int64 `json:"id"`
	Status int   `json:"status"`
}
type BookRecommendationsSortOrderIn struct {
	Id        int64 `json:"id"`
	SortOrder int   `json:"sortOrder"`
}

// App 推荐简要结构体
// 只用于 AppList 返回
type RecommendAppItem struct {
	Id        int64  `json:"id"        dc:"推荐ID"`
	BookId    int64  `json:"bookId"    dc:"书籍ID"`
	CoverUrl  string `json:"coverUrl"  dc:"推荐封面图"`
	SortOrder int    `json:"sortOrder" dc:"顺序"`
}

type BookRecommendationsAppListOut struct {
	Total int                `json:"total"`
	List  []RecommendAppItem `json:"list"`
}
