From 9b733a19237dd63752abe0121f43c554fd106ec5 Mon Sep 17 00:00:00 2001 From: 97694731 <97694731@qq.com> Date: Wed, 25 Mar 2026 17:44:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E6=9D=A1=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/es_config.go | 1 + es/es_search.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) 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,