From dfcd84c2bca30aa1891bda95d8a4dbc4aecd53c2 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 02 四月 2021 15:44:02 +0800
Subject: [PATCH] fix 数据权限语句null bug

---
 ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
index cacc204..3b6f640 100644
--- a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
+++ b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
@@ -31,7 +31,7 @@
     @Override
     public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
         ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField});
-		return entity2Vo(Collections.singletonList(db)).get(0);
+        return BeanUtil.toBean(db, ${ClassName}Vo.class)
     }
 
     @Override
@@ -53,6 +53,8 @@
 #end
         lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
 #else
+        Object dataScope = bo.getParams().get("dataScope");
+        lqw.apply(dataScope != null, dataScope != null ? dataScope.toString() : null);
         Map<String, Object> params = bo.getParams();
         if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
             lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
@@ -70,9 +72,17 @@
     * @return
     */
     private List<${ClassName}Vo> entity2Vo(Collection<${ClassName}> collection) {
-        return collection.stream()
+        List<${ClassName}Vo> voList = collection.stream()
                 .map(any -> BeanUtil.toBean(any, ${ClassName}Vo.class))
                 .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<${ClassName}> page = (Page<${ClassName}>)collection;
+            Page<${ClassName}Vo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
     }
 
     @Override

--
Gitblit v1.9.3