|
@@ -17,6 +17,7 @@ import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.time.temporal.Temporal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -39,7 +40,7 @@ public class CommunityAccompanyImpl implements ICommunityAccompanyService {
|
|
|
|
|
|
@Override
|
|
|
public CommunityAccompany selectCommunityAccompanyById(Long userId) {
|
|
|
-
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
CommunityAccompany communityAccompany = new CommunityAccompany();
|
|
|
|
|
|
//获取当前用户信息 天数
|
|
@@ -65,7 +66,7 @@ public class CommunityAccompanyImpl implements ICommunityAccompanyService {
|
|
|
}));
|
|
|
//如果用户文章数量不为空则执行以下的操作
|
|
|
if (communityArticles != null){
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+
|
|
|
//设置用户创作数
|
|
|
communityAccompany.setCreationCount((long) communityArticles.size());
|
|
|
|
|
@@ -108,19 +109,21 @@ public class CommunityAccompanyImpl implements ICommunityAccompanyService {
|
|
|
|
|
|
if (fans != 0 ){
|
|
|
communityAccompany.setFan(fans);
|
|
|
+ //粉丝数占比
|
|
|
+ List<CommunityUserLike> userLikeFan = new ArrayList<>(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>()
|
|
|
+ .select("like_user_id", "COUNT(1) as count")
|
|
|
+ .groupBy("like_user_id")
|
|
|
+ .having("COUNT(*) <= {0}", fans)
|
|
|
+ .orderByDesc("count"))) ;
|
|
|
+
|
|
|
+ //计算总人数
|
|
|
+ List<CommunityUserLike> userLikeFans = new ArrayList<>(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>()
|
|
|
+ .select("like_user_id", "COUNT(1) as count")
|
|
|
+ .groupBy("like_user_id")));
|
|
|
+ Double ReadPercent = Double.valueOf(df.format((double) userLikeFan.size() / userLikeFans.size() * 100));
|
|
|
+ communityAccompany.setFanPercent(ReadPercent);
|
|
|
}
|
|
|
|
|
|
- //粉丝数占比
|
|
|
- CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>()
|
|
|
- .select("like_user_id", "COUNT(1) as count")
|
|
|
- .groupBy("like_user_id")
|
|
|
- .orderByDesc("count")
|
|
|
- .last("LIMIT 1"));
|
|
|
-
|
|
|
-
|
|
|
- System.out.println(communityUserLike);
|
|
|
-
|
|
|
-
|
|
|
return communityAccompany;
|
|
|
}
|
|
|
|