浏览代码

新增教育计划时选择学习资料附件查询bug处理

jingyuanchao 2 年之前
父节点
当前提交
eca2019f85

+ 1 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/dto/SysLearningMaterialsFileListPageDto.java

@@ -22,6 +22,7 @@ public class SysLearningMaterialsFileListPageDto extends PageRequest {
 
     @ApiModelProperty(value = "学习标题")
     private String title;
+    private String orgPath;
 
     @ApiModelProperty(value = "附件名称")
     private String fileName;

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

@@ -39,6 +39,8 @@ import java.net.URLEncoder;
 import java.util.*;
 import java.util.stream.Stream;
 
+import static com.xunmei.common.core.constant.Constants.TOP_ORG_PARENT_ID;
+
 /**
  * 学习资料Service业务层处理
  *
@@ -59,7 +61,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
             throw new RuntimeException("机构不存在或机构信息缺失!");
         }
         final List<Long> list = dealParentOrgId(request, sysOrg);
-        boolean isTopOrg = ObjectUtil.equal(sysOrg.getParentId(), Constants.TOP_ORG_PARENT_ID);
+        boolean isTopOrg = ObjectUtil.equal(sysOrg.getParentId(), TOP_ORG_PARENT_ID);
         list.remove(request.getOrgId());
         request.setOrgIdList(list);
         request.setUserId(SecurityUtils.getUserId());
@@ -73,7 +75,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         for (SysLearningMaterialsPageVo record : page.getRecords()) {
             record.setNo(page.getRecords().indexOf(record));
         }
-       return TableDataInfo.success(page);
+        return TableDataInfo.success(page);
     }
 
     private List<Long> dealParentOrgId(SysLearningMaterialsPageDto request, SysOrg sysOrg) {
@@ -85,14 +87,21 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         return list;
     }
 
-    private List<Long> dealParentOrgId(Long orgId) {
+    private List<Long> dealParentOrgId(SysLearningMaterialsFileListPageDto request) {
+        Long orgId = request.getOrgId();
         SysOrg sysOrg = remoteOrgService.selectSysOrgById(orgId, SecurityConstants.INNER);
         if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
             throw new RuntimeException("机构不存在或机构信息缺失!");
         }
-        String[] split = sysOrg.getPath().split("-");
+        request.setOrgPath(sysOrg.getPath());
         List<Long> list = new ArrayList<>();
+        if (Constants.TOP_ORG_PARENT_ID.equals(sysOrg.getParentId())) {
+            list.add(orgId);
+            return list;
+        }
+        String[] split = sysOrg.getPath().split("-");
         Stream.of(split).forEach(s -> list.add(Long.valueOf(s)));
+        list.remove(orgId);
         return list;
     }
 
@@ -153,7 +162,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         sysLearningMaterials.setUpdateTime(DateUtils.getNowDate());
         sysLearningMaterials.setFileList(null);
         sysLearningMaterials.setFileNames(null);
-        if (ObjectUtil.isNotEmpty(request.getFileList()) ){
+        if (ObjectUtil.isNotEmpty(request.getFileList())) {
             sysLearningMaterials.setFileList(JSON.toJSONString(request.getFileList()));
             ArrayList<String> list1 = new ArrayList<>();
             request.getFileList().forEach(file -> {
@@ -185,7 +194,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         BeanUtils.copyProperties(request, sysLearningMaterials);
         sysLearningMaterials.setFileList(null);
         sysLearningMaterials.setFileNames(null);
-        if (ObjectUtil.isNotEmpty(request.getFileList()) ){
+        if (ObjectUtil.isNotEmpty(request.getFileList())) {
             sysLearningMaterials.setFileList(JSON.toJSONString(request.getFileList()));
             ArrayList<String> list1 = new ArrayList<>();
             request.getFileList().forEach(file -> {
@@ -237,7 +246,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
 
     @Override
     public TableDataInfo filePageList(SysLearningMaterialsFileListPageDto request) {
-        final List<Long> list = dealParentOrgId(request.getOrgId());
+        final List<Long> list = dealParentOrgId(request);
         request.setOrgIdList(list);
         final IPage<SysLearningMaterialsFileListVo> page = sysLearningMaterialsMapper.selectFilePageList(request.getPageRequest(), request);
         final List<SysLearningMaterialsFileListVo> records = page.getRecords();

+ 89 - 46
soc-modules/soc-modules-core/src/main/resources/mapper/edu/SysLearningMaterialsMapper.xml

@@ -3,7 +3,6 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xunmei.core.edu.mapper.SysLearningMaterialsMapper">
-
     <resultMap type="com.xunmei.common.core.domain.edu.domain.SysLearningMaterials" id="SysLearningMaterialsResult">
         <result property="id" column="id"/>
         <result property="title" column="title"/>
@@ -107,7 +106,7 @@
         u.id as createId,
         m.create_time,
         m.update_time as updateTime,
-        m.file_names as  fileNames
+        m.file_names as fileNames
         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
@@ -116,7 +115,8 @@
         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>
         <if test="request.checkSub==false">
@@ -149,7 +149,7 @@
         u.id as createId,
         m.create_time,
         m.update_time as updateTime,
-        m.file_names as  fileNames
+        m.file_names as fileNames
         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
@@ -172,69 +172,97 @@
             parameterType="com.xunmei.common.core.domain.edu.domain.SysLearningMaterials">
         insert into sys_learning_materials
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">id,
+            <if test="id != null">
+                id,
             </if>
-            <if test="title != null">title,
+            <if test="title != null">
+                title,
             </if>
-            <if test="content != null">content,
+            <if test="content != null">
+                content,
             </if>
-            <if test="knowledgeId != null">knowledge_id,
+            <if test="knowledgeId != null">
+                knowledge_id,
             </if>
-            <if test="orgId != null">org_id,
+            <if test="orgId != null">
+                org_id,
             </if>
-            <if test="orgName != null">org_name,
+            <if test="orgName != null">
+                org_name,
             </if>
-            <if test="orgPath != null">org_path,
+            <if test="orgPath != null">
+                org_path,
             </if>
-            <if test="isOpen != null">is_open,
+            <if test="isOpen != null">
+                is_open,
             </if>
             <if test="fileList != null">
                 file_list,
             </if>
-            <if test="remark != null">remark,
+            <if test="remark != null">
+                remark,
             </if>
-            <if test="deleted != null">deleted,
+            <if test="deleted != null">
+                deleted,
             </if>
-            <if test="createBy != null">create_by,
+            <if test="createBy != null">
+                create_by,
             </if>
-            <if test="createTime != null">create_time,
+            <if test="createTime != null">
+                create_time,
             </if>
-            <if test="updateBy != null">update_by,
+            <if test="updateBy != null">
+                update_by,
             </if>
-            <if test="updateTime != null">updateTime,
+            <if test="updateTime != null">
+                updateTime,
             </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">#{id},
+            <if test="id != null">
+                #{id},
             </if>
-            <if test="title != null">#{title},
+            <if test="title != null">
+                #{title},
             </if>
-            <if test="content != null">#{content},
+            <if test="content != null">
+                #{content},
             </if>
-            <if test="knowledgeId != null">#{knowledgeId},
+            <if test="knowledgeId != null">
+                #{knowledgeId},
             </if>
-            <if test="orgId != null">#{orgId},
+            <if test="orgId != null">
+                #{orgId},
             </if>
-            <if test="orgName != null">#{orgName},
+            <if test="orgName != null">
+                #{orgName},
             </if>
-            <if test="orgPath != null">#{orgPath},
+            <if test="orgPath != null">
+                #{orgPath},
             </if>
-            <if test="isOpen != null">#{isOpen},
+            <if test="isOpen != null">
+                #{isOpen},
             </if>
             <if test="fileList != null">
                 #{fileList},
             </if>
-            <if test="remark != null">#{remark},
+            <if test="remark != null">
+                #{remark},
             </if>
-            <if test="deleted != null">#{deleted},
+            <if test="deleted != null">
+                #{deleted},
             </if>
-            <if test="createBy != null">#{createBy},
+            <if test="createBy != null">
+                #{createBy},
             </if>
-            <if test="createTime != null">#{createTime},
+            <if test="createTime != null">
+                #{createTime},
             </if>
-            <if test="updateBy != null">#{updateBy},
+            <if test="updateBy != null">
+                #{updateBy},
             </if>
-            <if test="updateTime != null">#{updateTime},
+            <if test="updateTime != null">
+                #{updateTime},
             </if>
         </trim>
     </insert>
@@ -243,16 +271,20 @@
             parameterType="com.xunmei.common.core.domain.edu.domain.SysLearningMaterials">
         update sys_learning_materials
         <trim prefix="SET" suffixOverrides=",">
-            <if test="title != null">title =
+            <if test="title != null">
+                title =
                 #{title},
             </if>
-            <if test="content != null">content =
+            <if test="content != null">
+                content =
                 #{content},
             </if>
-            <if test="knowledgeId != null">knowledge_id =
+            <if test="knowledgeId != null">
+                knowledge_id =
                 #{knowledgeId},
             </if>
-            <if test="orgId != null">org_id =
+            <if test="orgId != null">
+                org_id =
                 #{orgId},
             </if>
             <if test="orgName != null">
@@ -283,13 +315,16 @@
                 create_by =
                 #{createBy},
             </if>
-            <if test="createTime != null">create_time =
+            <if test="createTime != null">
+                create_time =
                 #{createTime},
             </if>
-            <if test="updateBy != null">update_by =
+            <if test="updateBy != null">
+                update_by =
                 #{updateBy},
             </if>
-            <if test="updateTime != null">updateTime =
+            <if test="updateTime != null">
+                updateTime =
                 #{updateTime},
             </if>
         </trim>
@@ -308,12 +343,7 @@
             #{id}
         </foreach>
     </delete>
-
-    <select id="selectFilePageList" resultType="com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsFileListVo">
-        select id,org_id as orgId,title as title,org_name as orgName,file_list as file
-
-        from sys_learning_materials m
-        where m.deleted = 0
+    <sql id="filePageList">
         and m.is_open = 1
         and m.file_list is not null
         <if test="request.title != null and request.title != '' ">
@@ -322,11 +352,24 @@
         <if test="request.fileName != null and request.fileName != '' ">
             and m.file_names like concat('%', #{request.fileName}, '%')
         </if>
+    </sql>
+
+    <select id="selectFilePageList" resultType="com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsFileListVo">
+        select id,org_id as orgId,title as title,org_name as orgName,file_list as file
+
+        from sys_learning_materials m
+        where m.deleted = 0
+       <include refid="filePageList"/>
+        <if test="request.orgPath != null and request.orgPath != '' ">
+            and m.org_path like concat(#{request.orgPath}, '%')
+        </if>
         <if test="request.orgIdList.size>0">
-            and m.org_id in
+            or ( m.org_id in
             <foreach collection="request.orgIdList" item="item" open="(" separator="," close=")">
                 #{item}
             </foreach>
+            <include refid="filePageList"/>
+            )
         </if>
         order by m.org_id, m.create_time desc
     </select>