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
96e2a984
Commit
96e2a984
authored
Sep 05, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论优化
parent
dde995b4
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
148 additions
and
64 deletions
+148
-64
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
...a/com/tangguo/controller/mobile/MBbsMomentController.java
+20
-10
safe-campus-moment/src/main/java/com/tangguo/controller/pc/BbsMomentController.java
...n/java/com/tangguo/controller/pc/BbsMomentController.java
+1
-1
safe-campus-moment/src/main/java/com/tangguo/domain/bo/FeaturedCommentBO.java
...rc/main/java/com/tangguo/domain/bo/FeaturedCommentBO.java
+38
-0
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
...ent/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
+1
-1
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentCommentService.java
...in/java/com/tangguo/service/IBbsMomentCommentService.java
+2
-9
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentService.java
.../src/main/java/com/tangguo/service/IBbsMomentService.java
+18
-6
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
...com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
+1
-25
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
...n/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
+66
-11
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
...mpus-moment/src/main/resources/mapper/BbsMomentMapper.xml
+1
-1
No files found.
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
View file @
96e2a984
...
...
@@ -5,10 +5,7 @@ import com.tangguo.common.mauth.MobileAuth;
import
com.tangguo.common.mauth.MobileTokenHelper
;
import
com.tangguo.common.utils.PageUtils
;
import
com.tangguo.common.utils.ValidateOperations
;
import
com.tangguo.domain.bo.CommentMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.LikeMomentBO
;
import
com.tangguo.domain.bo.VoteMomentBO
;
import
com.tangguo.domain.bo.*
;
import
com.tangguo.domain.vo.BbsCommentDetailVO
;
import
com.tangguo.domain.vo.BbsMomentListVO
;
import
com.tangguo.domain.vo.BbsVoteOptionVO
;
...
...
@@ -54,7 +51,7 @@ public class MBbsMomentController {
*/
@MobileAuth
@GetMapping
(
"/moments"
)
public
AjaxResult
get
User
Moments
(
String
content
)
{
public
AjaxResult
getMoments
(
String
content
)
{
String
username
=
MobileTokenHelper
.
getUserName
();
PageUtils
.
clearPage
();
List
<
BbsMomentListVO
>
moments
=
this
.
momentService
.
getMoments
(
username
,
content
);
...
...
@@ -69,9 +66,8 @@ public class MBbsMomentController {
*/
@MobileAuth
@GetMapping
(
"/{id}"
)
public
AjaxResult
getUserMoment
(
@PathVariable
Long
id
)
{
String
username
=
MobileTokenHelper
.
getUserName
();
BbsMomentListVO
dbMoment
=
this
.
momentService
.
getMoment
(
id
,
username
);
public
AjaxResult
getMomentDetail
(
@PathVariable
Long
id
)
{
BbsMomentListVO
dbMoment
=
this
.
momentService
.
getMomentDetail
(
id
);
return
AjaxResult
.
success
(
dbMoment
);
}
...
...
@@ -212,8 +208,22 @@ public class MBbsMomentController {
@MobileAuth
@DeleteMapping
(
"/comment/delete/{commentId}"
)
public
AjaxResult
deleteComment
(
@PathVariable
Long
commentId
)
{
String
userName
=
MobileTokenHelper
.
getUserName
();
this
.
momentCommentService
.
deleteComment
(
commentId
,
userName
);
this
.
momentService
.
userDeleteComment
(
commentId
);
return
AjaxResult
.
success
();
}
/**
* 精选评论
*
* @param bo 评论
* @return 精选结果
*/
@MobileAuth
@PostMapping
(
"/comment/featured"
)
public
AjaxResult
featuredComment
(
@RequestBody
FeaturedCommentBO
bo
)
{
ValidateOperations
.
generalValidate
(
bo
);
this
.
momentService
.
userFeaturedComment
(
bo
);
return
AjaxResult
.
success
();
}
...
...
safe-campus-moment/src/main/java/com/tangguo/controller/pc/BbsMomentController.java
View file @
96e2a984
...
...
@@ -52,7 +52,7 @@ public class BbsMomentController extends BaseController {
@PreAuthorize
(
"@ss.hasPermi('bbs:moment:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
BbsMomentListVO
dbMoment
=
this
.
bbsMomentService
.
getMoment
(
id
,
SecurityUtils
.
getUsername
()
);
BbsMomentListVO
dbMoment
=
this
.
bbsMomentService
.
getMoment
Detail
(
id
);
return
success
(
dbMoment
);
}
...
...
safe-campus-moment/src/main/java/com/tangguo/domain/bo/FeaturedCommentBO.java
0 → 100644
View file @
96e2a984
package
com
.
tangguo
.
domain
.
bo
;
import
lombok.Data
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotNull
;
/**
*
*
* @author 谈笑
* @createTime 2025-09-05 11:58:28 星期五
*/
@Data
public
class
FeaturedCommentBO
{
/**
* 动态Id
*/
@NotNull
(
message
=
"动态Id不能为空"
)
private
Long
momentId
;
/**
* 评论Id
*/
@NotNull
(
message
=
"评论Id不能为空"
)
private
Long
commentId
;
/**
* 精选状态:0 取消精选、1 精选
*/
@NotNull
(
message
=
"精选状态不能为空"
)
@Min
(
value
=
0
,
message
=
"精选状态值错误"
)
@Max
(
value
=
1
,
message
=
"精选状态值错误"
)
private
Integer
featuredStatus
;
}
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
View file @
96e2a984
...
...
@@ -28,6 +28,6 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
List
<
BbsMomentListVO
>
selectMoments
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"content"
)
String
content
);
BbsMomentListVO
selectMoment
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"userName"
)
String
userName
);
BbsMomentListVO
selectMoment
Detail
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"userName"
)
String
userName
);
}
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentCommentService.java
View file @
96e2a984
...
...
@@ -2,7 +2,9 @@ package com.tangguo.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tangguo.domain.BbsMomentComment
;
import
com.tangguo.domain.bo.FeaturedCommentBO
;
import
com.tangguo.domain.vo.BbsCommentDetailVO
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
...
...
@@ -59,13 +61,4 @@ public interface IBbsMomentCommentService extends IService<BbsMomentComment> {
*/
List
<
BbsCommentDetailVO
>
getMomentComments
(
Long
momentId
,
String
userName
);
/**
* 删除评论
*
* @param commentId 评论Id
* @param userName 用户名
*/
void
deleteComment
(
Long
commentId
,
String
userName
);
}
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentService.java
View file @
96e2a984
...
...
@@ -2,10 +2,7 @@ package com.tangguo.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.bo.CommentMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.LikeMomentBO
;
import
com.tangguo.domain.bo.VoteMomentBO
;
import
com.tangguo.domain.bo.*
;
import
com.tangguo.domain.vo.BbsMomentListVO
;
import
com.tangguo.domain.vo.BbsUserMomentCountVO
;
...
...
@@ -68,10 +65,9 @@ public interface IBbsMomentService extends IService<BbsMoment> {
* 查询动态详情
*
* @param momentId 动态Id
* @param userName 用户名
* @return 动态列表
*/
BbsMomentListVO
getMoment
(
Long
momentId
,
String
userName
);
BbsMomentListVO
getMoment
Detail
(
Long
momentId
);
/**
...
...
@@ -113,4 +109,20 @@ public interface IBbsMomentService extends IService<BbsMoment> {
*/
void
userCommentMoment
(
CommentMomentBO
bo
);
/**
* 删除评论
*
* @param commentId 评论Id
*/
void
userDeleteComment
(
Long
commentId
);
/**
* 精选评论
*
* @param bo 评论
*/
void
userFeaturedComment
(
FeaturedCommentBO
bo
);
}
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
View file @
96e2a984
...
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.tangguo.common.enums.CommentStatus
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.domain.BbsMomentComment
;
import
com.tangguo.domain.bo.FeaturedCommentBO
;
import
com.tangguo.domain.vo.BbsCommentDetailVO
;
import
com.tangguo.mapper.BbsMomentCommentMapper
;
import
com.tangguo.service.IBbsMomentCommentService
;
...
...
@@ -107,29 +108,4 @@ public class BbsMomentCommentServiceImpl extends ServiceImpl<BbsMomentCommentMap
return
this
.
baseMapper
.
selectMomentComments
(
momentId
,
userName
);
}
/**
* 删除评论
*
* @param commentId 评论Id
* @param userName 用户名
*/
@Override
public
void
deleteComment
(
Long
commentId
,
String
userName
)
{
BbsMomentComment
dbComment
=
this
.
getOne
(
Wrappers
.
lambdaQuery
(
BbsMomentComment
.
class
).
eq
(
BbsMomentComment:
:
getId
,
commentId
)
);
if
(
Objects
.
isNull
(
dbComment
))
{
throw
new
ServiceException
(
"删除失败,未查询到当前动态评论数据。"
);
}
if
(!
dbComment
.
getUserName
().
equals
(
userName
))
{
throw
new
ServiceException
(
"删除失败,没有对当前动态评论的操作权限。"
);
}
BbsMomentComment
updComment
=
new
BbsMomentComment
();
updComment
.
setId
(
dbComment
.
getId
());
updComment
.
setStatus
(
CommentStatus
.
SC
.
getStatus
());
this
.
updateById
(
updComment
);
}
}
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
View file @
96e2a984
...
...
@@ -13,10 +13,7 @@ import com.tangguo.domain.BbsMoment;
import
com.tangguo.domain.BbsMomentAttachment
;
import
com.tangguo.domain.BbsMomentComment
;
import
com.tangguo.domain.BbsMomentVoteOption
;
import
com.tangguo.domain.bo.CommentMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.LikeMomentBO
;
import
com.tangguo.domain.bo.VoteMomentBO
;
import
com.tangguo.domain.bo.*
;
import
com.tangguo.domain.vo.*
;
import
com.tangguo.mapper.BbsMomentMapper
;
import
com.tangguo.service.*
;
...
...
@@ -47,16 +44,16 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
private
IBbsMomentAttachmentService
attachmentsService
;
@Resource
private
IBbsMoment
VoteOptionService
voteOption
Service
;
private
IBbsMoment
LikeService
like
Service
;
@Resource
private
IBbsMoment
CommentService
comment
Service
;
private
IBbsMoment
VoteService
vote
Service
;
@Resource
private
IBbsMoment
LikeService
like
Service
;
private
IBbsMoment
VoteOptionService
voteOption
Service
;
@Resource
private
IBbsMoment
VoteService
vote
Service
;
private
IBbsMoment
CommentService
comment
Service
;
/**
...
...
@@ -128,12 +125,12 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
* 查询动态详情
*
* @param momentId 动态Id
* @param userName 用户名
* @return 动态列表
*/
@Override
public
BbsMomentListVO
getMoment
(
Long
momentId
,
String
userName
)
{
BbsMomentListVO
dbMoment
=
this
.
baseMapper
.
selectMoment
(
momentId
,
userName
);
public
BbsMomentListVO
getMomentDetail
(
Long
momentId
)
{
String
userName
=
MobileTokenHelper
.
getUserName
();
BbsMomentListVO
dbMoment
=
this
.
baseMapper
.
selectMomentDetail
(
momentId
,
userName
);
this
.
fillMoment
(
Collections
.
singletonList
(
dbMoment
),
userName
);
dbMoment
.
setComments
(
null
);
return
dbMoment
;
...
...
@@ -328,6 +325,64 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
}
/**
* 删除评论
*
* @param commentId 评论Id
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
userDeleteComment
(
Long
commentId
)
{
BbsMomentComment
dbComment
=
this
.
commentService
.
getById
(
commentId
);
if
(
Objects
.
isNull
(
dbComment
))
{
throw
new
ServiceException
(
"删除失败,未查询到当前动态评论数据。"
);
}
String
userName
=
MobileTokenHelper
.
getUserName
();
if
(!
dbComment
.
getUserName
().
equals
(
userName
))
{
throw
new
ServiceException
(
"删除失败,没有对当前动态评论的操作权限。"
);
}
BbsMomentComment
updComment
=
new
BbsMomentComment
();
updComment
.
setId
(
dbComment
.
getId
());
updComment
.
setStatus
(
CommentStatus
.
SC
.
getStatus
());
this
.
commentService
.
updateById
(
updComment
);
}
/**
* 精选评论
*
* @param bo 评论
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
userFeaturedComment
(
FeaturedCommentBO
bo
)
{
BbsMoment
dbMoment
=
this
.
getById
(
bo
.
getMomentId
());
if
(
Objects
.
isNull
(
dbMoment
))
{
throw
new
ServiceException
(
"操作失败,未查询到当前动态数据。"
);
}
String
userName
=
MobileTokenHelper
.
getUserName
();
if
(!
dbMoment
.
getUserName
().
equals
(
userName
))
{
throw
new
ServiceException
(
"操作失败,没有对当前动态评论的操作权限。"
);
}
if
(
EnableStatus
.
QY
.
getStatus
()
!=
dbMoment
.
getIsEnableFeaturedComment
())
{
throw
new
ServiceException
(
"操作失败,当前动态未开启评论精选。"
);
}
BbsMomentComment
dbComment
=
this
.
commentService
.
getById
(
bo
.
getCommentId
());
if
(
Objects
.
isNull
(
dbComment
))
{
throw
new
ServiceException
(
"操作失败,未查询到当前动态评论数据。"
);
}
BbsMomentComment
updComment
=
new
BbsMomentComment
();
updComment
.
setId
(
dbComment
.
getId
());
updComment
.
setIsFeatured
(
bo
.
getFeaturedStatus
());
this
.
commentService
.
updateById
(
updComment
);
}
/**
* 构建动态实体
*
...
...
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
View file @
96e2a984
...
...
@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectMoment"
resultType=
"com.tangguo.domain.vo.BbsMomentListVO"
>
<select
id=
"selectMoment
Detail
"
resultType=
"com.tangguo.domain.vo.BbsMomentListVO"
>
SELECT
m.*,
uv.nike_name,
...
...
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