Forráskód Böngészése

学习资料查询bug修改

jingyuanchao 2 éve
szülő
commit
539db866ad

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/mapper/SysLearningMaterialsMapper.java

@@ -71,4 +71,6 @@ public interface SysLearningMaterialsMapper extends BaseMapper<SysLearningMateri
     Page<SysLearningMaterialsPageVo> selectPageData(@Param("page") Page<SysLearningMaterialsPageVo> page, @Param("request") SysLearningMaterialsPageDto sysLearningMaterials);
 
     IPage<SysLearningMaterialsFileListVo> selectFilePageList(Page<SysLearningMaterialsFileListVo> pageRequest, @Param("request") SysLearningMaterialsFileListPageDto request);
+
+    Page<SysLearningMaterialsPageVo> selectPageDataByTopOrg(Page<SysLearningMaterialsPageVo> pageRequest, @Param("request") SysLearningMaterialsPageDto request);
 }

+ 16 - 7
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/SysLearningMaterialsServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.constant.ErrorMsgConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.edu.domain.SysLearningMaterials;
@@ -53,11 +54,22 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
 
     @Override
     public TableDataInfo selectPage(SysLearningMaterialsPageDto request) {
-        final List<Long> list = dealParentOrgId(request, request.getOrgId());
+        SysOrg sysOrg = remoteOrgService.selectSysOrgById(request.getOrgId(), SecurityConstants.INNER);
+        if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
+            throw new RuntimeException("机构不存在或机构信息缺失!");
+        }
+        final List<Long> list = dealParentOrgId(request, sysOrg);
+        boolean isTopOrg = ObjectUtil.equal(sysOrg.getParentId(), Constants.TOP_ORG_PARENT_ID);
+        list.remove(request.getOrgId());
         request.setOrgIdList(list);
         request.setUserId(SecurityUtils.getUserId());
         //获取数据 默认查询当前及上级机构公开,当前用户创建的的数据
-        Page<SysLearningMaterialsPageVo> page = sysLearningMaterialsMapper.selectPageData(request.getPageRequest(), request);
+        Page<SysLearningMaterialsPageVo> page;
+        if (isTopOrg) {
+            page = sysLearningMaterialsMapper.selectPageDataByTopOrg(request.getPageRequest(), request);
+        } else {
+            page = sysLearningMaterialsMapper.selectPageData(request.getPageRequest(), request);
+        }
         for (SysLearningMaterialsPageVo record : page.getRecords()) {
             extractStringFromUrl(record);
         }
@@ -70,11 +82,8 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         return tableDataInfo;
     }
 
-    private List<Long> dealParentOrgId(SysLearningMaterialsPageDto request, Long orgId) {
-        SysOrg sysOrg = remoteOrgService.selectSysOrgById(orgId, SecurityConstants.INNER);
-        if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
-            throw new RuntimeException("机构不存在或机构信息缺失!");
-        }
+    private List<Long> dealParentOrgId(SysLearningMaterialsPageDto request, SysOrg sysOrg) {
+
         String[] split = sysOrg.getPath().split("-");
         List<Long> list = new ArrayList<>();
         Stream.of(split).forEach(s -> list.add(Long.valueOf(s)));

+ 45 - 7
soc-modules/soc-modules-core/src/main/resources/mapper/edu/SysLearningMaterialsMapper.xml

@@ -115,16 +115,54 @@
         and m.create_by=#{request.userId}
         <include refid="pageRequest"/>
         <if test="request.checkSub==true">
-            or ( m.org_path like concat(#{request.orgPath},'%') and m.is_open = 1 and m.org_path !=#{request.orgPath}
+            or ( m.org_path like concat(#{request.orgPath},'%') and m.is_open = 1 <!--and m.org_path !=#{request.orgPath}-->
             <include refid="pageRequest"/>)
         </if>
-        or ( m.org_id in
-        <foreach collection="request.orgIdList" item="item" open="(" separator="," close=")">
-            #{item}
-        </foreach>
-        and m.is_open = 1
+        <if test="request.checkSub==false">
+            and m.org_id=#{request.orgId}
+        </if>
+        <if test="request.orgIdList.size>0">
+            or ( m.org_id in
+            <foreach collection="request.orgIdList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            and m.is_open = 1
+            <include refid="pageRequest"/>
+            )
+        </if>
+
+        order by m.org_id, m.create_time desc
+    </select>
+
+
+    <select id="selectPageDataByTopOrg" resultType="com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsPageVo">
+        select m.id,
+        title,
+        k.name as knowledgeName,
+        m.org_id,
+        m.org_name,
+        is_open,
+        m.file_list,
+        remark as remark,
+        u.name as create_by,
+        u.id as createId,
+        m.create_time,
+        m.update_time as updateTime
+        from sys_learning_materials m
+        inner join sys_knowledge k on m.knowledge_id = k.id
+        inner join sys_user u on u.id=m.create_by
+        where m.deleted = 0
+        and k.deleted = 0
+        and m.create_by=#{request.userId}
         <include refid="pageRequest"/>
-        )
+
+        <if test="request.checkSub==false">
+            and m.org_id=#{request.orgId}
+        </if>
+        <if test="request.checkSub==true">
+            or ( m.org_path like concat(#{request.orgPath},'%') and m.is_open = 1
+            <include refid="pageRequest"/>)
+        </if>
         order by m.org_id, m.create_time desc
     </select>
 

+ 24 - 8
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfUtil.java

@@ -238,8 +238,8 @@ public class PdfUtil {
                     final Resource[] resources = applicationContext.getResources("classpath:file/black.png");
                     imageData = Image.getInstance(resources[0].getURL());
                 } else {
-                    byte[] bytes = convertFileToByteArray(new File(image));
-                    imageData = Image.getInstance(bytes);
+                  //  byte[] bytes = convertFileToByteArray(new File(image));
+                    imageData = convertFileToByteArray(new File(image));
                 }
                 imageData.scaleAbsolute(100, 100);
                 PdfPCell cell = new PdfPCell(imageData);
@@ -265,11 +265,27 @@ public class PdfUtil {
         return outerTable;
     }
 
-    public static byte[] convertFileToByteArray(File file) throws IOException {
-        FileInputStream fis = new FileInputStream(file);
-        byte[] byteArray = new byte[(int) file.length()];
-        fis.read(byteArray);
-        fis.close();
-        return byteArray;
+    public static Image convertFileToByteArray(File file) throws Exception {
+
+        try {
+            FileInputStream fis = new FileInputStream(file);
+            byte[] byteArray = new byte[(int) file.length()];
+            fis.read(byteArray);
+            fis.close();
+            return Image.getInstance(byteArray);
+        } catch (IOException e) {
+            return getLocalImage();
+        }
+
+    }
+
+    private static Image getLocalImage() {
+        try {
+            final ApplicationContext applicationContext = SpringUtil.getApplicationContext();
+            final Resource[] resources = applicationContext.getResources("classpath:file/black.png");
+            return Image.getInstance(resources[0].getURL());
+        } catch (IOException | BadElementException e) {
+            throw new RuntimeException(e);
+        }
     }
 }