Commit 1101ff07 authored by 万成波's avatar 万成波

修复Bug

parent db17bfb0
......@@ -83,11 +83,11 @@ spring:
# ActiveMQ配置
activemq:
broker-url: tcp://127.0.0.1:61616
broker-url: tcp://47.110.32.247:61616
packages:
trust-all: true
user: admin
password: admin
password: admin@2025.com
jms:
listener:
max-concurrency: 3
......
......@@ -83,11 +83,11 @@ spring:
# ActiveMQ配置
activemq:
broker-url: tcp://127.0.0.1:61616
broker-url: tcp://47.110.32.247:61616
packages:
trust-all: true
user: admin
password: admin
password: admin@2025.com
jms:
listener:
max-concurrency: 3
......
......@@ -2,11 +2,17 @@ package com.tangguo;
import com.tangguo.common.constant.ActiveMQConstant;
import com.tangguo.common.domain.PointsDetail;
import me.chanjar.weixin.cp.api.WxCpService;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
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 javax.annotation.Resource;
import javax.jms.*;
/**
*
......@@ -14,22 +20,72 @@ import javax.annotation.Resource;
* @author 谈笑
* @createTime 2025-09-01 16:18:29 星期一
*/
@ActiveProfiles("dev")
@SpringBootTest
public class ApplicationTest {
@Resource
private JmsTemplate jmsTemplate;
@Resource
private WxCpService wxCpService;
@Test
public void test() {
PointsDetail detail = new PointsDetail();
detail.setUserName("TanXiaoIng");
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);
this.jmsTemplate.convertAndSend(ActiveMQConstant.Points.DECR_USER_POINTS_QUEUE, detail, message -> {
message.setStringProperty("userName", detail.getUserName());
return message;
});
}
public static void main(String[] args) {
// 连接到ActiveMQ
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
connectionFactory.setUserName("admin");
connectionFactory.setPassword("admin");
Connection connection = null;
try {
connection = connectionFactory.createConnection();
connection.start();
// 创建会话
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 创建目标队列
Queue queue = session.createQueue(ActiveMQConstant.Points.INCR_USER_POINTS_QUEUE);
// 创建消息生产者
MessageProducer producer = session.createProducer(queue);
// 创建文本消息
TextMessage message = session.createTextMessage("Hello ActiveMQ!");
// 设置有效期为5秒(5000毫秒)
long timeToLive = 5000; // 5000毫秒
producer.send(message, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, timeToLive);
System.out.println("消息发送成功,消息ID: " + message.getJMSMessageID());
} catch (JMSException e) {
e.printStackTrace();
} finally {
// 关闭连接
try {
if (connection != null) {
connection.close();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
......@@ -8,6 +8,7 @@ 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 org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
......
......@@ -66,8 +66,8 @@ public class MBbsTopicController {
* @return 话题
*/
@GetMapping("/ranking")
public AjaxResult getRankingTopic() {
List<BbsTopicListVO> dbTopics = this.topicService.getRankingTopic();
public AjaxResult getRankingTopic(String name) {
List<BbsTopicListVO> dbTopics = this.topicService.getRankingTopic(name);
return AjaxResult.success(dbTopics);
}
......
......@@ -63,8 +63,7 @@ public class BbsMomentCommentController extends BaseController {
@Log(title = "动态评论记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
this.bbsMomentCommentService.deleteMomentComments(id);
return AjaxResult.success();
return toAjax(this.bbsMomentCommentService.removeById(id));
}
}
......@@ -64,7 +64,8 @@ public class BbsMomentController extends BaseController {
@Log(title = "动态", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
return toAjax(bbsMomentService.removeById(id));
this.bbsMomentService.deleteMoment(id);
return AjaxResult.success();
}
}
......@@ -96,9 +96,9 @@ public class BbsSensitiveWordController extends BaseController {
/**
* 修改敏感词库
* 导入敏感词库
*/
@ApiOperation("修改敏感词库")
@ApiOperation("导入敏感词库")
@PreAuthorize("@ss.hasPermi('bbs:word:edit')")
@Log(title = "敏感词库", businessType = BusinessType.IMPORT)
@PostMapping("/import")
......
......@@ -74,9 +74,10 @@ public interface IBbsTopicService extends IService<BbsTopic> {
/**
* 查询热搜话题
*
* @param name 话题名称
* @return 话题
*/
List<BbsTopicListVO> getRankingTopic();
List<BbsTopicListVO> getRankingTopic(String name);
/**
......
......@@ -93,7 +93,7 @@ public class BbsMomentCommentServiceImpl extends ServiceImpl<BbsMomentCommentMap
*/
@Override
public void deleteMomentComments(Long momentId) {
this.count(
this.remove(
Wrappers.lambdaQuery(BbsMomentComment.class)
.eq(BbsMomentComment::getMomentId, momentId)
);
......
......@@ -342,6 +342,15 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("评论失败,当前动态未开启评论。");
}
// 检查评论内容
String content = bo.getContent();
FoundWord fw = SensitiveWordUtils.getFoundFirstSensitive(content);
if (Objects.nonNull(fw)) {
String msg = String.format("评论失败,当前评论内容存在敏感词【%s】。", fw.getFoundWord());
throw new ServiceException(msg);
}
// 回复评论
BbsMomentComment dbParentComment = null;
if (Objects.nonNull(bo.getParentId())) {
dbParentComment = this.commentService.getById(bo.getParentId());
......@@ -356,7 +365,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
newComment.setMomentId(dbMoment.getId());
newComment.setUserName(dbUser.getUserName());
newComment.setNickName(dbUser.getNickName());
newComment.setContent(bo.getContent());
newComment.setContent(content);
newComment.setStatus(CommentStatus.ZC.getStatus());
newComment.setIsFeatured(0);
this.commentService.save(newComment);
......@@ -366,7 +375,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
updComment.setId(newComment.getId());
if (Objects.nonNull(dbParentComment)) {
updComment.setParentId(dbParentComment.getId());
updComment.setReplyNikeName(dbParentComment.getNickName());
updComment.setReplyNickName(dbParentComment.getNickName());
updComment.setAncestorPath(dbParentComment.getAncestorPath() + "," + newComment.getId());
} else {
updComment.setAncestorPath(String.valueOf(newComment.getId()));
......
package com.tangguo.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.dfa.FoundWord;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -21,10 +22,12 @@ import com.tangguo.service.IBbsTopicService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 话题Service业务层处理
......@@ -56,6 +59,7 @@ public class BbsTopicServiceImpl extends ServiceImpl<BbsTopicMapper, BbsTopic> i
lqw.orderByDesc(BbsTopic::getIsTop);
lqw.orderByDesc(BbsTopic::getTopTime);
lqw.orderByAsc(BbsTopic::getSort);
lqw.orderByDesc(BbsTopic::getCreateTime);
return bbsTopicMapper.selectList(lqw);
}
......@@ -175,15 +179,21 @@ public class BbsTopicServiceImpl extends ServiceImpl<BbsTopicMapper, BbsTopic> i
/**
* 查询热搜话题
*
* @param name 话题名称
* @return 话题
*/
@Override
public List<BbsTopicListVO> getRankingTopic() {
public List<BbsTopicListVO> getRankingTopic(String name) {
List<BbsTopicListVO> topics = this.redisCache.getCacheObject(MomentConstant.HOT_TOPIC);
if (CollUtil.isEmpty(topics)) {
topics = this.baseMapper.selectRankingTopic();
this.redisCache.setCacheObject(MomentConstant.HOT_TOPIC, topics, 1, TimeUnit.HOURS);
}
if (StrUtil.isNotBlank(name)) {
topics = topics.stream()
.filter(t -> t.getName().contains(name)).collect(Collectors.toList());
}
return topics;
}
......
......@@ -19,6 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="comment.momentContent != null and comment.momentContent != ''">
AND m.content LIKE CONCAT('%', #{comment.momentContent}, '%')
</if>
<if test="comment.nickName != null and comment.nickName != ''">
AND c.nick_name LIKE CONCAT('%', #{comment.nickName}, '%')
</if>
<if test="comment.userName != null and comment.userName != ''">
AND c.user_name LIKE CONCAT('%', #{comment.userName}, '%')
</if>
</where>
ORDER BY
c.create_time DESC
......
......@@ -41,7 +41,8 @@ public class BbsGradeServiceImpl extends ServiceImpl<BbsGradeMapper, BbsGrade> i
LambdaQueryWrapper<BbsGrade> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(grade.getName()), BbsGrade::getName, grade.getName());
lqw.eq(StringUtils.isNotBlank(grade.getCode()), BbsGrade::getCode, grade.getCode());
lqw.orderByAsc(BbsGrade::getCreateTime);
lqw.orderByAsc(BbsGrade::getSort);
lqw.orderByDesc(BbsGrade::getCreateTime);
return bbsGradeMapper.selectList(lqw);
}
......
......@@ -34,6 +34,7 @@ public class BbsUserPointsDetailServiceImpl extends ServiceImpl<BbsUserPointsDet
return this.list(
Wrappers.lambdaQuery(BbsUserPointsDetail.class)
.eq(BbsUserPointsDetail::getUserName, userName)
.orderByDesc(BbsUserPointsDetail::getCreateTime)
);
}
......
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