mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2026-06-27 16:14:31 +00:00
!854 update 优化使用getFirst()替代get(0)以提高代码可读性
* update 优化使用getFirst()替代get(0)以提高代码可读性
This commit is contained in:
@@ -97,7 +97,7 @@ public class SysLoginService {
|
||||
sysSocialService.insertByBo(bo);
|
||||
} else {
|
||||
// 更新用户信息
|
||||
bo.setId(list.get(0).getId());
|
||||
bo.setId(list.getFirst().getId());
|
||||
sysSocialService.updateByBo(bo);
|
||||
// 如果要绑定的平台账号已经被绑定过了 是否抛异常自行决断
|
||||
// throw new ServiceException("此平台账号已经被绑定!");
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
||||
}
|
||||
SysUserVo user = loadUser(list.get(0).getUserId());
|
||||
SysUserVo user = loadUser(list.getFirst().getUserId());
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class TreeBuildUtils extends TreeUtil {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,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)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ public class DropDownOptions {
|
||||
sonList.forEach(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
|
||||
String key = howToBuildEveryOption.apply(parentObj);
|
||||
// Key对应的Value
|
||||
|
||||
+2
-2
@@ -282,10 +282,10 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
||||
continue;
|
||||
}
|
||||
// 取第一个
|
||||
String str = data.get(0);
|
||||
String str = data.getFirst();
|
||||
rowData.add(str);
|
||||
// 通过移除的方式避免重复
|
||||
data.remove(0);
|
||||
data.removeFirst();
|
||||
// 设置可以继续
|
||||
flag = true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class PlusDataPermissionHandler {
|
||||
}
|
||||
Object defaultValue = "-1";
|
||||
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);
|
||||
DataPermissionHelper.getContext().forEach(context::setVariable);
|
||||
Set<String> conditions = new HashSet<>();
|
||||
|
||||
+2
-2
@@ -122,7 +122,7 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
||||
Map<Integer, List<DemoCityData>> groupByIdMap =
|
||||
StreamUtils.groupByKey(cityDataList, DemoCityData::getId);
|
||||
if (groupByIdMap.containsKey(id)) {
|
||||
DemoCityData demoCityData = groupByIdMap.get(id).get(0);
|
||||
DemoCityData demoCityData = groupByIdMap.get(id).getFirst();
|
||||
return DropDownOptions.createOptionValue(demoCityData.getName(), demoCityData.getId());
|
||||
} else {
|
||||
return StringUtils.EMPTY;
|
||||
@@ -216,7 +216,7 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
||||
|
||||
sonList.forEach(everySon -> {
|
||||
if (parentGroupByIdMap.containsKey(everySon.getPid())) {
|
||||
everySon.setPData(parentGroupByIdMap.get(everySon.getPid()).get(0));
|
||||
everySon.setPData(parentGroupByIdMap.get(everySon.getPid()).getFirst());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -603,7 +603,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNull(table.getPkColumn())) {
|
||||
table.setPkColumn(table.getColumns().get(0));
|
||||
table.setPkColumn(table.getColumns().getFirst());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -207,7 +207,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
}
|
||||
if (!BusinessStatusEnum.initialState(instance.getFlowStatus())) {
|
||||
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);
|
||||
notifyInitiatorIfNeeded(definition, instance, BusinessStatusEnum.BACK.getStatus(), variable);
|
||||
@@ -274,7 +274,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
}
|
||||
// 只有“退回到申请人”场景需要拦截待办提醒,其余退回/流转仍然保留待办消息。
|
||||
String applyNodeCode = flwCommonService.applyNodeCode(definition.getId());
|
||||
return !StringUtils.equals(applyNodeCode, nextTasks.get(0).getNodeCode());
|
||||
return !StringUtils.equals(applyNodeCode, nextTasks.getFirst().getNodeCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -189,6 +189,6 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
if (CollUtil.isEmpty(firstBetweenNode)) {
|
||||
throw new ServiceException("流程定义缺少申请人节点,请检查流程定义配置");
|
||||
}
|
||||
return firstBetweenNode.get(0).getNodeCode();
|
||||
return firstBetweenNode.getFirst().getNodeCode();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -133,7 +133,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
taskService.mergeVariable(flowInstance, variables);
|
||||
insService.updateById(flowInstance);
|
||||
StartProcessReturnDTO dto = new StartProcessReturnDTO(taskList.get(0).getInstanceId(), taskList.get(0).getId());
|
||||
StartProcessReturnDTO dto = new StartProcessReturnDTO(taskList.getFirst().getInstanceId(), taskList.getFirst().getId());
|
||||
// 保存流程实例业务信息
|
||||
this.buildFlowInstanceBizExt(flowInstance, bizExt);
|
||||
return dto;
|
||||
@@ -164,7 +164,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
if (taskList.size() > 1) {
|
||||
throw new ServiceException("请检查流程第一个环节是否为申请人!");
|
||||
}
|
||||
return new StartProcessReturnDTO(instance.getId(), taskList.get(0).getId());
|
||||
return new StartProcessReturnDTO(instance.getId(), taskList.getFirst().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,7 +345,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
if (CollUtil.isEmpty(flowHisTasks)) {
|
||||
throw new ServiceException("流程历史任务不存在,无法添加抄送记录");
|
||||
}
|
||||
FlowHisTask flowHisTask = flowHisTasks.get(0);
|
||||
FlowHisTask flowHisTask = flowHisTasks.getFirst();
|
||||
FlowNode flowNode = new FlowNode();
|
||||
flowNode.setNodeCode(flowHisTask.getTargetNodeCode());
|
||||
flowNode.setNodeName(flowHisTask.getTargetNodeName());
|
||||
@@ -544,7 +544,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return nodeCodes;
|
||||
}
|
||||
//判断是否配置了固定驳回节点
|
||||
Node node = nodeCodes.get(0);
|
||||
Node node = nodeCodes.getFirst();
|
||||
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
|
||||
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user