Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
312f3678
Commit
312f3678
authored
Jul 14, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户信息源修改
parent
3bc5d6c8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
29 deletions
+55
-29
CommentQo.java
...main/java/com/tanpu/community/api/beans/qo/CommentQo.java
+1
-2
ThemeQo.java
...c/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
+2
-3
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+1
-1
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+4
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+2
-21
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+7
-0
TimeUtil.java
...vice/src/main/java/com/tanpu/community/util/TimeUtil.java
+38
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/CommentQo.java
View file @
312f3678
...
@@ -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
Lo
calDateTime
updateTime
;
private
Lo
ng
updateTime
;
@ApiModelProperty
(
value
=
"昵称"
)
@ApiModelProperty
(
value
=
"昵称"
)
private
String
nickName
;
private
String
nickName
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
View file @
312f3678
...
@@ -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
Lo
calDateTime
createTime
;
private
Lo
ng
createTime
;
private
Lo
calDateTime
updateTime
;
private
Lo
ng
updateTime
;
}
}
community-service/src/main/java/com/tanpu/community/controller/CommentController.java
View file @
312f3678
...
@@ -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
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
312f3678
...
@@ -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
)){
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
312f3678
...
@@ -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
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
312f3678
...
@@ -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
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/util/TimeUtil.java
0 → 100644
View file @
312f3678
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"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment