From 74b0a5b08152410ffac04bc28dd297ce19b77d6a Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 30 Mar 2022 14:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2es=E5=95=86=E5=93=81=E6=97=B6=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E5=8F=91=E7=94=9F=E7=9A=84date=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/elasticsearch/BaseElasticsearchService.java | 10 ++-------- .../lili/modules/search/entity/dos/EsGoodsIndex.java | 11 ++++------- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 5cc50ec4..11a20fab 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -165,14 +165,8 @@ public abstract class BaseElasticsearchService { " \"type\": \"long\"\n" + " },\n" + " \"releaseTime\": {\n" + - " \"type\": \"text\",\n" + - " \"fielddata\": true, \n" + - " \"fields\": {\n" + - " \"keyword\": {\n" + - " \"type\": \"keyword\",\n" + - " \"ignore_above\": 256\n" + - " }\n" + - " }\n" + + " \"type\": \"date\",\n" + + " \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" + " },\n" + " \"categoryPath\": {\n" + " \"type\": \"text\",\n" + diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index cd5372de..813249b3 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -6,14 +6,12 @@ import cn.lili.elasticsearch.EsSuffix; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.promotion.tools.PromotionTools; -import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.Accessors; import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.DateFormat; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; @@ -251,9 +249,8 @@ public class EsGoodsIndex implements Serializable { private String goodsVideo; @ApiModelProperty("商品发布时间") - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @Field(type = FieldType.Date, format = DateFormat.basic_date_time) - private Date releaseTime; + @Field(type = FieldType.Date) + private Long releaseTime; /** * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum @@ -309,7 +306,7 @@ public class EsGoodsIndex implements Serializable { this.grade = sku.getGrade(); this.recommend = sku.getRecommend(); this.goodsType = sku.getGoodsType(); - this.releaseTime = new Date(); + this.releaseTime = new Date().getTime(); } } @@ -374,7 +371,7 @@ public class EsGoodsIndex implements Serializable { this.authFlag = sku.getAuthFlag(); this.intro = sku.getIntro(); this.grade = sku.getGrade(); - this.releaseTime = new Date(); + this.releaseTime = new Date().getTime(); } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index d231f0df..ce342996 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -277,7 +277,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements UpdateRequest updateRequest = new UpdateRequest(indexName, goodsIndex.getId()); JSONObject jsonObject = JSONUtil.parseObj(goodsIndex); - jsonObject.set("releaseTime", goodsIndex.getReleaseTime().getTime()); + jsonObject.set("releaseTime", goodsIndex.getReleaseTime()); updateRequest.doc(jsonObject); request.add(updateRequest); }