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

用户信息源修改

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