记得上下班打卡 | git大法好,push需谨慎

Commit ecde213f authored by anjiabin's avatar anjiabin

提交chime社交相关

parent 7b99f97b
package com.liquidnet.service.chime.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.adam.dto.rsc.AdamChimeUinfoDto;
import com.liquidnet.service.chime.biz.ChimeUserBiz;
import com.liquidnet.service.chime.constant.ChimeConstant;
import com.liquidnet.service.chime.dto.ChimeJoinUserCountDto;
import com.liquidnet.service.chime.dto.ChimeUserTagDto;
......@@ -22,6 +24,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Component
......@@ -30,7 +33,9 @@ public class DataUtils {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private RedisUtil redisUtil;
private ChimeUserBiz chimeUserBiz;
/**
* 注册社交用户
......@@ -116,18 +121,18 @@ public class DataUtils {
public List<ChimeJoinUserCountDto> getJoinUserCountList(List<String> performanceIdList){
Aggregation agg = Aggregation.newAggregation(
// 挑选所需的字段,类似select *,*所代表的字段内容
Aggregation.project("joinPerformanceId","avatar"),
Aggregation.project("joinPerformanceId","userId"),
// sql where 语句筛选符合条件的记录
Aggregation.match(Criteria.where("joinPerformanceId").in(performanceIdList)),
// 分组条件,设置分组字段
Aggregation.group("joinPerformanceId")
.first("joinPerformanceId").as("joinPerformanceId")
.addToSet("avatar").as("avatarArray")
.addToSet("userId").as("userIdArray")
.count().as("totalCount"),
// 排序(根据某字段排序 倒序)
// Aggregation.sort(Sort.Direction.DESC,"startDate"),
// 重新挑选字段
Aggregation.project("joinPerformanceId","totalCount","avatarArray")
Aggregation.project("joinPerformanceId","totalCount","userIdArray")
);
AggregationResults<Document> results = mongoTemplate.aggregate(agg, ChimeUserInfoVo.class.getSimpleName(), Document.class);
......@@ -139,8 +144,12 @@ public class DataUtils {
ChimeJoinUserCountDto dto = ChimeJoinUserCountDto.getNew();
dto.setPerformancesId(document.getString("joinPerformanceId"));
dto.setCount(document.getInteger("totalCount"));
List<String> ppl2 = document.getList("avatarArray",String.class);
dto.setAvatarImgList(ppl2);
List<String> ppl2 = document.getList("userIdArray",String.class);
//根据userId获取用户头像
List<AdamChimeUinfoDto> adamChimeUinfoDtoList = chimeUserBiz.getAdamUserInfoDtoList(ppl2);
if(StringUtil.isNotNull(adamChimeUinfoDtoList)){
dto.setAvatarImgList(adamChimeUinfoDtoList.stream().map(AdamChimeUinfoDto::getAvatar).collect(Collectors.toList()));
}
joinUserCountDtoList.add(dto);
});
log.debug("排序后的code列表2:[{}]",results);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment