文档库--收藏和订阅

This commit is contained in:
zhn
2022-02-24 10:51:00 +08:00
parent c6e525aaf0
commit d696be01e3
2 changed files with 42 additions and 3 deletions
@@ -28,7 +28,7 @@ import java.util.Date;
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="onl_cgform_collection对象", description="我的收藏")
public class OnlCgformCollection extends BussDocumentLibraryEO implements Serializable {
public class OnlCgformCollection implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@@ -691,9 +691,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//数据字典
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();
//下拉选处理数据字典
List records = infoPage.getRecords();
for (Object record : records) {
List<Map> records = infoPage.getRecords();
List<String> idList = new ArrayList<>();
for (Map record : records) {
Map<String, Object> record1 = (Map) record;
idList.add((String) record1.get("id"));
for (Map.Entry<String, Object> entry : record1.entrySet()) {
List<OnlCgformField> collect = fieldList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()))
@@ -702,8 +704,45 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
dictItem(sysDictItems, entry, collect);
}
}
//收藏和订阅
collectAndSubscribe(records, idList);
return infoPage;
}
/**
* 收藏和订阅
* @param records
* @param idList
*/
private void collectAndSubscribe(List<Map> records, List<String> idList) {
//收藏
LambdaQueryWrapper<OnlCgformCollection> wrapper = new LambdaQueryWrapper<>();
wrapper.in(OnlCgformCollection::getDocumentId,idList);
List<OnlCgformCollection> collectList = iOnlCgformCollectionService.list(wrapper);
List<String> collectIdList = collectList.stream().map(OnlCgformCollection::getDocumentId).collect(Collectors.toList());
//订阅
LambdaQueryWrapper<OnlCgformSubscribe> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(OnlCgformSubscribe::getDocumentId,idList);
List<OnlCgformSubscribe> subscribeList = iOnlCgformSubscribeService.list(lambdaQueryWrapper);
List<String> subscribeIdList = subscribeList.stream().map(OnlCgformSubscribe::getDocumentId).collect(Collectors.toList());
for (Map record : records) {
Map<String, Object> record1 = (Map) record;
String id = (String) record1.get("id");
//收藏标识(0-->未收藏 1-->已收藏)
if(collectIdList.contains(id)){
record1.put("collectFlag","1");
}else{
record1.put("collectFlag","0");
}
//订阅标识
if(subscribeIdList.contains(id)){
record1.put("subscribeFlag","1");
}else{
record1.put("subscribeFlag","0");
}
}
}
/**