Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
safe-campus-bbs
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
万成波
safe-campus-bbs
Commits
b72761d6
Commit
b72761d6
authored
Sep 05, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论优化
parent
ba84247c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
28 deletions
+31
-28
safe-campus-common/src/main/java/com/tangguo/common/core/page/TableDataInfo.java
...main/java/com/tangguo/common/core/page/TableDataInfo.java
+1
-1
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
...a/com/tangguo/controller/mobile/MBbsMomentController.java
+1
-2
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentService.java
.../src/main/java/com/tangguo/service/IBbsMomentService.java
+1
-2
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
...n/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
+5
-5
safe-campus-moment/src/main/resources/mapper/BbsMomentCommentMapper.xml
...ment/src/main/resources/mapper/BbsMomentCommentMapper.xml
+4
-3
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
...va/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
+19
-15
No files found.
safe-campus-common/src/main/java/com/tangguo/common/core/page/TableDataInfo.java
View file @
b72761d6
...
@@ -89,7 +89,7 @@ public class TableDataInfo implements Serializable {
...
@@ -89,7 +89,7 @@ public class TableDataInfo implements Serializable {
rspData
.
setCode
(
HttpStatus
.
SUCCESS
);
rspData
.
setCode
(
HttpStatus
.
SUCCESS
);
rspData
.
setMsg
(
"查询成功"
);
rspData
.
setMsg
(
"查询成功"
);
rspData
.
setRows
(
list
);
rspData
.
setRows
(
list
);
rspData
.
setTotal
(
new
PageInfo
(
list
).
getTotal
());
rspData
.
setTotal
(
new
PageInfo
<
Object
>
(
list
).
getTotal
());
return
rspData
;
return
rspData
;
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
View file @
b72761d6
...
@@ -53,9 +53,8 @@ public class MBbsMomentController {
...
@@ -53,9 +53,8 @@ public class MBbsMomentController {
@MobileAuth
@MobileAuth
@GetMapping
(
"/moments"
)
@GetMapping
(
"/moments"
)
public
TableDataInfo
getMoments
(
String
content
)
{
public
TableDataInfo
getMoments
(
String
content
)
{
String
username
=
MobileTokenHelper
.
getUserName
();
PageUtils
.
clearPage
();
PageUtils
.
clearPage
();
List
<
BbsMomentListVO
>
moments
=
this
.
momentService
.
getMoments
(
username
,
content
);
List
<
BbsMomentListVO
>
moments
=
this
.
momentService
.
getMoments
(
content
);
return
TableDataInfo
.
getDataTable
(
moments
);
return
TableDataInfo
.
getDataTable
(
moments
);
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentService.java
View file @
b72761d6
...
@@ -54,11 +54,10 @@ public interface IBbsMomentService extends IService<BbsMoment> {
...
@@ -54,11 +54,10 @@ public interface IBbsMomentService extends IService<BbsMoment> {
/**
/**
* 查询动态列表
* 查询动态列表
*
*
* @param userName 用户名
* @param content 动态内容
* @param content 动态内容
* @return 动态列表
* @return 动态列表
*/
*/
List
<
BbsMomentListVO
>
getMoments
(
String
userName
,
String
content
);
List
<
BbsMomentListVO
>
getMoments
(
String
content
);
/**
/**
...
...
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
View file @
b72761d6
...
@@ -109,12 +109,12 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -109,12 +109,12 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
/**
/**
* 查询动态列表
* 查询动态列表
*
*
* @param userName 用户名
* @param content 动态内容
* @param content 动态内容
* @return 动态列表
* @return 动态列表
*/
*/
@Override
@Override
public
List
<
BbsMomentListVO
>
getMoments
(
String
userName
,
String
content
)
{
public
List
<
BbsMomentListVO
>
getMoments
(
String
content
)
{
String
userName
=
MobileTokenHelper
.
getUserName
();
List
<
BbsMomentListVO
>
dbMoments
=
this
.
baseMapper
.
selectMoments
(
userName
,
content
);
List
<
BbsMomentListVO
>
dbMoments
=
this
.
baseMapper
.
selectMoments
(
userName
,
content
);
this
.
fillMoment
(
dbMoments
,
userName
);
this
.
fillMoment
(
dbMoments
,
userName
);
return
dbMoments
;
return
dbMoments
;
...
@@ -498,19 +498,19 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -498,19 +498,19 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentAttachment
>>>
af
=
CompletableFuture
.
supplyAsync
(()
->
{
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentAttachment
>>>
af
=
CompletableFuture
.
supplyAsync
(()
->
{
List
<
BbsMomentAttachment
>
atts
=
this
.
attachmentsService
.
getAttachments
(
momentIds
);
List
<
BbsMomentAttachment
>
atts
=
this
.
attachmentsService
.
getAttachments
(
momentIds
);
return
atts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentAttachment:
:
getMomentId
));
return
atts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentAttachment:
:
getMomentId
));
});
})
.
exceptionally
(
ex
->
new
HashMap
<>(
0
))
;
// 查询动态投票选项
// 查询动态投票选项
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentVoteOption
>>>
of
=
CompletableFuture
.
supplyAsync
(()
->
{
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentVoteOption
>>>
of
=
CompletableFuture
.
supplyAsync
(()
->
{
List
<
BbsMomentVoteOption
>
opts
=
this
.
voteOptionService
.
getVoteOptions
(
momentIds
);
List
<
BbsMomentVoteOption
>
opts
=
this
.
voteOptionService
.
getVoteOptions
(
momentIds
);
return
opts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentVoteOption:
:
getMomentId
));
return
opts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentVoteOption:
:
getMomentId
));
});
})
.
exceptionally
(
ex
->
new
HashMap
<>(
0
))
;
// 查询动态评论
// 查询动态评论
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentComment
>>>
cf
=
CompletableFuture
.
supplyAsync
(()
->
{
CompletableFuture
<
Map
<
Long
,
List
<
BbsMomentComment
>>>
cf
=
CompletableFuture
.
supplyAsync
(()
->
{
List
<
BbsMomentComment
>
opts
=
this
.
commentService
.
getMomentLimitComments
(
momentIds
,
userName
);
List
<
BbsMomentComment
>
opts
=
this
.
commentService
.
getMomentLimitComments
(
momentIds
,
userName
);
return
opts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentComment:
:
getMomentId
));
return
opts
.
stream
().
collect
(
Collectors
.
groupingBy
(
BbsMomentComment:
:
getMomentId
));
});
})
.
exceptionally
(
ex
->
new
HashMap
<>(
0
))
;
// 等待全部任务处理完毕
// 等待全部任务处理完毕
CompletableFuture
.
allOf
(
af
,
of
,
cf
).
join
();
CompletableFuture
.
allOf
(
af
,
of
,
cf
).
join
();
...
...
safe-campus-moment/src/main/resources/mapper/BbsMomentCommentMapper.xml
View file @
b72761d6
...
@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INNER JOIN
INNER JOIN
(
(
SELECT
SELECT
id, is_enable_featured_comment
id,
user_name,
is_enable_featured_comment
FROM
FROM
bbs_moment
bbs_moment
WHERE
WHERE
...
@@ -71,8 +71,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -71,8 +71,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.status = 1
c.status = 1
AND
AND
(
(
m.is_enable_featured_comment = 1
m.user_name = #{userName}
OR (m.is_enable_featured_comment = 0 AND (c.user_name = #{userName} OR c.is_featured = 1))
OR m.is_enable_featured_comment = 0
OR (m.is_enable_featured_comment = 1 AND (c.user_name = #{userName} OR c.is_featured = 1))
)
)
) AS c
) AS c
WHERE rn
<
= #{rows};
WHERE rn
<
= #{rows};
...
...
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
View file @
b72761d6
...
@@ -70,10 +70,12 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -70,10 +70,12 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
if
(
Objects
.
isNull
(
qwmhSysUser
))
{
if
(
Objects
.
isNull
(
qwmhSysUser
))
{
throw
new
ServiceException
(
"查询用户积分失败,未查询到当前用户数据。"
);
throw
new
ServiceException
(
"查询用户积分失败,未查询到当前用户数据。"
);
}
else
{
}
else
{
// 初始积分
dbUserPoints
=
new
BbsUserPoints
();
dbUserPoints
=
new
BbsUserPoints
();
dbUserPoints
.
setUserName
(
userName
);
dbUserPoints
.
setUserName
(
userName
);
dbUserPoints
.
setAccumulatedPoints
(
0
);
dbUserPoints
.
setAccumulatedPoints
(
0
);
dbUserPoints
.
setCurrentPoints
(
0
);
dbUserPoints
.
setCurrentPoints
(
0
);
// 初始等级
BbsGrade
dbGrade
=
this
.
gradeService
.
getInitialGrade
();
BbsGrade
dbGrade
=
this
.
gradeService
.
getInitialGrade
();
if
(
Objects
.
nonNull
(
dbGrade
))
{
if
(
Objects
.
nonNull
(
dbGrade
))
{
dbUserPoints
.
setGradeCode
(
dbGrade
.
getCode
());
dbUserPoints
.
setGradeCode
(
dbGrade
.
getCode
());
...
@@ -163,21 +165,21 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -163,21 +165,21 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
// 更新用户积分
// 更新用户积分
String
userName
=
detail
.
getUserName
();
String
userName
=
detail
.
getUserName
();
BbsUserPoints
u
serPoints
=
this
.
pointsServiceImpl
.
getAndInitUserPoints
(
userName
);
BbsUserPoints
dbU
serPoints
=
this
.
pointsServiceImpl
.
getAndInitUserPoints
(
userName
);
int
beforeCurrentPoints
=
u
serPoints
.
getCurrentPoints
();
int
beforeCurrentPoints
=
dbU
serPoints
.
getCurrentPoints
();
int
afterCurrentPoints
=
beforeCurrentPoints
+
points
;
int
afterCurrentPoints
=
beforeCurrentPoints
+
points
;
userPoints
.
setCurrentPoints
(
afterCurrentPoints
)
;
int
accumulatedPoints
=
dbUserPoints
.
getAccumulatedPoints
()
+
points
;
int
accumulatedPoints
=
userPoints
.
getAccumulatedPoints
()
+
points
;
dbUserPoints
.
setCurrentPoints
(
afterCurrentPoints
)
;
u
serPoints
.
setAccumulatedPoints
(
accumulatedPoints
);
dbU
serPoints
.
setAccumulatedPoints
(
accumulatedPoints
);
// 更新用户等级
// 更新用户等级
BbsGrade
dbGrade
=
this
.
gradeService
.
getGradeByPoints
(
accumulatedPoints
);
BbsGrade
dbGrade
=
this
.
gradeService
.
getGradeByPoints
(
accumulatedPoints
);
if
(
Objects
.
nonNull
(
dbGrade
)
&&
!
dbGrade
.
getCode
().
equals
(
u
serPoints
.
getGradeCode
()))
{
if
(
Objects
.
nonNull
(
dbGrade
)
&&
!
dbGrade
.
getCode
().
equals
(
dbU
serPoints
.
getGradeCode
()))
{
u
serPoints
.
setGradeName
(
dbGrade
.
getName
());
dbU
serPoints
.
setGradeName
(
dbGrade
.
getName
());
u
serPoints
.
setGradeCode
(
dbGrade
.
getCode
());
dbU
serPoints
.
setGradeCode
(
dbGrade
.
getCode
());
u
serPoints
.
setLastUpgradeTime
(
new
Date
());
dbU
serPoints
.
setLastUpgradeTime
(
new
Date
());
}
}
this
.
updateById
(
u
serPoints
);
this
.
updateById
(
dbU
serPoints
);
// 添加用户积分明细
// 添加用户积分明细
BbsUserPointsDetail
newDetail
=
new
BbsUserPointsDetail
();
BbsUserPointsDetail
newDetail
=
new
BbsUserPointsDetail
();
...
@@ -204,17 +206,19 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -204,17 +206,19 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
throw
new
ServiceException
(
"扣减用户积分失败,扣减的积分分值不能小于0。"
);
throw
new
ServiceException
(
"扣减用户积分失败,扣减的积分分值不能小于0。"
);
}
}
// 更新用户积分
String
userName
=
detail
.
getUserName
();
String
userName
=
detail
.
getUserName
();
BbsUserPoints
u
serPoints
=
this
.
pointsServiceImpl
.
getAndInitUserPoints
(
userName
);
BbsUserPoints
dbU
serPoints
=
this
.
pointsServiceImpl
.
getAndInitUserPoints
(
userName
);
Integer
beforeCurrentPoints
=
u
serPoints
.
getCurrentPoints
();
Integer
beforeCurrentPoints
=
dbU
serPoints
.
getCurrentPoints
();
if
(
points
>
beforeCurrentPoints
)
{
if
(
points
>
beforeCurrentPoints
)
{
throw
new
ServiceException
(
"扣减用户积分失败,当前用户可用积分不足。"
);
throw
new
ServiceException
(
"扣减用户积分失败,当前用户可用积分不足。"
);
}
}
// 更新用户积分
int
afterCurrentPoints
=
beforeCurrentPoints
-
points
;
int
afterCurrentPoints
=
beforeCurrentPoints
-
points
;
userPoints
.
setCurrentPoints
(
afterCurrentPoints
);
BbsUserPoints
updUserPoints
=
new
BbsUserPoints
();
this
.
updateById
(
userPoints
);
updUserPoints
.
setId
(
dbUserPoints
.
getId
());
updUserPoints
.
setCurrentPoints
(
afterCurrentPoints
);
this
.
updateById
(
updUserPoints
);
// 添加用户积分明细
// 添加用户积分明细
BbsUserPointsDetail
newDetail
=
new
BbsUserPointsDetail
();
BbsUserPointsDetail
newDetail
=
new
BbsUserPointsDetail
();
...
...
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