Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
541d5072
提交
541d5072
authored
10月 02, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
e2bf7e30
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
2 行删除
+31
-2
PostController.java
...a/com/example/afrishop_v3/controllers/PostController.java
+4
-2
Post.java
src/main/java/com/example/afrishop_v3/models/Post.java
+27
-0
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/PostController.java
浏览文件 @
541d5072
...
@@ -151,13 +151,15 @@ public class PostController {
...
@@ -151,13 +151,15 @@ public class PostController {
}
}
@GetMapping
(
"/community/{postId}"
)
@GetMapping
(
"/community/{postId}"
)
public
Optional
<
Post
>
findPost
(
@PathVariable
(
value
=
"postId"
)
String
id
)
{
public
Post
findPost
(
@PathVariable
(
value
=
"postId"
)
String
id
)
{
Optional
<
Post
>
byId
=
repository
.
findById
(
id
);
Optional
<
Post
>
byId
=
repository
.
findById
(
id
);
if
(
byId
.
isPresent
())
{
if
(
byId
.
isPresent
())
{
Post
post
=
byId
.
get
();
Post
post
=
byId
.
get
();
visitPost
(
post
);
visitPost
(
post
);
post
.
retrieveAll
=
true
;
return
post
;
}
}
return
byId
;
return
null
;
}
}
private
List
<
Post
>
postList
(
List
<
Post
>
postList
,
String
userId
)
{
private
List
<
Post
>
postList
(
List
<
Post
>
postList
,
String
userId
)
{
...
...
src/main/java/com/example/afrishop_v3/models/Post.java
浏览文件 @
541d5072
...
@@ -40,6 +40,9 @@ public class Post extends Model {
...
@@ -40,6 +40,9 @@ public class Post extends Model {
@Transient
@Transient
public
boolean
liked
=
false
;
public
boolean
liked
=
false
;
@Transient
public
boolean
retrieveAll
=
false
;
@OneToMany
(
mappedBy
=
"post"
,
cascade
=
CascadeType
.
ALL
)
@OneToMany
(
mappedBy
=
"post"
,
cascade
=
CascadeType
.
ALL
)
public
List
<
Content
>
contentList
=
new
ArrayList
<>();
public
List
<
Content
>
contentList
=
new
ArrayList
<>();
...
@@ -54,6 +57,14 @@ public class Post extends Model {
...
@@ -54,6 +57,14 @@ public class Post extends Model {
return
tags
;
return
tags
;
}
}
public
String
getUsername
()
{
return
userInfo
!=
null
?
userInfo
.
display
()
:
""
;
}
public
String
getAvatar
()
{
return
userInfo
!=
null
?
userInfo
.
getAvatar
()
:
""
;
}
public
TbCfUserInfo
getUser
()
{
public
TbCfUserInfo
getUser
()
{
return
userInfo
;
return
userInfo
;
}
}
...
@@ -102,4 +113,20 @@ public class Post extends Model {
...
@@ -102,4 +113,20 @@ public class Post extends Model {
public
List
<
Hashtag
>
hashtags
()
{
public
List
<
Hashtag
>
hashtags
()
{
return
hashtagList
.
stream
().
map
(
PostHashtag:
:
getHashtag
).
collect
(
Collectors
.
toList
());
return
hashtagList
.
stream
().
map
(
PostHashtag:
:
getHashtag
).
collect
(
Collectors
.
toList
());
}
}
@JsonProperty
public
List
<
String
>
items
()
{
return
contentList
.
stream
().
map
(
Content:
:
getContent
).
collect
(
Collectors
.
toList
());
}
public
TbCfUserInfo
getUserInfo
()
{
return
retrieveAll
?
userInfo
:
null
;
}
public
List
<
Content
>
getContentList
()
{
return
retrieveAll
?
contentList
:
new
ArrayList
<>();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论