diff --git a/es/es_config.go b/es/es_config.go index 8fe5f76..dd583e2 100644 --- a/es/es_config.go +++ b/es/es_config.go @@ -16,6 +16,7 @@ type ESFieldConfig struct { func GetESFieldConfig() *ESFieldConfig { return &ESFieldConfig{ AllowUpdate: map[string]bool{ + "book_name": true, "book_pic": true, "book_pic_s": true, "book_pic_b": true, diff --git a/es/es_search.go b/es/es_search.go index 2af24b2..ca90416 100644 --- a/es/es_search.go +++ b/es/es_search.go @@ -12,8 +12,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/gin-gonic/gin" - jsoniter "github.com/json-iterator/go" "io" "log" "net/http" @@ -21,6 +19,9 @@ import ( "strings" "time" + "github.com/gin-gonic/gin" + jsoniter "github.com/json-iterator/go" + "github.com/elastic/go-elasticsearch/v8/esapi" ) @@ -158,6 +159,10 @@ func (book *ESBook) ConvertToResponse() ESBookResponse { "localPath": book.BookDefPic.LocalPath, "pddPath": book.BookDefPic.PddPath, } + publicationTime := book.PublicationTime + if publicationTime == "" || publicationTime == "0" || publicationTime == "0000-00-00" { + publicationTime = time.Unix(0, 0).Format("2006-01") + } return ESBookResponse{ ID: book.ID, BookName: book.BookName.Value, @@ -170,7 +175,7 @@ func (book *ESBook) ConvertToResponse() ESBookResponse { Author: book.Author, Category: book.Category, Publisher: book.Publisher, - PublicationTime: book.PublicationTime, + PublicationTime: publicationTime, BindingLayout: book.BindingLayout, FixPrice: float64(book.FixPrice), Content: book.Content,