Commit efb37816 authored by 万成波's avatar 万成波

积分模块集成ActiveMQ

parent 6cc54ad5
......@@ -64,6 +64,7 @@ spring:
config:
multi-statement-allow: true
# Redis配置
redis:
# 地址
......@@ -94,3 +95,6 @@ spring:
trust-all: true
user: admin
password: admin
jms:
listener:
max-concurrency: 3
......@@ -24,7 +24,7 @@ public class ApplicationTest {
@Test
public void test() {
PointsDetail detail = new PointsDetail();
detail.setUserName("TanXiao");
detail.setUserName("TanXiaoIng");
detail.setDetailPoints(10);
detail.setDetailName("外部系统");
detail.setDescription("外部系统");
......
......@@ -47,7 +47,7 @@ public class UserPointsListener {
* @param detail 积分明细
*/
@JmsListener(destination = ActiveMQConstant.Points.DECR_USER_POINTS_QUEUE, containerFactory = ActiveMQConstant.QUEUE_CONTAINER_BEAN)
public void decrUserPoints(PointsDetail detail, Message message) {
public void decrUserPointsListener(PointsDetail detail, Message message) {
try {
log.info("=> 扣减用户积分消息:{}", detail);
this.userPointsService.decrUserPoints(detail);
......
......@@ -2,6 +2,7 @@ package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.vo.QwmhSysUserVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -16,4 +17,10 @@ public interface BbsUserPointsMapper extends BaseMapper<BbsUserPoints> {
List<BbsUserPoints> selectBbsUserPointsList(@Param("points") BbsUserPoints points);
QwmhSysUserVO selectQwmhUser(@Param("userName") String userName);
BbsUserPoints selectUserPoints(@Param("userName") String userName);
}
......@@ -7,9 +7,11 @@ import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.domain.dto.PointsDetail;
import com.tangguo.domain.vo.QwmhSysUserVO;
import com.tangguo.mapper.BbsUserPointsMapper;
import com.tangguo.service.IBbsUserPointsDetailService;
import com.tangguo.service.IBbsUserPointsService;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -58,15 +60,18 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
@Override
public BbsUserPoints getUserPoints(String userName) {
BbsUserPoints dbUserPoints = this.getOne(
Wrappers.lambdaQuery(BbsUserPoints.class).eq(BbsUserPoints::getUserName, userName)
);
BbsUserPoints dbUserPoints = this.baseMapper.selectUserPoints(userName);
if (Objects.isNull(dbUserPoints)) {
QwmhSysUserVO qwmhSysUser = this.baseMapper.selectQwmhUser(userName);
if (Objects.nonNull(qwmhSysUser)) {
dbUserPoints = new BbsUserPoints();
dbUserPoints.setUserName(userName);
dbUserPoints.setAccumulatedPoints(0);
dbUserPoints.setCurrentPoints(0);
this.save(dbUserPoints);
} else {
throw new ServiceException("查询用户积分失败,未查询到当前用户数据。");
}
}
return dbUserPoints;
}
......
......@@ -34,4 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.accumulated_points DESC
</select>
<select id="selectQwmhUser" resultType="com.tangguo.domain.vo.QwmhSysUserVO">
SELECT * FROM qwmh_sys_user_view WHERE user_name = #{userName}
</select>
<select id="selectUserPoints" resultType="com.tangguo.domain.BbsUserPoints">
SELECT * FROM bbs_user_points WHERE user_name = #{userName}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment