package v1

import (
	"server/internal/model"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta   `path:"/chapter" tags:"Backend/Chapter" method:"get" summary:"获取章节列表"`
	Page     int    `json:"page"     dc:"页码"`
	Size     int    `json:"size"     dc:"每页数量"`
	BookId   int64  `json:"bookId"   dc:"小说ID"`
	Title    string `json:"title"    dc:"章节标题（模糊搜索）"`
	IsLocked int    `json:"isLocked" dc:"是否锁定：0免费，1需积分解锁"`
}
type ListRes struct {
	Total int             `json:"total" dc:"总数"`
	List  []model.Chapter `json:"list"  dc:"章节列表"`
}

type AddReq struct {
	g.Meta        `path:"/chapter" tags:"Backend/Chapter" method:"post" summary:"新增章节"`
	BookId        int64  `json:"bookId"        dc:"小说ID"        v:"required"`
	Title         string `json:"title"         dc:"章节标题"      v:"required"`
	Content       string `json:"content"       dc:"章节内容"      v:"required"`
	WordCount     int    `json:"wordCount"     dc:"章节字数"`
	Sort          int    `json:"sort"          dc:"排序序号"`
	IsLocked      int    `json:"isLocked"      dc:"是否锁定：0免费，1需积分解锁"`
	RequiredScore int    `json:"requiredScore" dc:"解锁所需积分"`
}
type AddRes struct {
	Success bool `json:"success" dc:"是否成功"`
}

type EditReq struct {
	g.Meta        `path:"/chapter" tags:"Backend/Chapter" method:"put" summary:"编辑章节"`
	Id            int64  `json:"id"            dc:"章节ID"        v:"required"`
	BookId        int64  `json:"bookId"        dc:"小说ID"        v:"required"`
	Title         string `json:"title"         dc:"章节标题"      v:"required"`
	Content       string `json:"content"       dc:"章节内容"      v:"required"`
	WordCount     int    `json:"wordCount"     dc:"章节字数"`
	Sort          int    `json:"sort"          dc:"排序序号"`
	IsLocked      int    `json:"isLocked"      dc:"是否锁定：0免费，1需积分解锁"`
	RequiredScore int    `json:"requiredScore" dc:"解锁所需积分"`
}
type EditRes struct {
	Success bool `json:"success" dc:"是否成功"`
}

type DelReq struct {
	g.Meta `path:"/chapter" tags:"Backend/Chapter" method:"delete" summary:"删除章节"`
	Id     int64 `json:"id" dc:"章节ID" v:"required"`
}
type DelRes struct {
	Success bool `json:"success" dc:"是否成功"`
}

type AppListReq struct {
	g.Meta `path:"/chapter/app/list" tags:"APP/Chapter" method:"get" summary:"App获取章节列表"`
	BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
	IsDesc bool  `json:"isDesc" dc:"是否逆序排列"`
	Page   int   `json:"page"   dc:"页码"`
	Size   int   `json:"size"   dc:"每页数量"`
}
type AppListRes struct {
	Total int                    `json:"total" dc:"总数"`
	List  []model.ChapterAppItem `json:"list"  dc:"章节列表"`
}

type AppDetailReq struct {
	g.Meta `path:"/chapter/app/detail" tags:"APP/Chapter" method:"get" summary:"App获取章节详情"`
	Id     int64 `json:"id" dc:"章节ID" v:"required"`
}
type AppDetailRes struct {
	Id            int64  `json:"id"            dc:"章节ID"`
	BookId        int64  `json:"bookId"        dc:"书籍ID"`
	Title         string `json:"title"         dc:"章节标题"`
	Content       string `json:"content"       dc:"章节内容"`
	WordCount     int    `json:"wordCount"     dc:"字数"`
	Sort          int    `json:"sort"          dc:"排序"`
	IsLocked      int    `json:"isLocked"      dc:"是否锁定"`
	RequiredScore int    `json:"requiredScore" dc:"所需积分"`
	UpdatedAt     string `json:"updatedAt"     dc:"更新时间"`
}

type AppPurchaseReq struct {
	g.Meta `path:"/chapter/app/purchase" tags:"APP/Chapter" method:"post" summary:"App购买章节"`
	Id     int64 `json:"id" dc:"章节ID" v:"required"`
}
type AppPurchaseRes struct {
	Success bool `json:"success" dc:"是否成功"`
}

type AppProgressReq struct {
	g.Meta   `path:"/chapter/app/progress" tags:"APP/Chapter" method:"post" summary:"App上传阅读进度"`
	BookId   int64                       `json:"bookId"    dc:"书籍ID"    v:"required"`
	Chapters []model.ChapterProgressItem `json:"chapters"  dc:"章节进度列表" v:"required"`
}

type AppProgressRes struct {
	Success bool `json:"success" dc:"是否成功"`
}
