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
7e8a8490
Commit
7e8a8490
authored
Aug 03, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论、标题长度校验
parent
a47dd54d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
5 deletions
+12
-5
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+2
-2
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+5
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+5
-0
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+0
-3
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
7e8a8490
...
@@ -52,9 +52,9 @@ public class ThemeAnalysDO {
...
@@ -52,9 +52,9 @@ public class ThemeAnalysDO {
public
Double
getRank
()
{
public
Double
getRank
()
{
// 质量=帖子质量+用户质量
// 质量=帖子质量+用户质量
double
w
=
(
double
)
(
viewCount
*
0.1
+
forwardCount
*
3
+
commentCount
*
2
+
likeCount
*
1
+
collectCount
*
3
)
+
userWeight
;
double
w
=
(
double
)
(
viewCount
*
0.1
+
forwardCount
*
3
+
commentCount
*
2
+
likeCount
*
1
+
collectCount
*
3
)
+
userWeight
;
double
i
=
1
;
//初试
权重
double
i
=
1
;
// 初始
权重
double
t
=
Double
.
valueOf
(
minuteTillNow
)
/
60
;
double
t
=
Double
.
valueOf
(
minuteTillNow
)
/
60
;
double
g
=
0.1
;
//
时间系数
double
g
=
0.1
;
//
时间系数
return
(
w
+
i
)
/
Math
.
pow
(
t
+
1
,
g
);
return
(
w
+
i
)
/
Math
.
pow
(
t
+
1
,
g
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
7e8a8490
...
@@ -52,6 +52,11 @@ public class CommentManager {
...
@@ -52,6 +52,11 @@ public class CommentManager {
// 评论(对主题)
// 评论(对主题)
// 发表评论(对主题)
// 发表评论(对主题)
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
if
(
req
.
getComment
().
length
()>
500
){
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
}
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
themeId
(
req
.
getThemeId
())
.
themeId
(
req
.
getThemeId
())
.
parentId
(
req
.
getParentId
())
.
parentId
(
req
.
getParentId
())
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
7e8a8490
...
@@ -508,6 +508,11 @@ public class ThemeManager {
...
@@ -508,6 +508,11 @@ public class ThemeManager {
* @param req
* @param req
*/
*/
private
void
checkContent
(
CreateThemeReq
req
)
{
private
void
checkContent
(
CreateThemeReq
req
)
{
if
(
req
.
getTitle
().
length
()>
50
){
throw
new
IllegalArgumentException
(
"长文标题不能超过50字"
);
}
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
ThemeContentReq
themeContentReq
:
req
.
getContent
())
{
for
(
ThemeContentReq
themeContentReq
:
req
.
getContent
())
{
if
(
RelTypeEnum
.
TEXT
.
type
.
equals
(
themeContentReq
.
getType
()))
{
if
(
RelTypeEnum
.
TEXT
.
type
.
equals
(
themeContentReq
.
getType
()))
{
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
7e8a8490
...
@@ -40,9 +40,6 @@ public class CommentService {
...
@@ -40,9 +40,6 @@ public class CommentService {
@Transactional
@Transactional
public
void
insertComment
(
CommentEntity
commentEntity
)
{
public
void
insertComment
(
CommentEntity
commentEntity
)
{
commentEntity
.
setCommentId
(
uuidGenHelper
.
getUuidStr
());
commentEntity
.
setCommentId
(
uuidGenHelper
.
getUuidStr
());
if
(
commentEntity
.
getContent
().
length
()>
500
){
throw
new
IllegalArgumentException
(
"评论内容超过500字"
);
}
commentMapper
.
insert
(
commentEntity
);
commentMapper
.
insert
(
commentEntity
);
//失效缓存
//失效缓存
evictThemeCache
(
commentEntity
.
getThemeId
());
evictThemeCache
(
commentEntity
.
getThemeId
());
...
...
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