refactor: 使用 getFirst 优化首元素访问
This commit is contained in:
@@ -93,7 +93,7 @@ public class SysLoginService {
|
|||||||
remoteSocialService.insertByBo(bo);
|
remoteSocialService.insertByBo(bo);
|
||||||
} else {
|
} else {
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
bo.setId(list.get(0).getId());
|
bo.setId(list.getFirst().getId());
|
||||||
remoteSocialService.updateByBo(bo);
|
remoteSocialService.updateByBo(bo);
|
||||||
// 如果要绑定的平台账号已经被绑定过了 是否抛异常自行决断
|
// 如果要绑定的平台账号已经被绑定过了 是否抛异常自行决断
|
||||||
// throw new ServiceException("此平台账号已经被绑定!");
|
// throw new ServiceException("此平台账号已经被绑定!");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
||||||
}
|
}
|
||||||
RemoteSocialVo socialVo = list.get(0);
|
RemoteSocialVo socialVo = list.getFirst();
|
||||||
|
|
||||||
LoginUser loginUser = remoteUserService.getUserInfo(socialVo.getUserId());
|
LoginUser loginUser = remoteUserService.getUserInfo(socialVo.getUserId());
|
||||||
loginUser.setClientKey(client.getClientKey());
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ public class TreeBuildUtils extends TreeUtil {
|
|||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
return CollUtil.newArrayList();
|
return CollUtil.newArrayList();
|
||||||
}
|
}
|
||||||
K k = ReflectUtils.invokeGetter(list.get(0), "parentId");
|
K k = ReflectUtils.invokeGetter(list.getFirst(), "parentId");
|
||||||
return TreeUtil.build(list, k, DEFAULT_CONFIG, nodeParser);
|
return TreeUtil.build(list, k, DEFAULT_CONFIG, nodeParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -196,8 +196,8 @@ public class OpenApiHandler extends OpenAPIService {
|
|||||||
// 自定义部分 修改使用java注释当tag名
|
// 自定义部分 修改使用java注释当tag名
|
||||||
List<String> list = IoUtil.readLines(new StringReader(description), new ArrayList<>());
|
List<String> list = IoUtil.readLines(new StringReader(description), new ArrayList<>());
|
||||||
// tag.setName(tagAutoName);
|
// tag.setName(tagAutoName);
|
||||||
tag.setName(list.get(0));
|
tag.setName(list.getFirst());
|
||||||
operation.addTagsItem(list.get(0));
|
operation.addTagsItem(list.getFirst());
|
||||||
|
|
||||||
tag.setDescription(description);
|
tag.setDescription(description);
|
||||||
if (openAPI.getTags() == null || !openAPI.getTags().contains(tag)) {
|
if (openAPI.getTags() == null || !openAPI.getTags().contains(tag)) {
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class CellMergeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取有合并注解的字段
|
// 获取有合并注解的字段
|
||||||
Map<Field, FieldColumnIndex> mergeFields = getFieldColumnIndexMap(rows.get(0).getClass());
|
Map<Field, FieldColumnIndex> mergeFields = getFieldColumnIndexMap(rows.getFirst().getClass());
|
||||||
// 如果没有需要合并的字段则返回空集
|
// 如果没有需要合并的字段则返回空集
|
||||||
if (CollUtil.isEmpty(mergeFields)) {
|
if (CollUtil.isEmpty(mergeFields)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ public class DropDownOptions {
|
|||||||
sonList.forEach(everySon -> {
|
sonList.forEach(everySon -> {
|
||||||
if (parentGroupByIdMap.containsKey(sonHowToGetParentIdFunction.apply(everySon))) {
|
if (parentGroupByIdMap.containsKey(sonHowToGetParentIdFunction.apply(everySon))) {
|
||||||
// 找到对应的上级
|
// 找到对应的上级
|
||||||
T parentObj = parentGroupByIdMap.get(sonHowToGetParentIdFunction.apply(everySon)).get(0);
|
T parentObj = parentGroupByIdMap.get(sonHowToGetParentIdFunction.apply(everySon)).getFirst();
|
||||||
// 提取名称和ID作为Key
|
// 提取名称和ID作为Key
|
||||||
String key = howToBuildEveryOption.apply(parentObj);
|
String key = howToBuildEveryOption.apply(parentObj);
|
||||||
// Key对应的Value
|
// Key对应的Value
|
||||||
|
|||||||
+2
-2
@@ -276,10 +276,10 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 取第一个
|
// 取第一个
|
||||||
String str = data.get(0);
|
String str = data.getFirst();
|
||||||
rowData.add(str);
|
rowData.add(str);
|
||||||
// 通过移除的方式避免重复
|
// 通过移除的方式避免重复
|
||||||
data.remove(0);
|
data.removeFirst();
|
||||||
// 设置可以继续
|
// 设置可以继续
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public class SnailJobConfig {
|
|||||||
if (StringUtils.isNotBlank(serverName)) {
|
if (StringUtils.isNotBlank(serverName)) {
|
||||||
List<ServiceInstance> instances = discoveryClient.getInstances(serverName);
|
List<ServiceInstance> instances = discoveryClient.getInstances(serverName);
|
||||||
if (CollUtil.isNotEmpty(instances)) {
|
if (CollUtil.isNotEmpty(instances)) {
|
||||||
ServiceInstance instance = instances.get(0);
|
ServiceInstance instance = instances.getFirst();
|
||||||
System.setProperty("snail-job.server.host", instance.getHost());
|
System.setProperty("snail-job.server.host", instance.getHost());
|
||||||
System.setProperty("snail-job.server.port", properties.getPort());
|
System.setProperty("snail-job.server.port", properties.getPort());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ public class PlusDataPermissionHandler {
|
|||||||
}
|
}
|
||||||
Object defaultValue = "-1";
|
Object defaultValue = "-1";
|
||||||
NullSafeStandardEvaluationContext context = new NullSafeStandardEvaluationContext(defaultValue);
|
NullSafeStandardEvaluationContext context = new NullSafeStandardEvaluationContext(defaultValue);
|
||||||
context.addPropertyAccessor(new NullSafePropertyAccessor(context.getPropertyAccessors().get(0), defaultValue));
|
context.addPropertyAccessor(new NullSafePropertyAccessor(context.getPropertyAccessors().getFirst(), defaultValue));
|
||||||
context.setBeanResolver(beanResolver);
|
context.setBeanResolver(beanResolver);
|
||||||
DataPermissionHelper.getContext().forEach(context::setVariable);
|
DataPermissionHelper.getContext().forEach(context::setVariable);
|
||||||
Set<String> conditions = new HashSet<>();
|
Set<String> conditions = new HashSet<>();
|
||||||
|
|||||||
+2
-2
@@ -112,7 +112,7 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
|||||||
Map<Integer, List<DemoCityData>> groupByIdMap =
|
Map<Integer, List<DemoCityData>> groupByIdMap =
|
||||||
cityDataList.stream().collect(Collectors.groupingBy(DemoCityData::getId));
|
cityDataList.stream().collect(Collectors.groupingBy(DemoCityData::getId));
|
||||||
if (groupByIdMap.containsKey(id)) {
|
if (groupByIdMap.containsKey(id)) {
|
||||||
DemoCityData demoCityData = groupByIdMap.get(id).get(0);
|
DemoCityData demoCityData = groupByIdMap.get(id).getFirst();
|
||||||
return DropDownOptions.createOptionValue(demoCityData.getName(), demoCityData.getId());
|
return DropDownOptions.createOptionValue(demoCityData.getName(), demoCityData.getId());
|
||||||
} else {
|
} else {
|
||||||
return StrUtil.EMPTY;
|
return StrUtil.EMPTY;
|
||||||
@@ -206,7 +206,7 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
|||||||
|
|
||||||
sonList.forEach(everySon -> {
|
sonList.forEach(everySon -> {
|
||||||
if (parentGroupByIdMap.containsKey(everySon.getPid())) {
|
if (parentGroupByIdMap.containsKey(everySon.getPid())) {
|
||||||
everySon.setPData(parentGroupByIdMap.get(everySon.getPid()).get(0));
|
everySon.setPData(parentGroupByIdMap.get(everySon.getPid()).getFirst());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -593,7 +593,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNull(table.getPkColumn())) {
|
if (ObjectUtil.isNull(table.getPkColumn())) {
|
||||||
table.setPkColumn(table.getColumns().get(0));
|
table.setPkColumn(table.getColumns().getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -211,7 +211,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
}
|
}
|
||||||
if (!BusinessStatusEnum.initialState(instance.getFlowStatus())) {
|
if (!BusinessStatusEnum.initialState(instance.getFlowStatus())) {
|
||||||
if (task != null && CollUtil.isNotEmpty(nextTasks) && nextTasks.size() == 1
|
if (task != null && CollUtil.isNotEmpty(nextTasks) && nextTasks.size() == 1
|
||||||
&& flwCommonService.applyNodeCode(definition.getId()).equals(nextTasks.get(0).getNodeCode())) {
|
&& flwCommonService.applyNodeCode(definition.getId()).equals(nextTasks.getFirst().getNodeCode())) {
|
||||||
// 如果为画线指定驳回 线条指定为驳回 驳回得节点为申请人节点 则修改流程状态为退回
|
// 如果为画线指定驳回 线条指定为驳回 驳回得节点为申请人节点 则修改流程状态为退回
|
||||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, BusinessStatusEnum.BACK.getStatus(), params, false);
|
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, BusinessStatusEnum.BACK.getStatus(), params, false);
|
||||||
notifyInitiatorIfNeeded(definition, instance, BusinessStatusEnum.BACK.getStatus(), variable);
|
notifyInitiatorIfNeeded(definition, instance, BusinessStatusEnum.BACK.getStatus(), variable);
|
||||||
@@ -266,7 +266,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String applyNodeCode = flwCommonService.applyNodeCode(definition.getId());
|
String applyNodeCode = flwCommonService.applyNodeCode(definition.getId());
|
||||||
return !StringUtils.equals(applyNodeCode, nextTasks.get(0).getNodeCode());
|
return !StringUtils.equals(applyNodeCode, nextTasks.getFirst().getNodeCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyInitiatorIfNeeded(Definition definition, Instance instance, String status, Map<String, Object> variable) {
|
private void notifyInitiatorIfNeeded(Definition definition, Instance instance, String status, Map<String, Object> variable) {
|
||||||
|
|||||||
+1
-1
@@ -165,7 +165,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
|||||||
if (CollUtil.isEmpty(firstBetweenNode)) {
|
if (CollUtil.isEmpty(firstBetweenNode)) {
|
||||||
throw new ServiceException("流程定义缺少申请人节点,请检查流程定义配置");
|
throw new ServiceException("流程定义缺少申请人节点,请检查流程定义配置");
|
||||||
}
|
}
|
||||||
return firstBetweenNode.get(0).getNodeCode();
|
return firstBetweenNode.getFirst().getNodeCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -136,8 +136,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
taskService.mergeVariable(flowInstance, variables);
|
taskService.mergeVariable(flowInstance, variables);
|
||||||
insService.updateById(flowInstance);
|
insService.updateById(flowInstance);
|
||||||
RemoteStartProcessReturn dto = new RemoteStartProcessReturn();
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn();
|
||||||
dto.setProcessInstanceId(taskList.get(0).getInstanceId());
|
dto.setProcessInstanceId(taskList.getFirst().getInstanceId());
|
||||||
dto.setTaskId(taskList.get(0).getId());
|
dto.setTaskId(taskList.getFirst().getId());
|
||||||
// 保存流程实例业务信息
|
// 保存流程实例业务信息
|
||||||
this.buildFlowInstanceBizExt(flowInstance, bizExt);
|
this.buildFlowInstanceBizExt(flowInstance, bizExt);
|
||||||
return dto;
|
return dto;
|
||||||
@@ -170,7 +170,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
}
|
}
|
||||||
RemoteStartProcessReturn dto = new RemoteStartProcessReturn();
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn();
|
||||||
dto.setProcessInstanceId(instance.getId());
|
dto.setProcessInstanceId(instance.getId());
|
||||||
dto.setTaskId(taskList.get(0).getId());
|
dto.setTaskId(taskList.getFirst().getId());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
if (CollUtil.isEmpty(flowHisTasks)) {
|
if (CollUtil.isEmpty(flowHisTasks)) {
|
||||||
throw new ServiceException("流程历史任务不存在,无法添加抄送记录");
|
throw new ServiceException("流程历史任务不存在,无法添加抄送记录");
|
||||||
}
|
}
|
||||||
FlowHisTask flowHisTask = flowHisTasks.get(0);
|
FlowHisTask flowHisTask = flowHisTasks.getFirst();
|
||||||
FlowNode flowNode = new FlowNode();
|
FlowNode flowNode = new FlowNode();
|
||||||
flowNode.setNodeCode(flowHisTask.getTargetNodeCode());
|
flowNode.setNodeCode(flowHisTask.getTargetNodeCode());
|
||||||
flowNode.setNodeName(flowHisTask.getTargetNodeName());
|
flowNode.setNodeName(flowHisTask.getTargetNodeName());
|
||||||
@@ -531,7 +531,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
return nodeCodes;
|
return nodeCodes;
|
||||||
}
|
}
|
||||||
//判断是否配置了固定驳回节点
|
//判断是否配置了固定驳回节点
|
||||||
Node node = nodeCodes.get(0);
|
Node node = nodeCodes.getFirst();
|
||||||
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
|
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
|
||||||
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
|
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user