|
@@ -1,14 +1,19 @@
|
|
|
package com.doc.biz.service.impl;
|
|
|
|
|
|
+import com.doc.biz.domain.DocFavorite;
|
|
|
import com.doc.biz.domain.DocInfo;
|
|
|
import com.doc.biz.mapper.DocInfoMapper;
|
|
|
+import com.doc.biz.service.IDocFavoriteService;
|
|
|
import com.doc.biz.service.IDocInfoService;
|
|
|
+import com.doc.biz.service.IDocSpaceService;
|
|
|
import com.doc.biz.service.IElasticSearchService;
|
|
|
import com.doc.common.utils.DateUtils;
|
|
|
+import com.doc.common.utils.SecurityUtils;
|
|
|
import com.doc.common.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -23,6 +28,10 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
private DocInfoMapper docInfoMapper;
|
|
|
@Resource
|
|
|
private IElasticSearchService elasticSearchService;
|
|
|
+ @Resource
|
|
|
+ private IDocSpaceService spaceService;
|
|
|
+ @Resource
|
|
|
+ private IDocFavoriteService favoriteService;
|
|
|
|
|
|
/**
|
|
|
* 查询文件基本信息表
|
|
@@ -43,7 +52,26 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<DocInfo> selectDocInfoList(DocInfo docInfo) {
|
|
|
- return docInfoMapper.selectDocInfoList(docInfo);
|
|
|
+ List<DocInfo> list = docInfoMapper.selectDocInfoList(docInfo);
|
|
|
+
|
|
|
+ List<Long> favorites = new ArrayList<>();
|
|
|
+ DocFavorite favorite = new DocFavorite();
|
|
|
+ favorite.setOwner(SecurityUtils.getUserId());
|
|
|
+ favorite.setIsFolder("N");
|
|
|
+
|
|
|
+ favoriteService.selectDocFavoriteList(favorite).forEach(f -> {
|
|
|
+ favorites.add(f.getRelaId());
|
|
|
+ });
|
|
|
+
|
|
|
+ list.forEach(i -> {
|
|
|
+ if (favorites.contains(i.getDocId())) {
|
|
|
+ i.setIsFavorite("Y");
|
|
|
+ }else {
|
|
|
+ i.setIsFavorite("N");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -56,9 +84,9 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
public int insertDocInfo(DocInfo docInfo) {
|
|
|
docInfo.setCreateTime(DateUtils.getNowDate());
|
|
|
int i = docInfoMapper.insertDocInfo(docInfo);
|
|
|
-
|
|
|
elasticSearchService.save(docInfo);
|
|
|
-
|
|
|
+ //改变空间容量
|
|
|
+ spaceService.updateUsedCap(docInfo.getSpaceId());
|
|
|
return i;
|
|
|
}
|
|
|
|
|
@@ -76,6 +104,8 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
if (StringUtils.isNotEmpty(docInfo.getFileId())) {
|
|
|
elasticSearchService.save(docInfo);
|
|
|
}
|
|
|
+ //改变空间容量
|
|
|
+ spaceService.updateUsedCap(docInfo.getSpaceId());
|
|
|
|
|
|
return i;
|
|
|
}
|
|
@@ -88,7 +118,17 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteDocInfoByDocIds(Long[] docIds) {
|
|
|
- return docInfoMapper.deleteDocInfoByDocIds(docIds);
|
|
|
+ List<Long> spaceIds = new ArrayList<>();
|
|
|
+ for (Long docId : docIds) {
|
|
|
+ DocInfo docInfo = selectDocInfoByDocId(docId);
|
|
|
+ spaceIds.add(docInfo.getSpaceId());
|
|
|
+ }
|
|
|
+ int i = docInfoMapper.deleteDocInfoByDocIds(docIds);
|
|
|
+ //改变空间容量
|
|
|
+ for (Long spaceId : spaceIds) {
|
|
|
+ spaceService.updateUsedCap(spaceId);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -99,6 +139,11 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteDocInfoByDocId(Long docId) {
|
|
|
- return docInfoMapper.deleteDocInfoByDocId(docId);
|
|
|
+ DocInfo docInfo = selectDocInfoByDocId(docId);
|
|
|
+ int i = docInfoMapper.deleteDocInfoByDocId(docId);
|
|
|
+ //改变空间容量
|
|
|
+ spaceService.updateUsedCap(docInfo.getSpaceId());
|
|
|
+
|
|
|
+ return i;
|
|
|
}
|
|
|
}
|