单条搜索

This commit is contained in:
97694731 2026-03-25 17:44:17 +08:00
parent c5e755faec
commit 9b733a1923
2 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@ type ESFieldConfig struct {
func GetESFieldConfig() *ESFieldConfig { func GetESFieldConfig() *ESFieldConfig {
return &ESFieldConfig{ return &ESFieldConfig{
AllowUpdate: map[string]bool{ AllowUpdate: map[string]bool{
"book_name": true,
"book_pic": true, "book_pic": true,
"book_pic_s": true, "book_pic_s": true,
"book_pic_b": true, "book_pic_b": true,

View File

@ -12,8 +12,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gin-gonic/gin"
jsoniter "github.com/json-iterator/go"
"io" "io"
"log" "log"
"net/http" "net/http"
@ -21,6 +19,9 @@ import (
"strings" "strings"
"time" "time"
"github.com/gin-gonic/gin"
jsoniter "github.com/json-iterator/go"
"github.com/elastic/go-elasticsearch/v8/esapi" "github.com/elastic/go-elasticsearch/v8/esapi"
) )
@ -158,6 +159,10 @@ func (book *ESBook) ConvertToResponse() ESBookResponse {
"localPath": book.BookDefPic.LocalPath, "localPath": book.BookDefPic.LocalPath,
"pddPath": book.BookDefPic.PddPath, "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{ return ESBookResponse{
ID: book.ID, ID: book.ID,
BookName: book.BookName.Value, BookName: book.BookName.Value,
@ -170,7 +175,7 @@ func (book *ESBook) ConvertToResponse() ESBookResponse {
Author: book.Author, Author: book.Author,
Category: book.Category, Category: book.Category,
Publisher: book.Publisher, Publisher: book.Publisher,
PublicationTime: book.PublicationTime, PublicationTime: publicationTime,
BindingLayout: book.BindingLayout, BindingLayout: book.BindingLayout,
FixPrice: float64(book.FixPrice), FixPrice: float64(book.FixPrice),
Content: book.Content, Content: book.Content,