|
@@ -1,9 +1,12 @@
|
|
package com.xy.utils;
|
|
package com.xy.utils;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollStreamUtil;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.experimental.Accessors;
|
|
import lombok.experimental.Accessors;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -26,15 +29,44 @@ public class AlgorithmUtils {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 列表
|
|
|
|
|
|
+ * 列表 (所有数据)
|
|
*
|
|
*
|
|
* @return {@link List}<{@link Algorithm}>
|
|
* @return {@link List}<{@link Algorithm}>
|
|
*/
|
|
*/
|
|
- public static List<Algorithm> list(){
|
|
|
|
|
|
+ public static List<Algorithm> listAll(){
|
|
RedisService redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
RedisService redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
return (List<Algorithm>) redisService.get(REDIS_KEY_LIST);
|
|
return (List<Algorithm>) redisService.get(REDIS_KEY_LIST);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 列表 (启用中的ID和name)
|
|
|
|
+ *
|
|
|
|
+ * @return {@link List}<{@link Algorithm}>
|
|
|
|
+ */
|
|
|
|
+ public static List<Tuple.Tuple2<Long,String>> listIdName(){
|
|
|
|
+ RedisService redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
|
+ List<Algorithm> list = (List<Algorithm>)redisService.get(REDIS_KEY_LIST);
|
|
|
|
+ List<Tuple.Tuple2<Long,String>> listTuple = new ArrayList<>();
|
|
|
|
+ list.forEach(item->{
|
|
|
|
+ if(item.status){
|
|
|
|
+ Tuple.Tuple2<Long,String> idName = new Tuple.Tuple2<>(item.getId(), item.name);
|
|
|
|
+ listTuple.add(idName);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return listTuple;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 返回ID MAP
|
|
|
|
+ * 所有数据
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ public static Map<Long,Algorithm> idMap(){
|
|
|
|
+ RedisService redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
|
+ List<Algorithm> list = (List<Algorithm>)redisService.get(REDIS_KEY_LIST);
|
|
|
|
+ return CollStreamUtil.toIdentityMap(list, Algorithm::getId);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 对象
|
|
* 对象
|
|
@@ -67,7 +99,6 @@ public class AlgorithmUtils {
|
|
private String remark;
|
|
private String remark;
|
|
|
|
|
|
private Boolean status;
|
|
private Boolean status;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|