From 5ca038d888922e93bf45c7bd37f3c6dce849dcff Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 24 十二月 2021 11:36:02 +0800
Subject: [PATCH] update 调整监控依赖 从 common 迁移到 framework

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/BaseMapperPlus.java |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/BaseMapperPlus.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/BaseMapperPlus.java
index 24f9d91..e11ec94 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/BaseMapperPlus.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/BaseMapperPlus.java
@@ -1,5 +1,7 @@
 package com.ruoyi.common.core.mybatisplus.core;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -30,6 +32,9 @@
      */
     default <V> V selectVoById(Serializable id, Class<V> voClass){
         T obj = this.selectById(id);
+        if (ObjectUtil.isNull(obj)) {
+            return null;
+        }
         return BeanCopyUtils.copy(obj, voClass);
     }
 
@@ -38,8 +43,8 @@
      */
     default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass){
         List<T> list = this.selectBatchIds(idList);
-        if (list == null) {
-            return null;
+        if (CollUtil.isEmpty(list)) {
+            return CollUtil.newArrayList();
         }
         return BeanCopyUtils.copyList(list, voClass);
     }
@@ -49,8 +54,8 @@
      */
     default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass){
         List<T> list = this.selectByMap(map);
-        if (list == null) {
-            return null;
+        if (CollUtil.isEmpty(list)) {
+            return CollUtil.newArrayList();
         }
         return BeanCopyUtils.copyList(list, voClass);
     }
@@ -60,6 +65,9 @@
      */
     default <V> V selectVoOne(Wrapper<T> wrapper, Class<V> voClass) {
         T obj = this.selectOne(wrapper);
+        if (ObjectUtil.isNull(obj)) {
+            return null;
+        }
         return BeanCopyUtils.copy(obj, voClass);
     }
 
@@ -68,8 +76,8 @@
      */
     default <V> List<V> selectVoList(Wrapper<T> wrapper, Class<V> voClass) {
         List<T> list = this.selectList(wrapper);
-        if (list == null) {
-            return null;
+        if (CollUtil.isEmpty(list)) {
+            return CollUtil.newArrayList();
         }
         return BeanCopyUtils.copyList(list, voClass);
     }
@@ -77,11 +85,14 @@
     /**
      * 鍒嗛〉鏌ヨVO
      */
-    default <V> IPage<V> selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) {
+    default <V, P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) {
         IPage<T> pageData = this.selectPage(page, wrapper);
         IPage<V> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
+        if (CollUtil.isEmpty(pageData.getRecords())) {
+            return (P) voPage;
+        }
         voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
-        return voPage;
+        return (P) voPage;
     }
 
 }

--
Gitblit v1.9.3