|
@@ -1,6 +1,7 @@
|
|
|
package com.xynet.marketing.utils.collections.map;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.xynet.marketing.utils.Emptys;
|
|
|
|
|
|
import java.io.Serializable;
|
|
@@ -120,12 +121,13 @@ public class JHashMap<K, V> extends HashMap<K, V> implements JMap<K, V>, Seriali
|
|
|
|
|
|
/**
|
|
|
* 将对象List转为MapList
|
|
|
+ *
|
|
|
* @param list
|
|
|
- * @return
|
|
|
* @param <T>
|
|
|
+ * @return
|
|
|
*/
|
|
|
public static <T> List<Map<String, Object>> copy(List<T> list) {
|
|
|
- if(Emptys.check(list)){
|
|
|
+ if (Emptys.check(list)) {
|
|
|
List<Map<String, Object>> result = new ArrayList<>(list.size());
|
|
|
list.forEach(item -> {
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(item);
|
|
@@ -138,15 +140,32 @@ public class JHashMap<K, V> extends HashMap<K, V> implements JMap<K, V>, Seriali
|
|
|
|
|
|
/**
|
|
|
* 将对象转为Map
|
|
|
+ *
|
|
|
* @param obj
|
|
|
- * @return
|
|
|
* @param <T>
|
|
|
+ * @return
|
|
|
*/
|
|
|
public static <T> Map<String, Object> copy(T obj) {
|
|
|
- if(Emptys.check(obj)){
|
|
|
+ if (Emptys.check(obj)) {
|
|
|
List<Map<String, Object>> copy = copy(Arrays.asList(obj));
|
|
|
return copy.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将分页对象转为Map分页对象
|
|
|
+ * @param page
|
|
|
+ * @return
|
|
|
+ * @param <T>
|
|
|
+ */
|
|
|
+ public static <T> Page<Map<String, Object>> copy(Page<T> page) {
|
|
|
+ Page<Map<String, Object>> page2 = new Page();
|
|
|
+ page2.setPages(page.getPages()).setCurrent(page.getCurrent()).setSize(page.getSize()).setTotal(page.getTotal());
|
|
|
+ if (page.getRecords().size() > 0) {
|
|
|
+ List<Map<String, Object>> copy = copy(page.getRecords());
|
|
|
+ page2.setRecords(copy);
|
|
|
+ }
|
|
|
+ return page2;
|
|
|
+ }
|
|
|
}
|