|
@@ -10,6 +10,8 @@ import com.ruoyi.system.service.ISysDeptService;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.function.BiConsumer;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
public class DeptUstil {
|
|
@@ -44,5 +46,17 @@ public class DeptUstil {
|
|
|
return deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
}
|
|
|
|
|
|
+ public static Map<Long, String> getDeptNameMap() {
|
|
|
+ List<SysDept> deptList = sysDeptService.list();
|
|
|
+ return deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static <T> void assignmentNickName(List<T> list, Function<T, Long> idMapper, BiConsumer<T, String> setNickNameMap) {
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, String> nickNameMapByIds = getDeptNameMap();
|
|
|
+ list.forEach(item -> setNickNameMap.accept(item, nickNameMapByIds.get(idMapper.apply(item))));
|
|
|
+ }
|
|
|
|
|
|
}
|