sonar代码规范问题修复;

This commit is contained in:
gaoqr
2024-09-14 10:47:03 +08:00
parent 73440a7f3a
commit 59296b19c8
30 changed files with 75 additions and 72 deletions
@@ -1,8 +1,8 @@
package com.cf.imes.framework.es.core.service;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
@@ -50,7 +50,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(simpleDateFormat.format(date));
if (StrUtil.isBlank(document.getId())) {
if (CharSequenceUtil.isBlank(document.getId())) {
document.setId(snowflake.nextIdStr());
}
return elasticsearchClient.index(idx -> idx
@@ -77,7 +77,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
document.setUpdateTime(simpleDateFormat.format(date));
IndexRequest.Builder<Object> indexReqBuilder = new IndexRequest.Builder<>();
indexReqBuilder.index(idxName);
if (StrUtil.isBlank(idxId)) {
if (CharSequenceUtil.isBlank(idxId)) {
idxId = snowflake.nextIdStr();
}
indexReqBuilder.id(idxId);
@@ -94,7 +94,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
*/
@Override
public IndexResponse createByJson(String idxName, String idxId, String jsonContent) throws Exception {
if (StrUtil.isBlank(idxId)) {
if (CharSequenceUtil.isBlank(idxId)) {
idxId = snowflake.nextIdStr();
}
String finalIdxId = idxId;
@@ -136,7 +136,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
Date date = new Date();
LocalDateTime now = LocalDateTime.now();
documents.forEach(esDocument -> {
if (StrUtil.isBlank(esDocument.getId())) {
if (CharSequenceUtil.isBlank(esDocument.getId())) {
esDocument.setId(snowflake.nextIdStr());
}
esDocument.setCreator(loginUser.getNickname());
@@ -169,7 +169,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
Date date = new Date();
documents.forEach(esDocument -> {
// 假设esDocument有一个ID集。如果没有,则应该抛出异常或进行相应的处理。
if (StrUtil.isBlank(esDocument.getId())) {
if (CharSequenceUtil.isBlank(esDocument.getId())) {
throw new IllegalArgumentException("更新操作的文档ID不能为空");
}
esDocument.setUpdater(loginUser.getNickname());