| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | |
| | | apiScInfoVo.setIndexFile(happySocialCircle.getIndexFile()); |
| | | apiScInfoVo.setContent(happySocialCircle.getContent()); |
| | | apiScInfoVo.setCreatedTime(happySocialCircle.getCreatedTime()); |
| | | |
| | | List<HappyFollow> happyFollows = happyFollowMapper.selectList( |
| | | new LambdaQueryWrapper<HappyFollow>() |
| | | .select(HappyFollow::getId, HappyFollow::getType) |
| | | .eq(HappyFollow::getSourceType, StateUpDownEnum.SOURCE_TYPE_SOCIAL_CIRCLE.getCode()) |
| | | .eq(HappyFollow::getSourceId, happySocialCircle.getId()) |
| | | .in(HappyFollow::getType, Arrays.asList(StateUpDownEnum.LIKE.getCode(), StateUpDownEnum.SHARE.getCode())) |
| | | .eq(HappyFollow::getDeleteFlag, StateUpDownEnum.DOWN.getCode()) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyFollows)){ |
| | | // 使用Stream流操作happyFollows,按照type分类,返回每一个不同type的总数量,并返回一个Map |
| | | Map<Integer, Long> typeCountMap = happyFollows.stream() |
| | | .collect(Collectors.groupingBy(HappyFollow::getType, Collectors.counting())); |
| | | Long zanCnt = ObjectUtil.defaultIfNull(typeCountMap.get(StateUpDownEnum.LIKE.getCode()), 0L); |
| | | apiScInfoVo.setZanCnt(Math.toIntExact(zanCnt)); |
| | | Long sendCnt = ObjectUtil.defaultIfNull(typeCountMap.get(StateUpDownEnum.SHARE.getCode()), 0L); |
| | | apiScInfoVo.setSendCnt(Math.toIntExact(sendCnt)); |
| | | } |
| | | } |
| | | return new FebsResponse().success().data(apiScInfoVo); |
| | | } |