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
6cc54ad5
Commit
6cc54ad5
authored
Sep 01, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
积分模块集成ActiveMQ
parent
79fc45f3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
223 additions
and
21 deletions
+223
-21
safe-campus-admin/src/test/java/com/tangguo/ApplicationTest.java
...mpus-admin/src/test/java/com/tangguo/ApplicationTest.java
+35
-0
safe-campus-common/src/main/java/com/tangguo/common/constant/ActiveMQConstant.java
...in/java/com/tangguo/common/constant/ActiveMQConstant.java
+31
-0
safe-campus-framework/pom.xml
safe-campus-framework/pom.xml
+5
-0
safe-campus-framework/src/main/java/com/tangguo/framework/activemq/ActiveMQConfig.java
...n/java/com/tangguo/framework/activemq/ActiveMQConfig.java
+56
-0
safe-campus-framework/src/main/java/com/tangguo/framework/config/CreateAndUpdateMetaObjectHandler.java
...uo/framework/config/CreateAndUpdateMetaObjectHandler.java
+4
-4
safe-campus-moment/src/main/java/com/tangguo/controller/BbsMomentController.java
...main/java/com/tangguo/controller/BbsMomentController.java
+0
-1
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsExchangeController.java
...m/tangguo/controller/BbsUserPointsExchangeController.java
+17
-0
safe-campus-points/src/main/java/com/tangguo/domain/dto/PointsDetail.java
...ts/src/main/java/com/tangguo/domain/dto/PointsDetail.java
+10
-11
safe-campus-points/src/main/java/com/tangguo/event/UserPointsListener.java
...s/src/main/java/com/tangguo/event/UserPointsListener.java
+60
-0
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsExchangeServiceImpl.java
...angguo/service/impl/BbsUserPointsExchangeServiceImpl.java
+1
-1
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
...va/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
+4
-4
No files found.
safe-campus-admin/src/test/java/com/tangguo/ApplicationTest.java
0 → 100644
View file @
6cc54ad5
package
com
.
tangguo
;
import
com.tangguo.common.constant.ActiveMQConstant
;
import
com.tangguo.domain.dto.PointsDetail
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.jms.core.JmsTemplate
;
import
javax.annotation.Resource
;
/**
*
*
* @author 谈笑
* @createTime 2025-09-01 16:18:29 星期一
*/
@SpringBootTest
public
class
ApplicationTest
{
@Resource
private
JmsTemplate
jmsTemplate
;
@Test
public
void
test
()
{
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
"TanXiao"
);
detail
.
setDetailPoints
(
10
);
detail
.
setDetailName
(
"外部系统"
);
detail
.
setDescription
(
"外部系统"
);
this
.
jmsTemplate
.
convertAndSend
(
ActiveMQConstant
.
Points
.
INCR_USER_POINTS_QUEUE
,
detail
);
this
.
jmsTemplate
.
convertAndSend
(
ActiveMQConstant
.
Points
.
DECR_USER_POINTS_QUEUE
,
detail
);
}
}
safe-campus-common/src/main/java/com/tangguo/common/constant/ActiveMQConstant.java
0 → 100644
View file @
6cc54ad5
package
com
.
tangguo
.
common
.
constant
;
/**
* ActiveMQ常量
*
* @author 谈笑
* @createTime 2025-09-01 15:54:26 星期一
*/
public
interface
ActiveMQConstant
{
/**
* 点对点 (队列) 模式
*/
String
QUEUE_CONTAINER_BEAN
=
"queueContainer"
;
interface
Points
{
/**
* 增加用户积分队列名
*/
String
INCR_USER_POINTS_QUEUE
=
"points.user.incr"
;
/**
* 扣减用户积分队列名
*/
String
DECR_USER_POINTS_QUEUE
=
"points.user.decr"
;
}
}
safe-campus-framework/pom.xml
View file @
6cc54ad5
...
@@ -33,6 +33,11 @@
...
@@ -33,6 +33,11 @@
<artifactId>
druid-spring-boot-starter
</artifactId>
<artifactId>
druid-spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
</dependency>
<!-- 系统模块-->
<!-- 系统模块-->
<dependency>
<dependency>
<groupId>
com.tangguo
</groupId>
<groupId>
com.tangguo
</groupId>
...
...
safe-campus-framework/src/main/java/com/tangguo/framework/activemq/ActiveMQConfig.java
0 → 100644
View file @
6cc54ad5
package
com
.
tangguo
.
framework
.
activemq
;
import
com.tangguo.common.constant.ActiveMQConstant
;
import
org.apache.activemq.ActiveMQSession
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jms.annotation.EnableJms
;
import
org.springframework.jms.config.DefaultJmsListenerContainerFactory
;
import
org.springframework.jms.config.JmsListenerContainerFactory
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.Queue
;
/**
* ActiveMQ队列配置
*
* @author 谈笑
* @createTime 2025-09-01 15:53:31 星期一
*/
@EnableJms
@Configuration
public
class
ActiveMQConfig
{
/**
* 增加用户积分队列
*/
@Bean
public
Queue
incrUserPointsQueue
()
{
return
new
ActiveMQQueue
(
ActiveMQConstant
.
Points
.
INCR_USER_POINTS_QUEUE
);
}
/**
* 扣减用户积分队列
*/
@Bean
public
Queue
decrUserPointsQueue
()
{
return
new
ActiveMQQueue
(
ActiveMQConstant
.
Points
.
DECR_USER_POINTS_QUEUE
);
}
/**
* 点对点 (队列) 模式
*/
@Bean
(
ActiveMQConstant
.
QUEUE_CONTAINER_BEAN
)
public
JmsListenerContainerFactory
<?>
queueContainer
(
ConnectionFactory
connectionFactory
)
{
DefaultJmsListenerContainerFactory
factory
=
new
DefaultJmsListenerContainerFactory
();
factory
.
setPubSubDomain
(
false
);
factory
.
setSessionAcknowledgeMode
(
ActiveMQSession
.
INDIVIDUAL_ACKNOWLEDGE
);
factory
.
setSessionTransacted
(
false
);
factory
.
setConnectionFactory
(
connectionFactory
);
return
factory
;
}
}
safe-campus-framework/src/main/java/com/tangguo/framework/config/CreateAndUpdateMetaObjectHandler.java
View file @
6cc54ad5
package
com
.
tangguo
.
framework
.
config
;
package
com
.
tangguo
.
framework
.
config
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.http.HttpStatus
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
com.tangguo.common.core.domain.BaseEntity
;
import
com.tangguo.common.core.domain.BaseEntity
;
import
com.tangguo.common.exception.ServiceException
;
import
com.tangguo.common.utils.SecurityUtils
;
import
com.tangguo.common.utils.SecurityUtils
;
import
com.tangguo.common.utils.StringUtils
;
import
com.tangguo.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -38,7 +36,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
...
@@ -38,7 +36,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
baseEntity
.
setUpdateBy
(
username
);
baseEntity
.
setUpdateBy
(
username
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"自动注入异常 => "
+
e
.
getMessage
(),
HttpStatus
.
HTTP_UNAUTHORIZED
);
log
.
error
(
"=> 自动注入异常:"
,
e
);
// throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}
}
}
}
...
@@ -57,7 +56,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
...
@@ -57,7 +56,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"自动注入异常 => "
+
e
.
getMessage
(),
HttpStatus
.
HTTP_UNAUTHORIZED
);
log
.
error
(
"=> 自动注入异常:"
,
e
);
// throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}
}
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/controller/BbsMomentController.java
View file @
6cc54ad5
...
@@ -6,7 +6,6 @@ import com.tangguo.common.core.domain.AjaxResult;
...
@@ -6,7 +6,6 @@ import com.tangguo.common.core.domain.AjaxResult;
import
com.tangguo.common.core.page.TableDataInfo
;
import
com.tangguo.common.core.page.TableDataInfo
;
import
com.tangguo.common.enums.BusinessType
;
import
com.tangguo.common.enums.BusinessType
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMomentComment
;
import
com.tangguo.service.IBbsMomentService
;
import
com.tangguo.service.IBbsMomentService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
...
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsExchangeController.java
View file @
6cc54ad5
...
@@ -7,6 +7,7 @@ import com.tangguo.common.core.controller.BaseController;
...
@@ -7,6 +7,7 @@ import com.tangguo.common.core.controller.BaseController;
import
com.tangguo.common.core.domain.AjaxResult
;
import
com.tangguo.common.core.domain.AjaxResult
;
import
com.tangguo.common.core.page.TableDataInfo
;
import
com.tangguo.common.core.page.TableDataInfo
;
import
com.tangguo.common.enums.BusinessType
;
import
com.tangguo.common.enums.BusinessType
;
import
com.tangguo.common.utils.poi.ExcelUtil
;
import
com.tangguo.domain.BbsPointsGoods
;
import
com.tangguo.domain.BbsPointsGoods
;
import
com.tangguo.domain.BbsUserPointsExchange
;
import
com.tangguo.domain.BbsUserPointsExchange
;
import
com.tangguo.domain.vo.QwmhSysUserVO
;
import
com.tangguo.domain.vo.QwmhSysUserVO
;
...
@@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
...
@@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -84,6 +86,21 @@ public class BbsUserPointsExchangeController extends BaseController {
...
@@ -84,6 +86,21 @@ public class BbsUserPointsExchangeController extends BaseController {
}
}
/**
* 导出用户积分列表
*/
@ApiOperation
(
"导出用户积分列表"
)
@PreAuthorize
(
"@ss.hasPermi('points:points:export')"
)
@Log
(
title
=
"用户积分"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
BbsUserPointsExchange
exchange
)
{
List
<
BbsUserPointsExchange
>
list
=
bbsUserPointsExchangeService
.
selectBbsUserPointsExchangeList
(
exchange
);
ExcelUtil
<
BbsUserPointsExchange
>
util
=
new
ExcelUtil
<>(
BbsUserPointsExchange
.
class
);
util
.
exportExcel
(
response
,
list
,
"用户积分数据"
);
}
/**
/**
* 用户积分兑换
* 用户积分兑换
*/
*/
...
...
safe-campus-points/src/main/java/com/tangguo/domain/dto/PointsDetail.java
View file @
6cc54ad5
...
@@ -2,6 +2,8 @@ package com.tangguo.domain.dto;
...
@@ -2,6 +2,8 @@ package com.tangguo.domain.dto;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
/**
* 积分明细DTO
* 积分明细DTO
*
*
...
@@ -9,20 +11,22 @@ import lombok.Data;
...
@@ -9,20 +11,22 @@ import lombok.Data;
* @createTime 2025-08-29 17:23:29 星期五
* @createTime 2025-08-29 17:23:29 星期五
*/
*/
@Data
@Data
public
class
PointsDetail
{
public
class
PointsDetail
implements
Serializable
{
private
static
final
long
serialVersionUID
=
8057307839793769207L
;
/**
/**
* 用户名
* 用户名
(必填)
*/
*/
private
String
userName
;
private
String
userName
;
/**
/**
*
积分
*
明细积分 (必填)
*/
*/
private
int
p
oints
;
private
int
detailP
oints
;
/**
/**
* 明细名称
* 明细名称
(必填)
*/
*/
private
String
detailName
;
private
String
detailName
;
...
@@ -32,12 +36,7 @@ public class PointsDetail {
...
@@ -32,12 +36,7 @@ public class PointsDetail {
private
String
detailCode
;
private
String
detailCode
;
/**
/**
* 明细积分
* 明细说明 (必填)
*/
private
Integer
detailPoints
;
/**
* 明细说明
*/
*/
private
String
description
;
private
String
description
;
...
...
safe-campus-points/src/main/java/com/tangguo/event/UserPointsListener.java
0 → 100644
View file @
6cc54ad5
package
com
.
tangguo
.
event
;
import
com.tangguo.common.constant.ActiveMQConstant
;
import
com.tangguo.domain.dto.PointsDetail
;
import
com.tangguo.service.IBbsUserPointsService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.jms.Message
;
/**
* 用户积分增加扣减消息时间监听器
*
* @author 谈笑
* @createTime 2025-09-01 16:03:08 星期一
*/
@Slf4j
@Component
public
class
UserPointsListener
{
@Resource
private
IBbsUserPointsService
userPointsService
;
/**
* 增加用户积分消息
*
* @param detail 积分明细
*/
@JmsListener
(
destination
=
ActiveMQConstant
.
Points
.
INCR_USER_POINTS_QUEUE
,
containerFactory
=
ActiveMQConstant
.
QUEUE_CONTAINER_BEAN
)
public
void
incrUserPointsListener
(
PointsDetail
detail
,
Message
message
)
{
try
{
log
.
info
(
"=> 开始处理增加用户积分消息:{}"
,
detail
);
this
.
userPointsService
.
incrUserPoints
(
detail
);
message
.
acknowledge
();
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 增加用户积分消息处理失败,积分明细:{} 错误信息:"
,
detail
,
e
);
}
}
/**
* 扣减用户积分消息
*
* @param detail 积分明细
*/
@JmsListener
(
destination
=
ActiveMQConstant
.
Points
.
DECR_USER_POINTS_QUEUE
,
containerFactory
=
ActiveMQConstant
.
QUEUE_CONTAINER_BEAN
)
public
void
decrUserPoints
(
PointsDetail
detail
,
Message
message
)
{
try
{
log
.
info
(
"=> 扣减用户积分消息:{}"
,
detail
);
this
.
userPointsService
.
decrUserPoints
(
detail
);
message
.
acknowledge
();
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 扣减用户积分消息处理失败,积分明细:{} 错误信息:"
,
detail
,
e
);
}
}
}
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsExchangeServiceImpl.java
View file @
6cc54ad5
...
@@ -87,7 +87,7 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
...
@@ -87,7 +87,7 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
// 扣减用户积分
// 扣减用户积分
PointsDetail
detail
=
new
PointsDetail
();
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
detail
.
setUserName
(
userName
);
detail
.
setPoints
(
exchangePoints
);
detail
.
set
Detail
Points
(
exchangePoints
);
detail
.
setDetailName
(
dbGoods
.
getName
());
detail
.
setDetailName
(
dbGoods
.
getName
());
detail
.
setDetailCode
(
dbGoods
.
getCode
());
detail
.
setDetailCode
(
dbGoods
.
getCode
());
detail
.
setDescription
(
String
.
format
(
"用户【%s】兑换积分商品【%s-%s】"
,
userName
,
dbGoods
.
getName
(),
dbGoods
.
getCode
()));
detail
.
setDescription
(
String
.
format
(
"用户【%s】兑换积分商品【%s-%s】"
,
userName
,
dbGoods
.
getName
(),
dbGoods
.
getCode
()));
...
...
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
View file @
6cc54ad5
...
@@ -83,7 +83,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -83,7 +83,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
String
userName
=
points
.
getUserName
();
String
userName
=
points
.
getUserName
();
PointsDetail
detail
=
new
PointsDetail
();
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
detail
.
setUserName
(
userName
);
detail
.
setPoints
(
points
.
getIncrOrDecrPoints
());
detail
.
set
Detail
Points
(
points
.
getIncrOrDecrPoints
());
detail
.
setDetailName
(
"后台手动增加"
);
detail
.
setDetailName
(
"后台手动增加"
);
detail
.
setDescription
(
String
.
format
(
"管理员【%s】后台手动增加用户【%s】积分"
,
SecurityUtils
.
getUsername
(),
userName
));
detail
.
setDescription
(
String
.
format
(
"管理员【%s】后台手动增加用户【%s】积分"
,
SecurityUtils
.
getUsername
(),
userName
));
this
.
incrUserPoints
(
detail
);
this
.
incrUserPoints
(
detail
);
...
@@ -101,7 +101,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -101,7 +101,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
String
userName
=
points
.
getUserName
();
String
userName
=
points
.
getUserName
();
PointsDetail
detail
=
new
PointsDetail
();
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
detail
.
setUserName
(
userName
);
detail
.
setPoints
(
points
.
getIncrOrDecrPoints
());
detail
.
set
Detail
Points
(
points
.
getIncrOrDecrPoints
());
detail
.
setDetailName
(
"后台手动扣减"
);
detail
.
setDetailName
(
"后台手动扣减"
);
detail
.
setDescription
(
String
.
format
(
"管理员【%s】后台手动扣减用户【%s】积分"
,
SecurityUtils
.
getUsername
(),
userName
));
detail
.
setDescription
(
String
.
format
(
"管理员【%s】后台手动扣减用户【%s】积分"
,
SecurityUtils
.
getUsername
(),
userName
));
this
.
decrUserPoints
(
detail
);
this
.
decrUserPoints
(
detail
);
...
@@ -141,7 +141,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -141,7 +141,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
privIncrUserPoints
(
PointsDetail
detail
)
{
public
void
privIncrUserPoints
(
PointsDetail
detail
)
{
int
points
=
detail
.
getPoints
();
int
points
=
detail
.
get
Detail
Points
();
if
(
points
<
1
)
{
if
(
points
<
1
)
{
throw
new
ServiceException
(
"增加用户积分失败,增加的积分分值不能小于0。"
);
throw
new
ServiceException
(
"增加用户积分失败,增加的积分分值不能小于0。"
);
}
}
...
@@ -175,7 +175,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
...
@@ -175,7 +175,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
privDecrUserPoints
(
PointsDetail
detail
)
{
public
void
privDecrUserPoints
(
PointsDetail
detail
)
{
int
points
=
detail
.
getPoints
();
int
points
=
detail
.
get
Detail
Points
();
if
(
points
<
1
)
{
if
(
points
<
1
)
{
throw
new
ServiceException
(
"扣减用户积分失败,扣减的积分分值不能小于0。"
);
throw
new
ServiceException
(
"扣减用户积分失败,扣减的积分分值不能小于0。"
);
}
}
...
...
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