修改es索引创建人、修改人字段类型

This commit is contained in:
yangsb
2024-04-26 14:18:12 +08:00
parent 4186fd6cff
commit 0fb3bca338
4 changed files with 13 additions and 11 deletions
@@ -19,11 +19,11 @@ public class ESDocument {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private String createTime;
private Long creator;
private String creator;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private String updateTime;
private Long updater;
private String updater;
private Long organId;
}
@@ -48,8 +48,8 @@ public class ESDocumentServiceImpl implements ESDocumentService {
public <T> IndexResponse createByFluentDSL(String idxName, String idxId, ESDocument document) throws Exception {
Date date = new Date();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
document.setCreator(loginUser.getId());
document.setUpdater(loginUser.getId());
document.setCreator(loginUser.getNickname());
document.setUpdater(loginUser.getNickname());
document.setOrganId(loginUser.getOrganId());
document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(simpleDateFormat.format(date));
@@ -73,8 +73,8 @@ public class ESDocumentServiceImpl implements ESDocumentService {
public <T> IndexResponse createByBuilderPattern(String idxName, String idxId, ESDocument document) throws Exception {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Date date = new Date();
document.setCreator(loginUser.getId());
document.setUpdater(loginUser.getId());
document.setCreator(loginUser.getNickname());
document.setUpdater(loginUser.getNickname());
document.setOrganId(loginUser.getOrganId());
document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(simpleDateFormat.format(date));
@@ -142,14 +142,14 @@ public class ESDocumentServiceImpl implements ESDocumentService {
if (StrUtil.isBlank(esDocument.getId())) {
esDocument.setId(snowflake.nextIdStr());
}
esDocument.setCreator(loginUser.getId());
esDocument.setCreator(loginUser.getNickname());
esDocument.setCreateTime(simpleDateFormat.format(date));
esDocument.setUpdater(loginUser.getId());
esDocument.setUpdater(loginUser.getNickname());
esDocument.setUpdateTime(simpleDateFormat.format(date));
br.operations(op -> op.index(idx -> idx
.index(idxName)
.id(esDocument.getId().toString())
.id(esDocument.getId())
.document(esDocument)));
});
return elasticsearchClient.bulk(br.build());
@@ -31,6 +31,7 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
.betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
.orderByAsc(PlanDO::getSort)
.orderByDesc(PlanDO::getId));
}
+3 -2
View File
@@ -1,3 +1,4 @@
PUT imes_order_plate_model
{
"settings": {},
"mappings": {
@@ -132,7 +133,7 @@
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
},
"creator": {
"type": "long"
"type": "keyword"
},
"holeDetail": {
"properties": {
@@ -385,7 +386,7 @@
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
},
"updater": {
"type": "long"
"type": "keyword"
}
}
}