Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
40a0e9c0
提交
40a0e9c0
authored
9月 24, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
221e07a3
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
34 行增加
和
20 行删除
+34
-20
PostController.java
...a/com/example/afrishop_v3/controllers/PostController.java
+20
-15
Content.java
src/main/java/com/example/afrishop_v3/models/Content.java
+3
-0
ContentTag.java
src/main/java/com/example/afrishop_v3/models/ContentTag.java
+1
-1
Post.java
src/main/java/com/example/afrishop_v3/models/Post.java
+2
-2
PostHashtag.java
...main/java/com/example/afrishop_v3/models/PostHashtag.java
+4
-1
PostLike.java
src/main/java/com/example/afrishop_v3/models/PostLike.java
+2
-0
Tag.java
src/main/java/com/example/afrishop_v3/models/Tag.java
+2
-1
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/PostController.java
浏览文件 @
40a0e9c0
...
...
@@ -201,10 +201,9 @@ public class PostController {
RedirectAttributes
redirectAttributes
)
throws
IOException
{
TbCfUserInfo
user
=
this
.
user
.
user
();
post
.
setUser
(
user
);
repository
.
save
(
post
);
//
repository.save(post);
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
thumbList
=
new
ArrayList
<>();
List
<
Content
>
contents
=
new
ArrayList
<>();
if
(
thumbs
!=
null
)
{
for
(
MultipartFile
file
:
thumbs
)
{
...
...
@@ -229,13 +228,13 @@ public class PostController {
String
string
=
UploadController
.
sendFile
(
sb
.
toString
(),
api
);
list
.
add
(
string
);
Content
content
=
new
Content
();
content
.
setPost
(
post
);
//
content.setPost(post);
content
.
setImage
(
true
);
// content.path = store.toFile().getAbsolutePath();
content
.
setContent
(
string
);
content
.
setSize
(
file
.
getSize
());
contentRepository
.
save
(
content
);
contents
.
add
(
content
);
post
.
contentList
.
add
(
content
);
//contentRepository.save
(content);
}
}
...
...
@@ -256,12 +255,12 @@ public class PostController {
Optional
<
Hashtag
>
byName
=
hashtagRepository
.
findByName
(
hashtag
.
getName
());
hashtag
=
hashtagRepository
.
existsByName
(
hashtag
.
getName
())
&&
byName
.
isPresent
()
?
byName
.
get
()
:
hashtag
Repository
.
save
(
hashtag
)
;
hashtag
;
PostHashtag
postHashtag
=
new
PostHashtag
();
postHashtag
.
setHashtag
(
hashtag
);
postHashtag
.
setPost
(
post
);
//
postHashtag.setPost(post);
if
(
!
postHashtagRepository
.
existsByHashtagNameAndPostId
(
hashtag
.
getName
(),
post
.
getId
())
)
{
post
HashtagRepository
.
save
(
postHashtag
);
post
.
hashtagList
.
add
(
postHashtag
);
}
}
}
...
...
@@ -270,8 +269,8 @@ public class PostController {
int
index
=
0
;
int
vid
=
0
;
for
(
JsonTag
jsonTag
:
tags
)
{
if
(
contents
.
size
()
>
index
)
{
Content
content
=
contents
.
get
(
index
);
if
(
post
.
contentList
.
size
()
>
index
)
{
Content
content
=
post
.
contentList
.
get
(
index
);
content
.
setImage
(
jsonTag
.
isImage
());
if
(!
jsonTag
.
isImage
())
{
if
(
vid
<
thumbList
.
size
())
{
...
...
@@ -280,7 +279,7 @@ public class PostController {
vid
++;
}
}
contentRepository
.
save
(
content
);
//
contentRepository.save(content);
for
(
Position
position
:
jsonTag
.
list
)
{
Tag
tag
=
position
.
getTag
();
...
...
@@ -291,22 +290,22 @@ public class PostController {
if
(
b
)
{
item
=
itemRepository
.
findByItemId
(
item
.
getItemId
());
}
else
{
item
=
itemRepository
.
save
(
item
);
//
item = itemRepository.save(item);
}
tag
.
setItem
(
item
);
ContentTag
contentTag
=
new
ContentTag
();
if
(!
tagRepository
.
existsByTagName
(
tag
.
getTagName
()))
{
tagRepository
.
save
(
tag
);
//
tagRepository.save(tag);
}
else
{
tag
=
tagRepository
.
findByTagName
(
tag
.
getTagName
());
}
contentTag
.
setTag
(
tag
);
contentTag
.
setX
(
position
.
getX
());
contentTag
.
setY
(
position
.
getY
());
contentTag
.
setContent
(
content
);
postTagRepository
.
save
(
contentTag
);
//
contentTag.setContent(content);
content
.
contentTags
.
add
(
contentTag
);
}
index
++;
}
...
...
@@ -314,6 +313,12 @@ public class PostController {
}
//redirectAttributes.addFlashAttribute();
try
{
repository
.
save
(
post
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
e
.
getMessage
());
}
return
list
;
}
...
...
src/main/java/com/example/afrishop_v3/models/Content.java
浏览文件 @
40a0e9c0
...
...
@@ -27,6 +27,9 @@ public class Content extends Model {
private
boolean
isImage
;
@OneToMany
(
mappedBy
=
"content"
,
cascade
=
CascadeType
.
ALL
)
public
List
<
ContentTag
>
contentTags
=
new
ArrayList
<>();
public
void
setThumbnail
(
String
thumbnail
)
{
...
...
src/main/java/com/example/afrishop_v3/models/ContentTag.java
浏览文件 @
40a0e9c0
...
...
@@ -17,7 +17,7 @@ public class ContentTag extends Model {
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
private
Content
content
;
@ManyToOne
()
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
private
Tag
tag
;
private
double
x
;
...
...
src/main/java/com/example/afrishop_v3/models/Post.java
浏览文件 @
40a0e9c0
...
...
@@ -41,12 +41,12 @@ public class Post extends Model {
public
boolean
liked
=
false
;
@OneToMany
(
mappedBy
=
"post"
)
@OneToMany
(
mappedBy
=
"post"
,
cascade
=
CascadeType
.
ALL
)
public
List
<
Content
>
contentList
=
new
ArrayList
<>();
@JsonIgnore
@OneToMany
(
mappedBy
=
"post"
)
@OneToMany
(
mappedBy
=
"post"
,
cascade
=
CascadeType
.
ALL
)
public
List
<
PostHashtag
>
hashtagList
=
new
ArrayList
<>();
...
...
src/main/java/com/example/afrishop_v3/models/PostHashtag.java
浏览文件 @
40a0e9c0
...
...
@@ -3,16 +3,19 @@ package com.example.afrishop_v3.models;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
@Entity
@Getter
@Setter
@Table
(
name
=
"post_hashtag_v2"
)
public
class
PostHashtag
extends
Model
{
@ManyToOne
private
Post
post
;
@ManyToOne
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
private
Hashtag
hashtag
;
public
void
setPost
(
Post
post
)
{
...
...
src/main/java/com/example/afrishop_v3/models/PostLike.java
浏览文件 @
40a0e9c0
...
...
@@ -7,10 +7,12 @@ import lombok.Setter;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
@Entity
@Getter
@Setter
@Table
(
name
=
"post_like_v2"
)
public
class
PostLike
extends
Model
{
@JsonIgnore
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
...
...
src/main/java/com/example/afrishop_v3/models/Tag.java
浏览文件 @
40a0e9c0
...
...
@@ -4,6 +4,7 @@ import lombok.Getter;
import
lombok.Setter
;
import
org.hibernate.annotations.Formula
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
...
...
@@ -11,7 +12,7 @@ import javax.persistence.ManyToOne;
@Getter
@Setter
public
class
Tag
extends
Model
{
@ManyToOne
()
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
protected
Item
item
;
protected
String
tagName
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论