chore: update book enabled status wiring
This commit is contained in:
@@ -2,10 +2,10 @@ package book
|
||||
|
||||
type BookAuthor struct {
|
||||
HardDeleteModel
|
||||
Name string `json:"name" form:"name" gorm:"type:varchar(128);not null;uniqueIndex:uk_book_author_name;comment:作者名称"`
|
||||
AuthorStatus string `json:"authorStatus" form:"authorStatus" gorm:"type:varchar(32);not null;default:enabled;index;comment:作者启用状态字典值,对应 common_enabled_status"`
|
||||
Intro string `json:"intro" form:"intro" gorm:"type:text;comment:作者简介"`
|
||||
CoverUrl string `json:"coverUrl" form:"coverUrl" gorm:"type:varchar(500);comment:作者头像或封面 URL"`
|
||||
Name string `json:"name" form:"name" gorm:"type:varchar(128);not null;uniqueIndex:uk_book_author_name;comment:作者名称"`
|
||||
IsEnabled bool `json:"isEnabled" form:"isEnabled" gorm:"not null;default:true;index;comment:作者是否启用"`
|
||||
Intro string `json:"intro" form:"intro" gorm:"type:text;comment:作者简介"`
|
||||
CoverUrl string `json:"coverUrl" form:"coverUrl" gorm:"type:varchar(500);comment:作者头像或封面 URL"`
|
||||
}
|
||||
|
||||
func (BookAuthor) TableName() string {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package request
|
||||
|
||||
import commonReq "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/book"
|
||||
commonReq "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
)
|
||||
|
||||
type BookSearch struct {
|
||||
commonReq.PageInfo
|
||||
@@ -14,8 +17,15 @@ type BookSearch struct {
|
||||
|
||||
type BookAuthorSearch struct {
|
||||
commonReq.PageInfo
|
||||
Name string `json:"name" form:"name"`
|
||||
AuthorStatus string `json:"authorStatus" form:"authorStatus"`
|
||||
Name string `json:"name" form:"name"`
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
}
|
||||
|
||||
type CreateBookAuthorReq struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
Intro string `json:"intro" form:"intro"`
|
||||
CoverUrl string `json:"coverUrl" form:"coverUrl"`
|
||||
}
|
||||
|
||||
type BookAuthorRelationSearch struct {
|
||||
@@ -31,6 +41,16 @@ type BookChapterSearch struct {
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
}
|
||||
|
||||
type CreateBookChapterReq struct {
|
||||
BookID uint `json:"bookId" form:"bookId"`
|
||||
Title string `json:"title" form:"title"`
|
||||
ChapterNo int `json:"chapterNo" form:"chapterNo"`
|
||||
IsReadable bool `json:"isReadable" form:"isReadable"`
|
||||
ContentFileUrl string `json:"contentFileUrl" form:"contentFileUrl"`
|
||||
TotalLines int `json:"totalLines" form:"totalLines"`
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
}
|
||||
|
||||
type BookCommentSearch struct {
|
||||
commonReq.PageInfo
|
||||
MemberUserID *uint `json:"memberUserId" form:"memberUserId"`
|
||||
@@ -62,3 +82,47 @@ type BookSeriesSearch struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
}
|
||||
|
||||
type CreateBookSeriesReq struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
CoverUrl string `json:"coverUrl" form:"coverUrl"`
|
||||
Intro string `json:"intro" form:"intro"`
|
||||
IsEnabled *bool `json:"isEnabled" form:"isEnabled"`
|
||||
}
|
||||
|
||||
func (req CreateBookAuthorReq) ToModel() book.BookAuthor {
|
||||
return book.BookAuthor{
|
||||
Name: req.Name,
|
||||
IsEnabled: boolValueOrDefault(req.IsEnabled, true),
|
||||
Intro: req.Intro,
|
||||
CoverUrl: req.CoverUrl,
|
||||
}
|
||||
}
|
||||
|
||||
func (req CreateBookChapterReq) ToModel() book.BookChapter {
|
||||
return book.BookChapter{
|
||||
BookID: req.BookID,
|
||||
Title: req.Title,
|
||||
ChapterNo: req.ChapterNo,
|
||||
IsReadable: req.IsReadable,
|
||||
ContentFileUrl: req.ContentFileUrl,
|
||||
TotalLines: req.TotalLines,
|
||||
IsEnabled: boolValueOrDefault(req.IsEnabled, true),
|
||||
}
|
||||
}
|
||||
|
||||
func (req CreateBookSeriesReq) ToModel() book.BookSeries {
|
||||
return book.BookSeries{
|
||||
Name: req.Name,
|
||||
CoverUrl: req.CoverUrl,
|
||||
Intro: req.Intro,
|
||||
IsEnabled: boolValueOrDefault(req.IsEnabled, true),
|
||||
}
|
||||
}
|
||||
|
||||
func boolValueOrDefault(value *bool, defaultValue bool) bool {
|
||||
if value == nil {
|
||||
return defaultValue
|
||||
}
|
||||
return *value
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package common
|
||||
|
||||
const (
|
||||
CommonEnabledStatusEnabled = "enabled"
|
||||
CommonEnabledStatusDisabled = "disabled"
|
||||
)
|
||||
Reference in New Issue
Block a user