添加分类
This commit is contained in:
parent
59c188a9a7
commit
6f41cc9cbe
@ -25,6 +25,7 @@ type AddBookRequest struct {
|
||||
PageCount int64 `form:"page_count"` // 页数
|
||||
WordCount int64 `form:"word_count"` // 字数
|
||||
BookFormat int64 `form:"book_format"` // 图书格式
|
||||
CatID string `form:"cat_id"` // 类目ID JSON字符串
|
||||
LiveImage []string `form:"live_image"` // 图片
|
||||
}
|
||||
|
||||
|
||||
@ -143,6 +143,21 @@ func (s *BookService) doBook(data systemReq.AddBookRequest) (int64, error) {
|
||||
liveImage = datatypes.JSON("[]")
|
||||
}
|
||||
catIdByJson := datatypes.JSON(`{"xian_yu_cat_id": "", "kong_fu_zi_cat_id": "", "pin_duo_duo_cat_id": ""}`)
|
||||
if data.CatID != "" {
|
||||
var catObj map[string]string
|
||||
if err := json.Unmarshal([]byte(data.CatID), &catObj); err == nil {
|
||||
filtered := make(map[string]string)
|
||||
for k, v := range catObj {
|
||||
if strings.TrimSpace(v) != "" {
|
||||
filtered[k] = v
|
||||
}
|
||||
}
|
||||
if len(filtered) > 0 {
|
||||
filteredBytes, _ := json.Marshal(filtered)
|
||||
catIdByJson = filteredBytes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
book := models.BookInfo{
|
||||
Fid: data.Fid,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user