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
0d2c4a9c
Commit
0d2c4a9c
authored
Sep 30, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
0230113b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
79 additions
and
49 deletions
+79
-49
safe-campus-admin/src/main/java/com/tangguo/web/controller/system/SysLoginController.java
...com/tangguo/web/controller/system/SysLoginController.java
+4
-2
safe-campus-admin/src/test/java/com/tangguo/ApplicationTest.java
...mpus-admin/src/test/java/com/tangguo/ApplicationTest.java
+0
-6
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
...a/com/tangguo/controller/mobile/MBbsMomentController.java
+4
-2
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
...ent/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
+18
-0
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
...com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
+0
-1
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
...n/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
+20
-32
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsTopicServiceImpl.java
...in/java/com/tangguo/service/impl/BbsTopicServiceImpl.java
+0
-1
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
...mpus-moment/src/main/resources/mapper/BbsMomentMapper.xml
+33
-3
safe-campus-points/src/main/java/com/tangguo/controller/BbsPointsGoodsController.java
...java/com/tangguo/controller/BbsPointsGoodsController.java
+0
-1
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
...va/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
+0
-1
No files found.
safe-campus-admin/src/main/java/com/tangguo/web/controller/system/SysLoginController.java
View file @
0d2c4a9c
...
@@ -8,9 +8,9 @@ import com.tangguo.common.core.domain.entity.SysMenu;
...
@@ -8,9 +8,9 @@ import com.tangguo.common.core.domain.entity.SysMenu;
import
com.tangguo.common.core.domain.entity.SysUser
;
import
com.tangguo.common.core.domain.entity.SysUser
;
import
com.tangguo.common.core.domain.model.LoginBody
;
import
com.tangguo.common.core.domain.model.LoginBody
;
import
com.tangguo.common.core.domain.model.LoginUser
;
import
com.tangguo.common.core.domain.model.LoginUser
;
import
com.tangguo.common.core.domain.model.WxcpCodeLogin
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.common.utils.SecurityUtils
;
import
com.tangguo.common.utils.SecurityUtils
;
import
com.tangguo.common.core.domain.model.WxcpCodeLogin
;
import
com.tangguo.framework.config.ServerConfig
;
import
com.tangguo.framework.config.ServerConfig
;
import
com.tangguo.framework.web.service.SysLoginService
;
import
com.tangguo.framework.web.service.SysLoginService
;
import
com.tangguo.framework.web.service.SysPermissionService
;
import
com.tangguo.framework.web.service.SysPermissionService
;
...
@@ -28,7 +28,9 @@ import org.springframework.web.bind.annotation.PostMapping;
...
@@ -28,7 +28,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
/**
/**
* 登录验证
* 登录验证
...
...
safe-campus-admin/src/test/java/com/tangguo/ApplicationTest.java
View file @
0d2c4a9c
package
com
.
tangguo
;
package
com
.
tangguo
;
import
com.tangguo.common.constant.ActiveMQConstant
;
import
com.tangguo.common.domain.PointsDetail
;
import
me.chanjar.weixin.cp.api.WxCpOAuth2Service
;
import
me.chanjar.weixin.cp.api.WxCpOAuth2Service
;
import
me.chanjar.weixin.cp.api.WxCpService
;
import
me.chanjar.weixin.cp.api.WxCpService
;
import
org.apache.activemq.ActiveMQConnectionFactory
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.jms.core.MessagePostProcessor
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ActiveProfiles
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.jms.*
;
/**
/**
*
*
...
...
safe-campus-moment/src/main/java/com/tangguo/controller/mobile/MBbsMomentController.java
View file @
0d2c4a9c
...
@@ -196,8 +196,10 @@ public class MBbsMomentController {
...
@@ -196,8 +196,10 @@ public class MBbsMomentController {
*/
*/
@DeleteMapping
(
"/comment/delete/{commentId}"
)
@DeleteMapping
(
"/comment/delete/{commentId}"
)
public
AjaxResult
deleteComment
(
@PathVariable
Long
commentId
)
{
public
AjaxResult
deleteComment
(
@PathVariable
Long
commentId
)
{
this
.
momentService
.
userDeleteComment
(
commentId
);
synchronized
(
String
.
valueOf
(
commentId
).
intern
())
{
return
AjaxResult
.
success
();
this
.
momentService
.
userDeleteComment
(
commentId
);
return
AjaxResult
.
success
();
}
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
View file @
0d2c4a9c
...
@@ -31,4 +31,22 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
...
@@ -31,4 +31,22 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
BbsMomentListVO
selectMomentDetail
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"userName"
)
String
userName
);
BbsMomentListVO
selectMomentDetail
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"userName"
)
String
userName
);
int
incrMomentLikeCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
int
decrMomentLikeCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
int
incrMomentCommentCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
int
decrMomentCommentCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
int
incrMomentVoteCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
int
decrMomentVoteCount
(
@Param
(
"momentId"
)
Long
momentId
,
@Param
(
"count"
)
int
count
);
}
}
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentCommentServiceImpl.java
View file @
0d2c4a9c
...
@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
...
@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
...
...
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
View file @
0d2c4a9c
...
@@ -43,9 +43,6 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -43,9 +43,6 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
@Resource
@Resource
private
ApplicationEventPublisher
eventPublisher
;
private
ApplicationEventPublisher
eventPublisher
;
@Resource
private
BbsMomentMapper
bbsMomentMapper
;
@Resource
@Resource
private
IBbsMomentAttachmentService
attachmentsService
;
private
IBbsMomentAttachmentService
attachmentsService
;
...
@@ -245,32 +242,27 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -245,32 +242,27 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw
new
ServiceException
(
"点赞失败,未查询到当前动态数据。"
);
throw
new
ServiceException
(
"点赞失败,未查询到当前动态数据。"
);
}
}
Long
dbMomentId
=
dbMoment
.
getId
();
String
username
=
SecurityUtils
.
getUsername
();
String
username
=
SecurityUtils
.
getUsername
();
long
likeStatus
=
this
.
likeService
.
getUserMomentLikeCount
(
dbMoment
.
getId
(),
username
);
long
likeStatus
=
this
.
likeService
.
getUserMomentLikeCount
(
dbMomentId
,
username
);
int
likeCount
=
dbMoment
.
getLikeCount
();
if
(
LikeStatus
.
LIKE
.
getStatus
()
==
bo
.
getLikeStatus
())
{
if
(
LikeStatus
.
LIKE
.
getStatus
()
==
bo
.
getLikeStatus
())
{
if
(
likeStatus
>
0
)
{
if
(
likeStatus
>
0
)
{
throw
new
ServiceException
(
"点赞失败,已对当前动态点赞。"
);
throw
new
ServiceException
(
"点赞失败,已对当前动态点赞。"
);
}
else
{
}
else
{
this
.
likeService
.
addMomentLike
(
dbMoment
.
getId
()
,
username
);
this
.
likeService
.
addMomentLike
(
dbMoment
Id
,
username
);
likeCount
++
;
this
.
baseMapper
.
incrMomentLikeCount
(
dbMomentId
,
1
)
;
}
}
}
else
{
}
else
{
if
(
likeStatus
<
1
)
{
if
(
likeStatus
<
1
)
{
throw
new
ServiceException
(
"取消失败,没有对当前动态点赞。"
);
throw
new
ServiceException
(
"取消失败,没有对当前动态点赞。"
);
}
else
{
}
else
{
this
.
likeService
.
deleteMomentLike
(
dbMoment
.
getId
()
,
username
);
this
.
likeService
.
deleteMomentLike
(
dbMoment
Id
,
username
);
likeCount
--
;
this
.
baseMapper
.
decrMomentLikeCount
(
dbMomentId
,
1
)
;
}
}
}
}
// 更新动态点赞人数
BbsMoment
updMoment
=
new
BbsMoment
();
updMoment
.
setId
(
dbMoment
.
getId
());
updMoment
.
setLikeCount
(
likeCount
);
this
.
updateById
(
updMoment
);
// 发布用户操作事件
// 发布用户操作事件
OperateEvent
operateEvent
=
new
OperateEvent
(
username
,
OperateType
.
DZDT
);
OperateEvent
operateEvent
=
new
OperateEvent
(
username
,
OperateType
.
DZDT
);
this
.
eventPublisher
.
publishEvent
(
operateEvent
);
this
.
eventPublisher
.
publishEvent
(
operateEvent
);
...
@@ -293,20 +285,21 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -293,20 +285,21 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw
new
ServiceException
(
"投票失败,当前动态未开启投票。"
);
throw
new
ServiceException
(
"投票失败,当前动态未开启投票。"
);
}
}
Long
dbMomentId
=
dbMoment
.
getId
();
String
username
=
SecurityUtils
.
getUsername
();
String
username
=
SecurityUtils
.
getUsername
();
long
voteCount
=
this
.
voteService
.
getUserMomentVoteCount
(
dbMoment
.
getId
()
,
username
);
long
voteCount
=
this
.
voteService
.
getUserMomentVoteCount
(
dbMoment
Id
,
username
);
if
(
voteCount
>
0
)
{
if
(
voteCount
>
0
)
{
throw
new
ServiceException
(
"投票失败,已对当前动态投票。"
);
throw
new
ServiceException
(
"投票失败,已对当前动态投票。"
);
}
}
String
optionCode
=
bo
.
getOptionCode
();
String
optionCode
=
bo
.
getOptionCode
();
BbsMomentVoteOption
dbOption
=
this
.
voteOptionService
.
getVoteOption
(
dbMoment
.
getId
()
,
optionCode
);
BbsMomentVoteOption
dbOption
=
this
.
voteOptionService
.
getVoteOption
(
dbMoment
Id
,
optionCode
);
if
(
Objects
.
isNull
(
dbOption
))
{
if
(
Objects
.
isNull
(
dbOption
))
{
throw
new
ServiceException
(
"投票失败,未查询到当前投票选项数据。"
);
throw
new
ServiceException
(
"投票失败,未查询到当前投票选项数据。"
);
}
}
// 添加投票记录
// 添加投票记录
this
.
voteService
.
addMomentVoteCount
(
dbMoment
.
getId
()
,
username
,
optionCode
);
this
.
voteService
.
addMomentVoteCount
(
dbMoment
Id
,
username
,
optionCode
);
// 更新投票选项投票人数
// 更新投票选项投票人数
BbsMomentVoteOption
updOption
=
new
BbsMomentVoteOption
();
BbsMomentVoteOption
updOption
=
new
BbsMomentVoteOption
();
...
@@ -315,10 +308,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -315,10 +308,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
this
.
voteOptionService
.
updateById
(
updOption
);
this
.
voteOptionService
.
updateById
(
updOption
);
// 更新动态投票人数
// 更新动态投票人数
BbsMoment
updMoment
=
new
BbsMoment
();
this
.
baseMapper
.
incrMomentVoteCount
(
dbMomentId
,
1
);
updMoment
.
setId
(
dbMoment
.
getId
());
updMoment
.
setVoteCount
(
dbMoment
.
getVoteCount
()
+
1
);
this
.
updateById
(
updMoment
);
// 发布用户操作事件
// 发布用户操作事件
OperateEvent
operateEvent
=
new
OperateEvent
(
username
,
OperateType
.
TPDT
);
OperateEvent
operateEvent
=
new
OperateEvent
(
username
,
OperateType
.
TPDT
);
...
@@ -360,9 +350,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -360,9 +350,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
}
}
// 添加动态评论
// 添加动态评论
Long
dbMomentId
=
dbMoment
.
getId
();
SysUser
dbUser
=
SecurityUtils
.
getLoginUser
().
getUser
();
SysUser
dbUser
=
SecurityUtils
.
getLoginUser
().
getUser
();
BbsMomentComment
newComment
=
new
BbsMomentComment
();
BbsMomentComment
newComment
=
new
BbsMomentComment
();
newComment
.
setMomentId
(
dbMoment
.
getId
()
);
newComment
.
setMomentId
(
dbMoment
Id
);
newComment
.
setUserName
(
dbUser
.
getUserName
());
newComment
.
setUserName
(
dbUser
.
getUserName
());
newComment
.
setNickName
(
dbUser
.
getNickName
());
newComment
.
setNickName
(
dbUser
.
getNickName
());
newComment
.
setContent
(
content
);
newComment
.
setContent
(
content
);
...
@@ -383,10 +374,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -383,10 +374,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
this
.
commentService
.
updateById
(
updComment
);
this
.
commentService
.
updateById
(
updComment
);
// 更新动态评论人数
// 更新动态评论人数
BbsMoment
updMoment
=
new
BbsMoment
();
this
.
baseMapper
.
incrMomentCommentCount
(
dbMomentId
,
1
);
updMoment
.
setId
(
dbMoment
.
getId
());
updMoment
.
setCommentCount
(
dbMoment
.
getCommentCount
()
+
1
);
this
.
updateById
(
updMoment
);
// 发布用户操作事件
// 发布用户操作事件
OperateEvent
operateEvent
=
new
OperateEvent
(
dbUser
.
getUserName
(),
OperateType
.
TPDT
);
OperateEvent
operateEvent
=
new
OperateEvent
(
dbUser
.
getUserName
(),
OperateType
.
TPDT
);
...
@@ -412,10 +400,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
...
@@ -412,10 +400,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw
new
ServiceException
(
"删除失败,没有对当前动态评论的操作权限。"
);
throw
new
ServiceException
(
"删除失败,没有对当前动态评论的操作权限。"
);
}
}
BbsMomentComment
updComment
=
new
BbsMomentComment
(
);
this
.
commentService
.
removeById
(
dbComment
.
getId
()
);
updComment
.
setId
(
dbComment
.
getId
());
updComment
.
setStatus
(
CommentStatus
.
SC
.
getStatus
());
// 更新动态评论人数
this
.
commentService
.
updateById
(
updComment
);
this
.
baseMapper
.
incrMomentCommentCount
(
dbComment
.
getMomentId
(),
1
);
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsTopicServiceImpl.java
View file @
0d2c4a9c
...
@@ -22,7 +22,6 @@ import com.tangguo.service.IBbsTopicService;
...
@@ -22,7 +22,6 @@ import com.tangguo.service.IBbsTopicService;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
...
...
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
View file @
0d2c4a9c
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.tangguo.mapper.BbsMomentMapper"
>
<mapper
namespace=
"com.tangguo.mapper.BbsMomentMapper"
>
<select
id=
"selectBbsMomentList"
resultType=
"com.tangguo.domain.BbsMoment"
>
<select
id=
"selectBbsMomentList"
resultType=
"com.tangguo.domain.BbsMoment"
>
SELECT
SELECT
m.*,
m.*,
uv.nick_name,
uv.nick_name,
...
@@ -156,5 +156,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -156,5 +156,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY
ORDER BY
m.create_time DESC
m.create_time DESC
</select>
</select>
<update
id=
"incrMomentLikeCount"
>
UPDATE bbs_moment SET like_count = like_count + #{count} WHERE id = #{momentId}
</update>
<update
id=
"decrMomentLikeCount"
>
UPDATE bbs_moment SET like_count = like_count - #{count} WHERE id = #{momentId}
</update>
<update
id=
"incrMomentCommentCount"
>
UPDATE bbs_moment SET comment_count = comment_count + #{count} WHERE id = #{momentId}
</update>
<update
id=
"decrMomentCommentCount"
>
UPDATE bbs_moment SET comment_count = comment_count - #{count} WHERE id = #{momentId}
</update>
<update
id=
"incrMomentVoteCount"
>
UPDATE bbs_moment SET vote_count = vote_count + #{count} WHERE id = #{momentId}
</update>
<update
id=
"decrMomentVoteCount"
>
UPDATE bbs_moment SET vote_count = vote_count - #{count} WHERE id = #{momentId}
</update>
</mapper>
</mapper>
safe-campus-points/src/main/java/com/tangguo/controller/BbsPointsGoodsController.java
View file @
0d2c4a9c
package
com
.
tangguo
.
controller
;
package
com
.
tangguo
.
controller
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.tangguo.common.annotation.Log
;
import
com.tangguo.common.annotation.Log
;
import
com.tangguo.common.core.controller.BaseController
;
import
com.tangguo.common.core.controller.BaseController
;
import
com.tangguo.common.core.domain.AjaxResult
;
import
com.tangguo.common.core.domain.AjaxResult
;
...
...
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
View file @
0d2c4a9c
...
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.tangguo.common.domain.PointsDetail
;
import
com.tangguo.common.domain.PointsDetail
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.common.utils.SecurityUtils
;
import
com.tangguo.domain.BbsGrade
;
import
com.tangguo.domain.BbsGrade
;
import
com.tangguo.domain.BbsUserPoints
;
import
com.tangguo.domain.BbsUserPoints
;
import
com.tangguo.domain.BbsUserPointsDetail
;
import
com.tangguo.domain.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