|
@@ -22,6 +22,9 @@ import org.springframework.stereotype.Service;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -628,10 +631,18 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
communityUserInfoVo.setSex(sysUser.getSex());
|
|
|
communityUserInfoVo.setUserId(userId);
|
|
|
|
|
|
- //设置关注,粉丝,陪伴数量 文章数量
|
|
|
+ //设置关注,粉丝,陪伴天数 文章数量
|
|
|
communityUserInfoVo.setLikeCount(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().eq("user_id", userId)).size());
|
|
|
communityUserInfoVo.setFansCount(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().eq("like_user_id", userId)).size());
|
|
|
- communityUserInfoVo.setCompanionCount(0);
|
|
|
+
|
|
|
+ Date createTime = sysUser.getCreateTime();
|
|
|
+ // 将 Date 对象转换为 LocalDate 对象
|
|
|
+ LocalDate localCreateTime = createTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ // 计算两个日期之间的天数差
|
|
|
+ long daysDifference = ChronoUnit.DAYS.between(localCreateTime, today);
|
|
|
+ communityUserInfoVo.setCompanionCount((int) daysDifference);
|
|
|
|
|
|
communityUserInfoVo.setArticleCount(communityArticleMapper.selectList(new QueryWrapper<CommunityArticle>()
|
|
|
.eq("user_id",userId)
|