ソースを参照

教育培训代码提交

jingyuanchao 2 年 前
コミット
725765b949

+ 55 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/SysLearningMaterialsDetailVo.java

@@ -0,0 +1,55 @@
+package com.xunmei.common.core.domain.edu.vo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.xunmei.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * 学习资料对象 sys_learning_materials
+ *
+ * @author xunmei
+ * @date 2023-08-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "学习资料新增对象", description = "学习资料")
+    public class SysLearningMaterialsDetailVo extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
+    private Long id;
+    @ApiModelProperty(value = "资料标题")
+    private String title;
+
+    @ApiModelProperty(value = "资料内容")
+    private String content;
+
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
+    @ApiModelProperty(value = "资料类型(知识库标签)")
+    private Long knowledgeId;
+
+    @ApiModelProperty(value = "所属机构")
+    private Long orgId;
+
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "机构path")
+    private String orgPath;
+
+    @ApiModelProperty(value = "是否公开,0:未公开,1:已公开")
+    private Integer isOpen;
+
+    @ApiModelProperty(value = "附件")
+    private List<String> fileList;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+}

+ 36 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/SysLearningMaterialsFileListVo.java

@@ -0,0 +1,36 @@
+package com.xunmei.common.core.domain.edu.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/9/3 15:40
+ */
+@Data
+public class SysLearningMaterialsFileListVo {
+    @ApiModelProperty(value = "学习资料id")
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
+    private Long id;
+
+    @ApiModelProperty(value = "机构id")
+    private Long orgId;
+
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "学习标题")
+    private String title;
+
+    @ApiModelProperty(value = "机构id")
+    private List<String> fileList;
+
+    @JsonIgnore
+    @ApiModelProperty(value = "文件")
+    private String file;
+
+}

+ 9 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/controller/SysLearningMaterialsController.java

@@ -103,14 +103,19 @@ public class SysLearningMaterialsController extends BaseController {
         sysLearningMaterialsService.export(sysLearningMaterials,response);
     }
 
-    /**
-     * 修改学习资料,设置未公开/公开
-     */
-    @ApiOperation(value = "修改SysLearningMaterials")
+
+    @ApiOperation(value = "修改学习资料,设置未公开/公开")
     @RequiresPermissions("core:materials:edit")
     @Log(title = "学习资料", businessType = BusinessType.UPDATE)
     @GetMapping("/{id}/{isOpen}")
     public AjaxResult editOpen(@PathVariable Long id, @PathVariable Integer isOpen) {
         return toAjax(sysLearningMaterialsService.editOpen(id, isOpen));
     }
+
+    @ApiOperation(value = "获取学习资料及文件列表")
+    @GetMapping("/fileList/{orgId}")
+    public AjaxResult fileList(@PathVariable Long orgId) {
+        return AjaxResult.success(sysLearningMaterialsService.fileList(orgId));
+    }
+
 }

+ 4 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/ISysLearningMaterialsService.java

@@ -1,11 +1,12 @@
 package com.xunmei.core.edu.service;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsInsertDto;
+import com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsDetailVo;
+import com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsFileListVo;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.core.domain.edu.domain.SysLearningMaterials;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsPageDto;
@@ -25,7 +26,7 @@ public interface ISysLearningMaterialsService extends IService<SysLearningMateri
      * @param id 学习资料主键
      * @return 学习资料
      */
-    public SysLearningMaterials selectSysLearningMaterialsById(Long id);
+    public SysLearningMaterialsDetailVo selectSysLearningMaterialsById(Long id);
 
     /**
      * 查询学习资料列表
@@ -79,4 +80,5 @@ public interface ISysLearningMaterialsService extends IService<SysLearningMateri
 
     void export(SysLearningMaterialsPageDto sysLearningMaterials, HttpServletResponse response) throws IOException;
 
+    List<SysLearningMaterialsFileListVo> fileList(Long orgId);
 }

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

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
 import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -12,6 +13,8 @@ import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.edu.domain.SysLearningMaterials;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsInsertDto;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsPageDto;
+import com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsDetailVo;
+import com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsFileListVo;
 import com.xunmei.common.core.domain.edu.vo.SysLearningMaterialsPageVo;
 import com.xunmei.common.core.utils.DateHelper;
 import com.xunmei.common.core.utils.DateUtils;
@@ -31,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.*;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
@@ -88,10 +92,14 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
             return;
         }
         String fileList = record.getFileList();
-        List<Map> maps = JSON.parseArray(fileList, Map.class);
-        String name = maps.get(0).get("name").toString();
+        List<String> list = JSON.parseArray(fileList, String.class);
+        List<String> arrayList = new ArrayList<>();
+        for (String fileStr : list) {
+            final Map map = JSON.parseObject(fileStr, Map.class);
+            arrayList.add(map.get("name").toString());
+        }
         // 获取最后一个斜杠后面的字符串
-        record.setFileList(name);
+        record.setFileList(String.join(",", arrayList));
     }
 
     /**
@@ -101,8 +109,12 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
      * @return 学习资料
      */
     @Override
-    public SysLearningMaterials selectSysLearningMaterialsById(Long id) {
-        return sysLearningMaterialsMapper.selectById(id);
+    public SysLearningMaterialsDetailVo selectSysLearningMaterialsById(Long id) {
+        final SysLearningMaterials materials = sysLearningMaterialsMapper.selectById(id);
+        SysLearningMaterialsDetailVo vo = new SysLearningMaterialsDetailVo();
+        BeanUtils.copyProperties(materials, vo);
+        vo.setFileList(ObjectUtil.isNotEmpty(materials.getFileList()) ? JSON.parseArray(materials.getFileList(), String.class) : new ArrayList<>());
+        return vo;
     }
 
     /**
@@ -119,7 +131,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
     /**
      * 新增学习资料
      *
-     * @param sysLearningMaterials 学习资料
+     * @param request 学习资料
      * @return 结果
      */
     @Override
@@ -130,6 +142,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         sysLearningMaterials.setCreateTime(DateUtils.getNowDate());
         sysLearningMaterials.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
         sysLearningMaterials.setUpdateTime(DateUtils.getNowDate());
+        sysLearningMaterials.setFileList(ObjectUtil.isNotEmpty(request.getFileList())?JSON.toJSONString(request.getFileList()):null);
         sysLearningMaterials.setIsOpen(0);
         SysOrg sysOrg = remoteOrgService.selectSysOrgById(sysLearningMaterials.getOrgId(), SecurityConstants.INNER);
         if (sysOrg != null) {
@@ -187,6 +200,26 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
     }
 
     @Override
+    public List<SysLearningMaterialsFileListVo> fileList(Long orgId) {
+        final LambdaQueryWrapper<SysLearningMaterials> wrapper = new LambdaQueryWrapper<>();
+        final SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> remoteOrgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        wrapper.eq(SysLearningMaterials::getIsOpen, 1);
+        wrapper.eq(SysLearningMaterials::getDeleted, 0);
+        wrapper.isNotNull(SysLearningMaterials::getFileList);
+        wrapper.likeRight(SysLearningMaterials::getOrgPath, sysOrg.getPath());
+        final List<SysLearningMaterials> list = sysLearningMaterialsMapper.selectList(wrapper);
+        if (ObjectUtil.isEmpty(list)) {
+            return new ArrayList<>();
+        }
+        return list.stream().map(sysLearningMaterials -> {
+            final SysLearningMaterialsFileListVo sysLearningMaterialsFileListVo = new SysLearningMaterialsFileListVo();
+            BeanUtils.copyProperties(sysLearningMaterials, sysLearningMaterialsFileListVo);
+            sysLearningMaterialsFileListVo.setFileList(JSON.parseArray(sysLearningMaterials.getFileList(), String.class));
+            return sysLearningMaterialsFileListVo;
+        }).collect(Collectors.toList());
+    }
+
+    @Override
     public void export(SysLearningMaterialsPageDto sysLearningMaterials, HttpServletResponse response) throws
             IOException {
         SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> remoteOrgService.selectOrgById(sysLearningMaterials.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);