修改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) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private String createTime; private String createTime;
private Long creator; private String creator;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private String updateTime; private String updateTime;
private Long updater; private String updater;
private Long organId; private Long organId;
} }
@@ -48,8 +48,8 @@ public class ESDocumentServiceImpl implements ESDocumentService {
public <T> IndexResponse createByFluentDSL(String idxName, String idxId, ESDocument document) throws Exception { public <T> IndexResponse createByFluentDSL(String idxName, String idxId, ESDocument document) throws Exception {
Date date = new Date(); Date date = new Date();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
document.setCreator(loginUser.getId()); document.setCreator(loginUser.getNickname());
document.setUpdater(loginUser.getId()); document.setUpdater(loginUser.getNickname());
document.setOrganId(loginUser.getOrganId()); document.setOrganId(loginUser.getOrganId());
document.setCreateTime(simpleDateFormat.format(date)); document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(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 { public <T> IndexResponse createByBuilderPattern(String idxName, String idxId, ESDocument document) throws Exception {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Date date = new Date(); Date date = new Date();
document.setCreator(loginUser.getId()); document.setCreator(loginUser.getNickname());
document.setUpdater(loginUser.getId()); document.setUpdater(loginUser.getNickname());
document.setOrganId(loginUser.getOrganId()); document.setOrganId(loginUser.getOrganId());
document.setCreateTime(simpleDateFormat.format(date)); document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(simpleDateFormat.format(date)); document.setUpdateTime(simpleDateFormat.format(date));
@@ -142,14 +142,14 @@ public class ESDocumentServiceImpl implements ESDocumentService {
if (StrUtil.isBlank(esDocument.getId())) { if (StrUtil.isBlank(esDocument.getId())) {
esDocument.setId(snowflake.nextIdStr()); esDocument.setId(snowflake.nextIdStr());
} }
esDocument.setCreator(loginUser.getId()); esDocument.setCreator(loginUser.getNickname());
esDocument.setCreateTime(simpleDateFormat.format(date)); esDocument.setCreateTime(simpleDateFormat.format(date));
esDocument.setUpdater(loginUser.getId()); esDocument.setUpdater(loginUser.getNickname());
esDocument.setUpdateTime(simpleDateFormat.format(date)); esDocument.setUpdateTime(simpleDateFormat.format(date));
br.operations(op -> op.index(idx -> idx br.operations(op -> op.index(idx -> idx
.index(idxName) .index(idxName)
.id(esDocument.getId().toString()) .id(esDocument.getId())
.document(esDocument))); .document(esDocument)));
}); });
return elasticsearchClient.bulk(br.build()); return elasticsearchClient.bulk(br.build());
@@ -31,6 +31,7 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PlanDO::getOperator, reqVO.getOperator()) .eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
.betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime()) .betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
.orderByAsc(PlanDO::getSort)
.orderByDesc(PlanDO::getId)); .orderByDesc(PlanDO::getId));
} }
+3 -2
View File
@@ -1,3 +1,4 @@
PUT imes_order_plate_model
{ {
"settings": {}, "settings": {},
"mappings": { "mappings": {
@@ -132,7 +133,7 @@
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis" "format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
}, },
"creator": { "creator": {
"type": "long" "type": "keyword"
}, },
"holeDetail": { "holeDetail": {
"properties": { "properties": {
@@ -385,7 +386,7 @@
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis" "format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
}, },
"updater": { "updater": {
"type": "long" "type": "keyword"
} }
} }
} }