|
|
@@ -6,11 +6,13 @@ 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.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.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.edu.domain.SysLearningMaterials;
|
|
|
+import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsFileListPageDto;
|
|
|
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.dto.SysLearningMaterialsUpdateDto;
|
|
|
@@ -60,7 +62,8 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
|
|
|
} else {
|
|
|
page = new Page<>();
|
|
|
}
|
|
|
- dealParentOrgId(sysLearningMaterials);
|
|
|
+ final List<Long> list = dealParentOrgId(sysLearningMaterials.getOrgId());
|
|
|
+ sysLearningMaterials.setOrgIdList(list);
|
|
|
sysLearningMaterials.setUserId(SecurityUtils.getUserId());
|
|
|
//获取数据
|
|
|
page = sysLearningMaterialsMapper.selectPageData(page, sysLearningMaterials);
|
|
|
@@ -76,16 +79,16 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
- private void dealParentOrgId(SysLearningMaterialsPageDto sysLearningMaterials) {
|
|
|
- SysOrg sysOrg = remoteOrgService.selectSysOrgById(sysLearningMaterials.getOrgId(), SecurityConstants.INNER);
|
|
|
+ private List<Long> dealParentOrgId(Long orgId) {
|
|
|
+ SysOrg sysOrg = remoteOrgService.selectSysOrgById(orgId, SecurityConstants.INNER);
|
|
|
if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
|
|
|
throw new RuntimeException("机构不存在或机构信息缺失!");
|
|
|
}
|
|
|
String[] split = sysOrg.getPath().split("-");
|
|
|
List<Long> list = new ArrayList<>();
|
|
|
Stream.of(split).forEach(s -> list.add(Long.valueOf(s)));
|
|
|
- list.remove(sysLearningMaterials.getOrgId());
|
|
|
- sysLearningMaterials.setOrgIdList(list);
|
|
|
+ //list.remove(sysLearningMaterials.getOrgId());
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
public void extractStringFromUrl(SysLearningMaterialsPageVo record) {
|
|
|
@@ -143,7 +146,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.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
|
|
|
sysLearningMaterials.setIsOpen(0);
|
|
|
SysOrg sysOrg = remoteOrgService.selectSysOrgById(sysLearningMaterials.getOrgId(), SecurityConstants.INNER);
|
|
|
if (sysOrg != null) {
|
|
|
@@ -163,7 +166,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
|
|
|
public int updateSysLearningMaterials(SysLearningMaterialsUpdateDto request) {
|
|
|
final SysLearningMaterials materials = getById(request.getId());
|
|
|
BeanUtils.copyProperties(request, materials);
|
|
|
- materials.setFileList(ObjectUtil.isNotEmpty(request.getFileList())?JSON.toJSONString(request.getFileList()):null);
|
|
|
+ materials.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
|
|
|
materials.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
materials.setUpdateTime(DateUtils.getNowDate());
|
|
|
return sysLearningMaterialsMapper.updateById(materials);
|
|
|
@@ -204,23 +207,18 @@ 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<>();
|
|
|
+ public TableDataInfo filePageList(SysLearningMaterialsFileListPageDto request) {
|
|
|
+ final List<Long> list = dealParentOrgId(request.getOrgId());
|
|
|
+ request.setOrgIdList(list);
|
|
|
+ final IPage<SysLearningMaterialsFileListVo> page = sysLearningMaterialsMapper.selectFilePageList(request.getPageRequest(), request);
|
|
|
+ final List<SysLearningMaterialsFileListVo> records = page.getRecords();
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+ for (SysLearningMaterialsFileListVo record : records) {
|
|
|
+ record.setFileList(ObjectUtil.isNotEmpty(record.getFile()) ? JSON.parseArray(record.getFile(), String.class) : 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());
|
|
|
+ return TableDataInfo.build(page);
|
|
|
}
|
|
|
|
|
|
@Override
|