修复一个搜索es商品时可能会发生的date格式转换问题
This commit is contained in:
parent
6d014a01bc
commit
74b0a5b081
@ -165,14 +165,8 @@ public abstract class BaseElasticsearchService {
|
|||||||
" \"type\": \"long\"\n" +
|
" \"type\": \"long\"\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"releaseTime\": {\n" +
|
" \"releaseTime\": {\n" +
|
||||||
" \"type\": \"text\",\n" +
|
" \"type\": \"date\",\n" +
|
||||||
" \"fielddata\": true, \n" +
|
" \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" +
|
||||||
" \"fields\": {\n" +
|
|
||||||
" \"keyword\": {\n" +
|
|
||||||
" \"type\": \"keyword\",\n" +
|
|
||||||
" \"ignore_above\": 256\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"categoryPath\": {\n" +
|
" \"categoryPath\": {\n" +
|
||||||
" \"type\": \"text\",\n" +
|
" \"type\": \"text\",\n" +
|
||||||
|
@ -6,14 +6,12 @@ import cn.lili.elasticsearch.EsSuffix;
|
|||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.springframework.data.annotation.Id;
|
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.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
@ -251,9 +249,8 @@ public class EsGoodsIndex implements Serializable {
|
|||||||
private String goodsVideo;
|
private String goodsVideo;
|
||||||
|
|
||||||
@ApiModelProperty("商品发布时间")
|
@ApiModelProperty("商品发布时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
@Field(type = FieldType.Date)
|
||||||
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
|
private Long releaseTime;
|
||||||
private Date releaseTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
|
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
|
||||||
@ -309,7 +306,7 @@ public class EsGoodsIndex implements Serializable {
|
|||||||
this.grade = sku.getGrade();
|
this.grade = sku.getGrade();
|
||||||
this.recommend = sku.getRecommend();
|
this.recommend = sku.getRecommend();
|
||||||
this.goodsType = sku.getGoodsType();
|
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.authFlag = sku.getAuthFlag();
|
||||||
this.intro = sku.getIntro();
|
this.intro = sku.getIntro();
|
||||||
this.grade = sku.getGrade();
|
this.grade = sku.getGrade();
|
||||||
this.releaseTime = new Date();
|
this.releaseTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
UpdateRequest updateRequest = new UpdateRequest(indexName, goodsIndex.getId());
|
UpdateRequest updateRequest = new UpdateRequest(indexName, goodsIndex.getId());
|
||||||
|
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(goodsIndex);
|
JSONObject jsonObject = JSONUtil.parseObj(goodsIndex);
|
||||||
jsonObject.set("releaseTime", goodsIndex.getReleaseTime().getTime());
|
jsonObject.set("releaseTime", goodsIndex.getReleaseTime());
|
||||||
updateRequest.doc(jsonObject);
|
updateRequest.doc(jsonObject);
|
||||||
request.add(updateRequest);
|
request.add(updateRequest);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user