Commit 312f3678 authored by 刘基明's avatar 刘基明

用户信息源修改

parent 3bc5d6c8
......@@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
......@@ -31,7 +30,7 @@ public class CommentQo {
private Integer likeCount;
@ApiModelProperty(value = "评论时间")
private LocalDateTime updateTime;
private Long updateTime;
@ApiModelProperty(value = "昵称")
private String nickName;
......
......@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
......@@ -76,8 +75,8 @@ public class ThemeQo {
@ApiModelProperty(value = "转发的主题")
private FormerThemeQo formerTheme;
private LocalDateTime createTime;
private Long createTime;
private LocalDateTime updateTime;
private Long updateTime;
}
......@@ -40,7 +40,7 @@ public class CommentController {
return CommonResp.success();
}
@ApiOperation("查看评论")
@ApiOperation("评论列表")
@AuthLogin
@PostMapping(value = "/queryComment")
@ResponseBody
......
......@@ -61,8 +61,10 @@ public class CommentManager {
//用户信息
String authorId = commentQo.getAuthorId();
UserInfoEntity userInfo = userInfoService.selectById(authorId);
commentQo.setUserImg(userInfo.getUiHeadimg());
commentQo.setNickName(userInfo.getUiNickname());
if (userInfo!=null){
commentQo.setUserImg(userInfo.getUiHeadimg());
commentQo.setNickName(userInfo.getUiNickname());
}
//是否点赞及点赞数
String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)){
......
......@@ -23,9 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -218,7 +215,7 @@ public class ThemeManager {
String themeId = themeQo.getThemeId();
//迄今时间
themeQo.setUpToNowTime(calUpToNowTime(themeQo.getCreateTime()));
//是否关注作者
String authorId = themeQo.getAuthorId();
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
......@@ -246,8 +243,6 @@ public class ThemeManager {
String themeId = themeQo.getThemeId();
productService.transferAttachement(themeQo);
//迄今时间
themeQo.setUpToNowTime(calUpToNowTime(themeQo.getCreateTime()));
//转发原文
buildFormerTheme(themeQo);
......@@ -272,21 +267,7 @@ public class ThemeManager {
}
//计算迄今时间
private String calUpToNowTime(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
long duration = between.toMinutes();
if (duration < 1) {
return "刚刚";
} else if (duration < 60) {
return duration + "分钟前";
} else if (duration < 60 * 24) {
return duration / 60 + "小时前";
} else if (start.getYear() == LocalDateTime.now().getYear()) {
return start.format(DateTimeFormatter.ofPattern("MM-dd HH:mm:ss"));
}
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
public void delete(String themeId) {
......
......@@ -24,6 +24,8 @@ public class ConvertUtil {
}
ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {});
themeQO.setContent(themeContentQos);
return themeQO;
......@@ -35,6 +37,9 @@ public class ConvertUtil {
}
ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {});
//首页列表使用,限制附件个数为1(1文本+1附件),-》已经改为全部返回
// if (themeContentQos != null && themeContentQos.size() > 2) {
......@@ -42,6 +47,7 @@ public class ConvertUtil {
// }else{
themeQO.setContent(themeContentQos);
// }
return themeQO;
}
......@@ -86,6 +92,7 @@ public class ConvertUtil {
public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo();
BeanUtils.copyProperties(entity, qo);
qo.setUpdateTime(TimeUtil.getTimestampOfDateTime(entity.getUpdateTime()));
return qo;
}
......
package com.tanpu.community.util;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class TimeUtil {
public static long getTimestampOfDateTime(LocalDateTime localDateTime) {
ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant();
return instant.toEpochMilli();
}
public static LocalDateTime getDateTimeOfTimestamp(long timestamp) {
Instant instant = Instant.ofEpochMilli(timestamp);
ZoneId zone = ZoneId.systemDefault();
return LocalDateTime.ofInstant(instant, zone);
}
//计算迄今时间
public static String calUpToNowTime(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
long duration = between.toMinutes();
if (duration < 1) {
return "刚刚";
} else if (duration < 60) {
return duration + "分钟前";
} else if (duration < 60 * 24) {
return duration / 60 + "小时前";
} else if (start.getYear() == LocalDateTime.now().getYear()) {
return start.format(DateTimeFormatter.ofPattern("MM-dd HH:mm:ss"));
}
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
}
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