Commit 3595d0db authored by yuwenwen's avatar yuwenwen
parents 819be043 6cc54ad5
......@@ -63,7 +63,8 @@ spring:
wall:
config:
multi-statement-allow: true
# redis 配置
# Redis配置
redis:
# 地址
host: localhost
......@@ -85,3 +86,11 @@ spring:
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# ActiveMQ配置
activemq:
broker-url: tcp://127.0.0.1:61616
packages:
trust-all: true
user: admin
password: admin
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);
}
}
......@@ -5,7 +5,7 @@ VUE_APP_TITLE = 一站式高校轻享平台
ENV = 'development'
# 若依管理系统/开发环境
VUE_APP_BASE_API = 'http://192.168.5.177:8080'
VUE_APP_BASE_API = 'http://127.0.0.1:8080'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -181,6 +181,11 @@
<artifactId>weixin-java-cp</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
</dependencies>
</project>
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";
}
}
......@@ -33,6 +33,11 @@
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.tangguo</groupId>
......
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;
}
}
package com.tangguo.framework.config;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.tangguo.common.core.domain.BaseEntity;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -38,7 +36,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
baseEntity.setUpdateBy(username);
}
} 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 {
}
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
log.error("=> 自动注入异常:", e);
// throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}
}
......
......@@ -34,7 +34,7 @@ public class BbsGradeController extends BaseController {
* 查询用户等级列表
*/
@ApiOperation("查询用户等级列表")
@PreAuthorize("@ss.hasPermi('grade:grade:list')")
@PreAuthorize("@ss.hasPermi('bbs:grade:list')")
@GetMapping("/list")
public TableDataInfo list(BbsGrade bbsGrade) {
startPage();
......@@ -47,7 +47,7 @@ public class BbsGradeController extends BaseController {
* 获取用户等级详细信息
*/
@ApiOperation("获取用户等级详细信息")
@PreAuthorize("@ss.hasPermi('grade:grade:query')")
@PreAuthorize("@ss.hasPermi('bbs:grade:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(bbsGradeService.getById(id));
......@@ -58,7 +58,7 @@ public class BbsGradeController extends BaseController {
* 新增用户等级
*/
@ApiOperation("新增用户等级")
@PreAuthorize("@ss.hasPermi('grade:grade:add')")
@PreAuthorize("@ss.hasPermi('bbs:grade:add')")
@Log(title = "用户等级", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BbsGrade grade) {
......@@ -71,7 +71,7 @@ public class BbsGradeController extends BaseController {
* 修改用户等级
*/
@ApiOperation("修改用户等级")
@PreAuthorize("@ss.hasPermi('grade:grade:edit')")
@PreAuthorize("@ss.hasPermi('bbs:grade:edit')")
@Log(title = "用户等级", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BbsGrade grade) {
......@@ -84,7 +84,7 @@ public class BbsGradeController extends BaseController {
* 删除用户等级
*/
@ApiOperation("删除用户等级")
@PreAuthorize("@ss.hasPermi('grade:grade:remove')")
@PreAuthorize("@ss.hasPermi('bbs:grade:remove')")
@Log(title = "用户等级", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
......
......@@ -34,7 +34,7 @@ public class BbsMomentCommentController extends BaseController {
* 查询动态评论记录列表
*/
@ApiOperation("查询动态评论记录列表")
@PreAuthorize("@ss.hasPermi('comment:comment:list')")
@PreAuthorize("@ss.hasPermi('moment:comment:list')")
@GetMapping("/list")
public TableDataInfo list(BbsMomentComment comment) {
startPage();
......@@ -47,7 +47,7 @@ public class BbsMomentCommentController extends BaseController {
* 获取动态评论记录详细信息
*/
@ApiOperation("获取动态评论记录详细信息")
@PreAuthorize("@ss.hasPermi('comment:comment:query')")
@PreAuthorize("@ss.hasPermi('moment:comment:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
BbsMomentComment comment = this.bbsMomentCommentService.getBbsMomentComment(id);
......@@ -59,7 +59,7 @@ public class BbsMomentCommentController extends BaseController {
* 删除动态评论记录
*/
@ApiOperation("删除动态评论记录")
@PreAuthorize("@ss.hasPermi('comment:comment:remove')")
@PreAuthorize("@ss.hasPermi('moment:comment:remove')")
@Log(title = "动态评论记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
......
package com.tangguo.controller;
import com.tangguo.common.annotation.Log;
import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType;
import com.tangguo.domain.BbsMoment;
import com.tangguo.service.IBbsMomentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 动态Controller
*
* @author ruoyi
* @date 2025-09-01
*/
@Api(tags="动态管理")
@RestController
@RequestMapping("/bbs/moment")
public class BbsMomentController extends BaseController {
@Resource
private IBbsMomentService bbsMomentService;
/**
* 查询动态列表
*/
@ApiOperation("查询动态列表")
@PreAuthorize("@ss.hasPermi('bbs:moment:list')")
@GetMapping("/list")
public TableDataInfo list(BbsMoment bbsMoment) {
startPage();
List<BbsMoment> list = bbsMomentService.selectBbsMomentList(bbsMoment);
return getDataTable(list);
}
/**
* 获取动态详细信息
*/
@ApiOperation("获取动态详细信息")
@PreAuthorize("@ss.hasPermi('bbs:moment:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
BbsMoment moment = this.bbsMomentService.getById(id);
return success(moment);
}
/**
* 删除动态
*/
@ApiOperation("删除动态")
@PreAuthorize("@ss.hasPermi('bbs:moment:remove')")
@Log(title = "动态", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
return toAjax(bbsMomentService.removeById(id));
}
}
......@@ -36,7 +36,7 @@ public class BbsSensitiveWordController extends BaseController {
* 查询敏感词库列表
*/
@ApiOperation("查询敏感词库列表")
@PreAuthorize("@ss.hasPermi('word:word:list')")
@PreAuthorize("@ss.hasPermi('bbs:word:list')")
@GetMapping("/list")
public TableDataInfo list(BbsSensitiveWord bbsSensitiveWord) {
startPage();
......@@ -49,7 +49,7 @@ public class BbsSensitiveWordController extends BaseController {
* 获取敏感词库详细信息
*/
@ApiOperation("获取敏感词库详细信息")
@PreAuthorize("@ss.hasPermi('word:word:query')")
@PreAuthorize("@ss.hasPermi('bbs:word:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(bbsSensitiveWordService.getById(id));
......@@ -60,7 +60,7 @@ public class BbsSensitiveWordController extends BaseController {
* 新增敏感词库
*/
@ApiOperation("新增敏感词库")
@PreAuthorize("@ss.hasPermi('word:word:add')")
@PreAuthorize("@ss.hasPermi('bbs:word:add')")
@Log(title = "敏感词库", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BbsSensitiveWord word) {
......@@ -73,7 +73,7 @@ public class BbsSensitiveWordController extends BaseController {
* 修改敏感词库
*/
@ApiOperation("修改敏感词库")
@PreAuthorize("@ss.hasPermi('word:word:edit')")
@PreAuthorize("@ss.hasPermi('bbs:word:edit')")
@Log(title = "敏感词库", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BbsSensitiveWord word) {
......@@ -86,7 +86,7 @@ public class BbsSensitiveWordController extends BaseController {
* 删除敏感词库
*/
@ApiOperation("删除敏感词库")
@PreAuthorize("@ss.hasPermi('word:word:remove')")
@PreAuthorize("@ss.hasPermi('bbs:word:remove')")
@Log(title = "敏感词库", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
......@@ -99,7 +99,7 @@ public class BbsSensitiveWordController extends BaseController {
* 修改敏感词库
*/
@ApiOperation("修改敏感词库")
@PreAuthorize("@ss.hasPermi('word:word:edit')")
@PreAuthorize("@ss.hasPermi('bbs:word:edit')")
@Log(title = "敏感词库", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importWords(MultipartFile file) {
......@@ -112,7 +112,7 @@ public class BbsSensitiveWordController extends BaseController {
* 刷新敏感词库缓存
*/
@ApiOperation("刷新敏感词库缓存")
@PreAuthorize("@ss.hasPermi('word:word:refresh')")
@PreAuthorize("@ss.hasPermi('bbs:word:refresh')")
@Log(title = "敏感词库", businessType = BusinessType.UPDATE)
@PutMapping("/refresh")
public AjaxResult refresh() {
......
......@@ -34,7 +34,7 @@ public class BbsTopicController extends BaseController {
* 查询话题列表
*/
@ApiOperation("查询话题列表")
@PreAuthorize("@ss.hasPermi('topic:topic:list')")
@PreAuthorize("@ss.hasPermi('bbs:topic:list')")
@GetMapping("/list")
public TableDataInfo list(BbsTopic bbsTopic) {
startPage();
......@@ -47,7 +47,7 @@ public class BbsTopicController extends BaseController {
* 获取话题详细信息
*/
@ApiOperation("获取话题详细信息")
@PreAuthorize("@ss.hasPermi('topic:topic:query')")
@PreAuthorize("@ss.hasPermi('bbs:topic:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(bbsTopicService.getById(id));
......@@ -58,7 +58,7 @@ public class BbsTopicController extends BaseController {
* 新增话题
*/
@ApiOperation("新增话题")
@PreAuthorize("@ss.hasPermi('topic:topic:add')")
@PreAuthorize("@ss.hasPermi('bbs:topic:add')")
@Log(title = "话题", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BbsTopic bbsTopic) {
......@@ -71,7 +71,7 @@ public class BbsTopicController extends BaseController {
* 修改话题
*/
@ApiOperation("修改话题")
@PreAuthorize("@ss.hasPermi('topic:topic:edit')")
@PreAuthorize("@ss.hasPermi('bbs:topic:edit')")
@Log(title = "话题", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BbsTopic bbsTopic) {
......@@ -84,7 +84,7 @@ public class BbsTopicController extends BaseController {
* 置顶话题
*/
@ApiOperation("置顶话题")
@PreAuthorize("@ss.hasPermi('topic:topic:top')")
@PreAuthorize("@ss.hasPermi('bbs:topic:top')")
@Log(title = "话题", businessType = BusinessType.UPDATE)
@PutMapping("/top")
public AjaxResult top(@RequestBody BbsTopic bbsTopic) {
......@@ -97,7 +97,7 @@ public class BbsTopicController extends BaseController {
* 删除话题
*/
@ApiOperation("删除话题")
@PreAuthorize("@ss.hasPermi('topic:topic:remove')")
@PreAuthorize("@ss.hasPermi('bbs:topic:remove')")
@Log(title = "话题", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
......
package com.tangguo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tangguo.common.annotation.Excel;
import com.tangguo.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 动态对象 bbs_moment
*
* @author ruoyi
* @date 2025-09-01
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("bbs_moment")
@ApiModel(value = "BbsMoment", description = "动态实体")
public class BbsMoment extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 发布人用户名 */
@Excel(name = "发布人用户名")
@ApiModelProperty("发布人用户名")
private String userName;
/** 动态内容 */
@Excel(name = "动态内容")
@ApiModelProperty("动态内容")
private String content;
/** 动态类型:IMAGE 图片动态、VIDEO 视频动态 */
@Excel(name = "动态类型:IMAGE 图片动态、VIDEO 视频动态")
@ApiModelProperty("动态类型:IMAGE 图片动态、VIDEO 视频动态")
private String type;
/** 话题名称(逗号分割) */
@Excel(name = "话题名称", readConverterExp = "逗=号分割")
@ApiModelProperty("话题名称(逗号分割)")
private String topicNames;
/** 话题Ids(逗号分割) */
@Excel(name = "话题Ids", readConverterExp = "逗=号分割")
@ApiModelProperty("话题Ids(逗号分割)")
private String topicIds;
/** 外部链接地址 */
@Excel(name = "外部链接地址")
@ApiModelProperty("外部链接地址")
private String linkUrl;
/** 是否开启评论:0 否、1 是 */
@Excel(name = "是否开启评论:0 否、1 是")
@ApiModelProperty("是否开启评论:0 否、1 是")
private Integer isEnableComment;
/** 是否精选评论:0 否、1 是 */
@Excel(name = "是否精选评论:0 否、1 是")
@ApiModelProperty("是否精选评论:0 否、1 是")
private Integer isEnableFeaturedComment;
/** 是否开启投票:0 否、1 是 */
@Excel(name = "是否开启投票:0 否、1 是")
@ApiModelProperty("是否开启投票:0 否、1 是")
private Integer isEnableVote;
/** 投票标题 */
@Excel(name = "投票标题")
@ApiModelProperty("投票标题")
private String voteTitle;
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
@Excel(name = "投票选项类型:TEXT 文字、IMAGE 图片")
@ApiModelProperty("投票选项类型:TEXT 文字、IMAGE 图片")
private String voteOptionType;
/** 投票开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "投票开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("投票开始时间")
private Date voteStartTime;
/** 投票结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "投票结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("投票结束时间")
private Date voteEndTime;
/** 投票选项JSON */
@Excel(name = "投票选项JSON")
@ApiModelProperty("投票选项JSON")
private String voteOptions;
/** 动态点赞人数 */
@Excel(name = "动态点赞人数")
@ApiModelProperty("动态点赞人数")
private Integer likeCount;
/** 动态投票人数 */
@Excel(name = "动态投票人数")
@ApiModelProperty("动态投票人数")
private Integer voteCount;
/** 用户姓名 */
@TableField(exist = false)
private String nikeName;
/** 用户部门 */
@TableField(exist = false)
private String deptName;
}
package com.tangguo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tangguo.common.annotation.Excel;
import com.tangguo.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* 动态附件对象 bbs_moment_attachments
*
* @author ruoyi
* @date 2025-09-01
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("bbs_moment_attachments")
@ApiModel(value = "BbsMomentAttachments", description = "动态附件实体")
public class BbsMomentAttachments extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 动态ID */
@Excel(name = "动态ID")
@ApiModelProperty("动态ID")
private Long momentId;
/** 用户名 */
@Excel(name = "用户名")
@ApiModelProperty("用户名")
private String userName;
/** 附件名称 */
@Excel(name = "附件名称")
@ApiModelProperty("附件名称")
private String name;
/** 附件类型:图片 IMAGE、视频 VIDEO */
@Excel(name = "附件类型:图片 IMAGE、视频 VIDEO")
@ApiModelProperty("附件类型:图片 IMAGE、视频 VIDEO")
private String type;
/** 附件预览地址 */
@Excel(name = "附件预览地址")
@ApiModelProperty("附件预览地址")
private String url;
/** 文件扩展名:PNG、JPG、MP4 */
@Excel(name = "文件扩展名:PNG、JPG、MP4")
@ApiModelProperty("文件扩展名:PNG、JPG、MP4")
private String fileExt;
}
......@@ -28,78 +28,78 @@ import java.util.List;
@TableName("bbs_moment_comment")
@ApiModel(value = "BbsMomentComment", description = "动态评论记录实体")
public class BbsMomentComment extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type= IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 轻享内容ID */
@Excel(name = "轻享内容ID")
@ApiModelProperty("轻享内容ID")
private Long momentId;
/** 评论用户姓名 */
@Excel(name = "评论用户姓名")
@ApiModelProperty("评论用户姓名")
private String nikeName;
/** 评论用户名 */
@Excel(name = "评论用户名")
@ApiModelProperty("评论用户名")
private String userName;
/** 评论内容 */
@Excel(name = "评论内容")
@ApiModelProperty("评论内容")
private String content;
/** 评论图片地址(1-3张) */
@Excel(name = "评论图片地址", readConverterExp = "1=-3张")
@ApiModelProperty("评论图片地址(1-3张)")
private String imgsUrl;
/** 评论状态:0 删除、1 正常、2 隐藏 */
@Excel(name = "评论状态:0 删除、1 正常、2 隐藏")
@ApiModelProperty("评论状态:0 删除、1 正常、2 隐藏")
private Integer status;
/** 评论是否精选:0 否、1 是 */
@Excel(name = "评论是否精选:0 否、1 是")
@ApiModelProperty("评论是否精选:0 否、1 是")
private Integer isFeatured;
/** 父级评论ID(为空为评论,否则为回复。) */
@Excel(name = "父级评论ID", readConverterExp = "为=空为评论,否则为回复。")
@ApiModelProperty("父级评论ID(为空为评论,否则为回复。)")
private Long parentId;
/** 回复的用户姓名 */
@Excel(name = "回复的用户姓名")
@ApiModelProperty("回复的用户姓名")
private String replyNikeName;
/** 评论祖级路径(逗号分隔) */
@Excel(name = "评论祖级路径", readConverterExp = "逗=号分隔")
@ApiModelProperty("评论祖级路径(逗号分隔)")
private String ancestorPath;
/** 删除评论内容 */
@Excel(name = "删除评论内容")
@ApiModelProperty("删除评论内容")
private String deleteComment;
/**
* 动态内容
*/
@TableField(exist = false)
private String momentContent;
/**
* 子评论和回复
*/
@TableField(exist = false)
private List<BbsMomentComment> comments;
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 轻享内容ID */
@Excel(name = "轻享内容ID")
@ApiModelProperty("轻享内容ID")
private Long momentId;
/** 评论用户姓名 */
@Excel(name = "评论用户姓名")
@ApiModelProperty("评论用户姓名")
private String nikeName;
/** 评论用户名 */
@Excel(name = "评论用户名")
@ApiModelProperty("评论用户名")
private String userName;
/** 评论内容 */
@Excel(name = "评论内容")
@ApiModelProperty("评论内容")
private String content;
/** 评论图片地址(1-3张) */
@Excel(name = "评论图片地址", readConverterExp = "1=-3张")
@ApiModelProperty("评论图片地址(1-3张)")
private String imgsUrl;
/** 评论状态:0 删除、1 正常、2 隐藏 */
@Excel(name = "评论状态:0 删除、1 正常、2 隐藏")
@ApiModelProperty("评论状态:0 删除、1 正常、2 隐藏")
private Integer status;
/** 评论是否精选:0 否、1 是 */
@Excel(name = "评论是否精选:0 否、1 是")
@ApiModelProperty("评论是否精选:0 否、1 是")
private Integer isFeatured;
/** 父级评论ID(为空为评论,否则为回复。) */
@Excel(name = "父级评论ID", readConverterExp = "为=空为评论,否则为回复。")
@ApiModelProperty("父级评论ID(为空为评论,否则为回复。)")
private Long parentId;
/** 回复的用户姓名 */
@Excel(name = "回复的用户姓名")
@ApiModelProperty("回复的用户姓名")
private String replyNikeName;
/** 评论祖级路径(逗号分隔) */
@Excel(name = "评论祖级路径", readConverterExp = "逗=号分隔")
@ApiModelProperty("评论祖级路径(逗号分隔)")
private String ancestorPath;
/** 删除评论内容 */
@Excel(name = "删除评论内容")
@ApiModelProperty("删除评论内容")
private String deleteComment;
/**
* 动态内容
*/
@TableField(exist = false)
private String momentContent;
/**
* 子评论和回复
*/
@TableField(exist = false)
private List<BbsMomentComment> comments;
}
package com.tangguo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tangguo.common.annotation.Excel;
import com.tangguo.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* 动态点赞记录对象 bbs_moment_like
*
* @author ruoyi
* @date 2025-09-01
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("bbs_moment_like")
@ApiModel(value = "BbsMomentLike", description = "动态点赞记录实体")
public class BbsMomentLike extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 动态ID */
@Excel(name = "动态ID")
@ApiModelProperty("动态ID")
private Long momentId;
/** 点赞用户名 */
@Excel(name = "点赞用户名")
@ApiModelProperty("点赞用户名")
private String userName;
/** 点赞状态:0 取消、1 正常 */
@Excel(name = "点赞状态:0 取消、1 正常")
@ApiModelProperty("点赞状态:0 取消、1 正常")
private Integer likeStatus;
}
package com.tangguo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tangguo.common.annotation.Excel;
import com.tangguo.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* 动态投票记录对象 bbs_moment_vote
*
* @author ruoyi
* @date 2025-09-01
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("bbs_moment_vote")
@ApiModel(value = "BbsMomentVote", description = "动态投票记录实体")
public class BbsMomentVote extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 动态ID */
@Excel(name = "动态ID")
@ApiModelProperty("动态ID")
private Long momentId;
/** 投票用户名 */
@Excel(name = "投票用户名")
@ApiModelProperty("投票用户名")
private String userName;
/** 投票选项编码 */
@Excel(name = "投票选项编码")
@ApiModelProperty("投票选项编码")
private String optionCode;
}
package com.tangguo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tangguo.common.annotation.Excel;
import com.tangguo.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* 动态投票选项对象 bbs_moment_vote_option
*
* @author ruoyi
* @date 2025-09-01
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("bbs_moment_vote_option")
@ApiModel(value = "BbsMomentVoteOption", description = "动态投票选项实体")
public class BbsMomentVoteOption extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
@ApiModelProperty("ID")
private Long id;
/** 动态ID */
@Excel(name = "动态ID")
@ApiModelProperty("动态ID")
private Long momentId;
/** 选项类型:TEXT 文字、IMAGE 图片 */
@Excel(name = "选项类型:TEXT 文字、IMAGE 图片")
@ApiModelProperty("选项类型:TEXT 文字、IMAGE 图片")
private String type;
/** 选项名称 */
@Excel(name = "选项名称")
@ApiModelProperty("选项名称")
private String name;
/** 选项编码 */
@Excel(name = "选项编码")
@ApiModelProperty("选项编码")
private String code;
/** 图片地址 */
@Excel(name = "图片地址")
@ApiModelProperty("图片地址")
private String imageUrl;
/** 排序值(升序) */
@Excel(name = "排序值", readConverterExp = "升=序")
@ApiModelProperty("排序值(升序)")
private Integer sort;
/** 投票人数 */
@Excel(name = "投票人数")
@ApiModelProperty("投票人数")
private Integer voteCount;
}
......@@ -13,7 +13,7 @@ import java.util.List;
* @createTime 2025-08-28 09:43:53 星期四
*/
@Data
public class DataImportResult<T> implements Serializable {
public class DataImportResult<T> implements Serializable {
private static final long serialVersionUID = -1544586244818112713L;
......
package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsMomentAttachments;
/**
* 动态附件Mapper接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface BbsMomentAttachmentsMapper extends BaseMapper<BbsMomentAttachments> {
}
package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsMomentLike;
/**
* 动态点赞记录Mapper接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface BbsMomentLikeMapper extends BaseMapper<BbsMomentLike> {
}
package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsMoment;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 动态Mapper接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
List<BbsMoment> selectBbsMomentList(@Param("moment") BbsMoment moment);
}
package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsMomentVote;
/**
* 动态投票记录Mapper接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface BbsMomentVoteMapper extends BaseMapper<BbsMomentVote> {
}
package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsMomentVoteOption;
/**
* 动态投票选项Mapper接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface BbsMomentVoteOptionMapper extends BaseMapper<BbsMomentVoteOption> {
}
package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMomentAttachments;
/**
* 动态附件Service接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface IBbsMomentAttachmentsService extends IService<BbsMomentAttachments> {
}
package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMomentLike;
/**
* 动态点赞记录Service接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface IBbsMomentLikeService extends IService<BbsMomentLike> {
}
package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMoment;
import java.util.List;
/**
* 动态Service接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface IBbsMomentService extends IService<BbsMoment> {
/**
* 查询动态列表
*
* @param bbsMoment 动态
* @return 动态集合
*/
public List<BbsMoment> selectBbsMomentList(BbsMoment bbsMoment);
}
package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMomentVoteOption;
/**
* 动态投票选项Service接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface IBbsMomentVoteOptionService extends IService<BbsMomentVoteOption> {
}
package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMomentVote;
/**
* 动态投票记录Service接口
*
* @author ruoyi
* @date 2025-09-01
*/
public interface IBbsMomentVoteService extends IService<BbsMomentVote> {
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.domain.BbsMomentAttachments;
import com.tangguo.mapper.BbsMomentAttachmentsMapper;
import com.tangguo.service.IBbsMomentAttachmentsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 动态附件Service业务层处理
*
* @author ruoyi
* @date 2025-09-01
*/
@Service
public class BbsMomentAttachmentsServiceImpl extends ServiceImpl<BbsMomentAttachmentsMapper, BbsMomentAttachments> implements IBbsMomentAttachmentsService {
@Resource
private BbsMomentAttachmentsMapper bbsMomentAttachmentsMapper;
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.domain.BbsMomentLike;
import com.tangguo.mapper.BbsMomentLikeMapper;
import com.tangguo.service.IBbsMomentLikeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 动态点赞记录Service业务层处理
*
* @author ruoyi
* @date 2025-09-01
*/
@Service
public class BbsMomentLikeServiceImpl extends ServiceImpl<BbsMomentLikeMapper, BbsMomentLike> implements IBbsMomentLikeService {
@Resource
private BbsMomentLikeMapper bbsMomentLikeMapper;
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.domain.BbsMoment;
import com.tangguo.mapper.BbsMomentMapper;
import com.tangguo.service.IBbsMomentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 动态Service业务层处理
*
* @author ruoyi
* @date 2025-09-01
*/
@Service
public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment> implements IBbsMomentService {
@Resource
private BbsMomentMapper bbsMomentMapper;
/**
* 查询动态列表
*
* @param moment 动态
* @return 动态
*/
@Override
public List<BbsMoment> selectBbsMomentList(BbsMoment moment) {
return this.baseMapper.selectBbsMomentList(moment);
}
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.domain.BbsMomentVoteOption;
import com.tangguo.mapper.BbsMomentVoteOptionMapper;
import com.tangguo.service.IBbsMomentVoteOptionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 动态投票选项Service业务层处理
*
* @author ruoyi
* @date 2025-09-01
*/
@Service
public class BbsMomentVoteOptionServiceImpl extends ServiceImpl<BbsMomentVoteOptionMapper, BbsMomentVoteOption> implements IBbsMomentVoteOptionService {
@Resource
private BbsMomentVoteOptionMapper bbsMomentVoteOptionMapper;
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.domain.BbsMomentVote;
import com.tangguo.mapper.BbsMomentVoteMapper;
import com.tangguo.service.IBbsMomentVoteService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 动态投票记录Service业务层处理
*
* @author ruoyi
* @date 2025-09-01
*/
@Service
public class BbsMomentVoteServiceImpl extends ServiceImpl<BbsMomentVoteMapper, BbsMomentVote> implements IBbsMomentVoteService {
@Resource
private BbsMomentVoteMapper bbsMomentVoteMapper;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentAttachmentsMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentLikeMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentMapper">
<select id="selectBbsMomentList" resultType="com.tangguo.domain.BbsMoment">
SELECT
m.*,
uv.nike_name,
uv.dept_name
FROM
bbs_moment m
LEFT JOIN
qwmh_sys_user_view uv ON uv.user_name = m.user_name
<where>
<if test="moment.content != null and moment.content != ''">
m.content LIKE CONCAT('%', #{moment.content}, '%')
</if>
<if test="moment.params.startTime != null and moment.params.startTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{moment.params.startTime}
</if>
<if test="moment.params.endTime != null and moment.params.endTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{moment.params.endTime}
</if>
</where>
ORDER BY
m.create_time DESC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentVoteMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentVoteOptionMapper">
</mapper>
......@@ -3,9 +3,7 @@ package com.tangguo.controller;
import com.tangguo.common.annotation.Log;
import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType;
import com.tangguo.common.utils.poi.ExcelUtil;
import com.tangguo.domain.BbsPointsSetting;
import com.tangguo.service.IBbsPointsSettingService;
import io.swagger.annotations.Api;
......@@ -14,9 +12,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 积分规则配置Controller
......@@ -38,25 +35,10 @@ public class BbsPointsSettingController extends BaseController {
*/
@ApiOperation("查询积分规则配置列表")
@PreAuthorize("@ss.hasPermi('points:points:list')")
@GetMapping("/list")
public TableDataInfo list(BbsPointsSetting bbsPointsSetting) {
startPage();
List<BbsPointsSetting> list = bbsPointsSettingService.selectBbsPointsSettingList(bbsPointsSetting);
return getDataTable(list);
}
/**
* 导出积分规则配置列表
*/
@ApiOperation("导出积分规则配置列表")
@PreAuthorize("@ss.hasPermi('points:points:export')")
@Log(title = "积分规则配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BbsPointsSetting bbsPointsSetting) {
List<BbsPointsSetting> list = bbsPointsSettingService.selectBbsPointsSettingList(bbsPointsSetting);
ExcelUtil<BbsPointsSetting> util = new ExcelUtil<BbsPointsSetting>(BbsPointsSetting.class);
util.exportExcel(response, list, "积分规则配置数据");
@GetMapping("/details")
public AjaxResult details() {
Map<String, List<BbsPointsSetting>> details = this.bbsPointsSettingService.getSettingDetails();
return AjaxResult.success(details);
}
......@@ -78,8 +60,9 @@ public class BbsPointsSettingController extends BaseController {
@PreAuthorize("@ss.hasPermi('points:points:add')")
@Log(title = "积分规则配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BbsPointsSetting bbsPointsSetting) {
return toAjax(bbsPointsSettingService.save(bbsPointsSetting));
public AjaxResult add(@RequestBody BbsPointsSetting setting) {
this.bbsPointsSettingService.addSetting(setting);
return AjaxResult.success();
}
......@@ -89,9 +72,10 @@ public class BbsPointsSettingController extends BaseController {
@ApiOperation("修改积分规则配置")
@PreAuthorize("@ss.hasPermi('points:points:edit')")
@Log(title = "积分规则配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BbsPointsSetting bbsPointsSetting) {
return toAjax(bbsPointsSettingService.updateById(bbsPointsSetting));
@PutMapping("/status")
public AjaxResult edit(@RequestBody BbsPointsSetting setting) {
this.bbsPointsSettingService.editSetting(setting);
return AjaxResult.success();
}
......@@ -101,9 +85,10 @@ public class BbsPointsSettingController extends BaseController {
@ApiOperation("删除积分规则配置")
@PreAuthorize("@ss.hasPermi('points:points:remove')")
@Log(title = "积分规则配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(bbsPointsSettingService.removeByIds(Arrays.asList(ids)));
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
this.bbsPointsSettingService.deleteSetting(id);
return AjaxResult.success();
}
}
......@@ -20,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
......@@ -85,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, "用户积分数据");
}
/**
* 用户积分兑换
*/
......
......@@ -2,6 +2,8 @@ package com.tangguo.domain.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 积分明细DTO
*
......@@ -9,25 +11,32 @@ import lombok.Data;
* @createTime 2025-08-29 17:23:29 星期五
*/
@Data
public class PointsDetailDTO {
public class PointsDetail implements Serializable {
private static final long serialVersionUID = 8057307839793769207L;
/**
* 明细名称
* 用户名 (必填)
*/
private String detailName;
private String userName;
/**
* 明细编码
* 明细积分 (必填)
*/
private String detailCode;
private int detailPoints;
/**
* 明细积分
* 明细名称 (必填)
*/
private Integer detailPoints;
private String detailName;
/**
* 明细编码
*/
private String detailCode;
/**
* 明细说明
* 明细说明 (必填)
*/
private String description;
......
package com.tangguo.domain.vo;
import com.tangguo.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
......
package com.tangguo.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 积分配置类型
*
* @author 谈笑
* @createTime 2025-09-01 10:14:35 星期一
*/
@Getter
@AllArgsConstructor
public enum PointsSettingType {
ADD("增加积分"), DEC("减少积分");
private final String desc;
}
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);
}
}
}
......@@ -2,7 +2,6 @@ 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;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsPointsSetting;
import java.util.List;
import java.util.Map;
/**
* 积分规则配置Service接口
......@@ -21,4 +22,44 @@ public interface IBbsPointsSettingService extends IService<BbsPointsSetting> {
*/
List<BbsPointsSetting> selectBbsPointsSettingList(BbsPointsSetting bbsPointsSetting);
/**
* 查询积分规则配置明细
*
* @return 配置明细
*/
Map<String, List<BbsPointsSetting>> getSettingDetails();
/**
* 添加积分配置
*
* @param setting 积分配置
*/
void addSetting(BbsPointsSetting setting);
/**
* 修改积分配置
*
* @param setting 积分配置
*/
void editSetting(BbsPointsSetting setting);
/**
* 删除积分配置
*
* @param settingId 配置Id
*/
void deleteSetting(Long settingId);
/**
* 修改配置状态
*
* @param setting 积分配置
*/
void setSettingStatus(BbsPointsSetting setting);
}
......@@ -2,7 +2,7 @@ package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.dto.PointsDetailDTO;
import com.tangguo.domain.dto.PointsDetail;
import java.util.List;
......@@ -51,20 +51,16 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
/**
* 增加用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
void incrUserPoints(String userName, int points, PointsDetailDTO detail);
void incrUserPoints(PointsDetail detail);
/**
* 扣减用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
void decrUserPoints(String userName, int points, PointsDetailDTO detail);
void decrUserPoints(PointsDetail detail);
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.utils.StringUtils;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.domain.BbsPointsSetting;
import com.tangguo.enums.PointsSettingType;
import com.tangguo.mapper.BbsPointsSettingMapper;
import com.tangguo.service.IBbsPointsSettingService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 积分规则配置Service业务层处理
......@@ -25,6 +29,7 @@ public class BbsPointsSettingServiceImpl extends ServiceImpl<BbsPointsSettingMap
@Resource
private BbsPointsSettingMapper bbsPointsSettingMapper;
/**
* 查询积分规则配置列表
*
......@@ -33,23 +38,117 @@ public class BbsPointsSettingServiceImpl extends ServiceImpl<BbsPointsSettingMap
*/
@Override
public List<BbsPointsSetting> selectBbsPointsSettingList(BbsPointsSetting bbsPointsSetting) {
return bbsPointsSettingMapper.selectList(buildQueryWrapper(bbsPointsSetting));
return this.list();
}
/**
* 查询积分规则配置明细
*
* @return 配置明细
*/
@Override
public Map<String, List<BbsPointsSetting>> getSettingDetails() {
List<BbsPointsSetting> settings = this.list();
List<BbsPointsSetting> addSetting = settings.stream()
.filter(s -> PointsSettingType.ADD.name().equals(s.getType())).collect(Collectors.toList());
List<BbsPointsSetting> decSetting = settings.stream()
.filter(s -> PointsSettingType.DEC.name().equals(s.getType())).collect(Collectors.toList());
Map<String, List<BbsPointsSetting>> settingMap = new LinkedHashMap<>(2);
settingMap.put(PointsSettingType.ADD.name(), addSetting);
settingMap.put(PointsSettingType.DEC.name(), decSetting);
return settingMap;
}
private LambdaQueryWrapper<BbsPointsSetting> buildQueryWrapper(BbsPointsSetting query) {
Map<String, Object> params = query.getParams();
LambdaQueryWrapper<BbsPointsSetting> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(BbsPointsSetting::getCreateTime);
lqw.eq(StringUtils.isNotBlank(query.getType()), BbsPointsSetting::getType, query.getType());
lqw.like(StringUtils.isNotBlank(query.getAgentName()), BbsPointsSetting::getAgentName, query.getAgentName());
lqw.eq(StringUtils.isNotBlank(query.getAgentId()), BbsPointsSetting::getAgentId, query.getAgentId());
lqw.like(StringUtils.isNotBlank(query.getOperateName()), BbsPointsSetting::getOperateName, query.getOperateName());
lqw.eq(StringUtils.isNotBlank(query.getOperateCode()), BbsPointsSetting::getOperateCode, query.getOperateCode());
lqw.eq(query.getOperatePoints() != null, BbsPointsSetting::getOperatePoints, query.getOperatePoints());
lqw.eq(query.getLimitCount() != null, BbsPointsSetting::getLimitCount, query.getLimitCount());
lqw.eq(query.getEnableStatus() != null, BbsPointsSetting::getEnableStatus, query.getEnableStatus());
return lqw;
/**
* 添加积分配置
*
* @param setting 积分配置
*/
@Override
public void addSetting(BbsPointsSetting setting) {
long nameCount = this.count(
Wrappers.lambdaQuery(BbsPointsSetting.class).eq(BbsPointsSetting::getOperateName, setting.getOperateName())
);
if (nameCount > 0) {
throw new ServiceException("新增失败,操作行为名称重复。");
}
BbsPointsSetting addSetting = new BbsPointsSetting();
addSetting.setType(setting.getType());
addSetting.setAgentName(setting.getAgentName());
addSetting.setOperateName(setting.getOperateName());
addSetting.setOperateCode(IdUtil.fastSimpleUUID());
addSetting.setOperatePoints(setting.getOperatePoints());
addSetting.setLimitCount(setting.getLimitCount());
addSetting.setEnableStatus(setting.getEnableStatus());
this.save(addSetting);
}
/**
* 修改积分配置
*
* @param setting 积分配置
*/
@Override
public void editSetting(BbsPointsSetting setting) {
BbsPointsSetting dbSetting = this.getById(setting.getId());
if (Objects.isNull(dbSetting)) {
throw new ServiceException("修改失败,未查询到当前积分配置数据。");
}
if (!dbSetting.getOperateName().equals(setting.getOperateName())) {
long nameCount = this.count(
Wrappers.lambdaQuery(BbsPointsSetting.class).eq(BbsPointsSetting::getOperateName, setting.getOperateName())
);
if (nameCount > 0) {
throw new ServiceException("修改失败,操作行为名称重复。");
}
}
BbsPointsSetting updSetting = new BbsPointsSetting();
updSetting.setId(dbSetting.getId());
updSetting.setOperateName(setting.getOperateName());
updSetting.setOperatePoints(setting.getOperatePoints());
updSetting.setLimitCount(setting.getLimitCount());
updSetting.setEnableStatus(setting.getEnableStatus());
this.updateById(updSetting);
}
/**
* 删除积分配置
*
* @param settingId 配置Id
*/
@Override
public void deleteSetting(Long settingId) {
this.removeById(settingId);
}
/**
* 修改配置状态
*
* @param setting 积分配置
*/
@Override
public void setSettingStatus(BbsPointsSetting setting) {
BbsPointsSetting dbSetting = this.getById(setting.getId());
if (Objects.isNull(dbSetting)) {
throw new ServiceException("修改失败,未查询到当前积分配置数据。");
}
if (!dbSetting.getEnableStatus().equals(setting.getEnableStatus())) {
BbsPointsSetting updSetting = new BbsPointsSetting();
updSetting.setId(dbSetting.getId());
updSetting.setEnableStatus(setting.getEnableStatus());
this.updateById(updSetting);
}
}
}
......@@ -6,7 +6,6 @@ import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.mapper.BbsUserPointsDetailMapper;
import com.tangguo.service.IBbsUserPointsDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......
......@@ -5,7 +5,7 @@ import com.tangguo.common.exception.ServiceException;
import com.tangguo.domain.BbsPointsGoods;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsExchange;
import com.tangguo.domain.dto.PointsDetailDTO;
import com.tangguo.domain.dto.PointsDetail;
import com.tangguo.mapper.BbsUserPointsExchangeMapper;
import com.tangguo.service.IBbsPointsGoodsService;
import com.tangguo.service.IBbsUserPointsExchangeService;
......@@ -85,11 +85,13 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
this.pointsGoodsService.incrGoodsSales(goodsId, 1);
// 扣减用户积分
PointsDetailDTO detail = new PointsDetailDTO();
PointsDetail detail = new PointsDetail();
detail.setUserName(userName);
detail.setDetailPoints(exchangePoints);
detail.setDetailName(dbGoods.getName());
detail.setDetailCode(dbGoods.getCode());
detail.setDescription(String.format("用户【%s】兑换积分商品【%s-%s】", userName, dbGoods.getName(), dbGoods.getCode()));
this.userPointsService.decrUserPoints(userName, exchangePoints, detail);
this.userPointsService.decrUserPoints(detail);
// 添加兑换记录
BbsUserPointsExchange addExchange = new BbsUserPointsExchange();
......
......@@ -6,12 +6,11 @@ import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.domain.dto.PointsDetailDTO;
import com.tangguo.domain.dto.PointsDetail;
import com.tangguo.mapper.BbsUserPointsMapper;
import com.tangguo.service.IBbsUserPointsDetailService;
import com.tangguo.service.IBbsUserPointsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -82,10 +81,12 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Override
public void addUserPoints(BbsUserPoints points) {
String userName = points.getUserName();
PointsDetailDTO detail = new PointsDetailDTO();
PointsDetail detail = new PointsDetail();
detail.setUserName(userName);
detail.setDetailPoints(points.getIncrOrDecrPoints());
detail.setDetailName("后台手动增加");
detail.setDescription(String.format("管理员【%s】后台手动增加用户【%s】积分", SecurityUtils.getUsername(), userName));
this.incrUserPoints(userName, points.getIncrOrDecrPoints(), detail);
this.incrUserPoints(detail);
}
......@@ -98,24 +99,24 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Override
public void deleteUserPoints(BbsUserPoints points) {
String userName = points.getUserName();
PointsDetailDTO detail = new PointsDetailDTO();
PointsDetail detail = new PointsDetail();
detail.setUserName(userName);
detail.setDetailPoints(points.getIncrOrDecrPoints());
detail.setDetailName("后台手动扣减");
detail.setDescription(String.format("管理员【%s】后台手动扣减用户【%s】积分", SecurityUtils.getUsername(), userName));
this.decrUserPoints(userName, points.getIncrOrDecrPoints(), detail);
this.decrUserPoints(detail);
}
/**
* 增加用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
@Override
public void incrUserPoints(String userName, int points, PointsDetailDTO detail) {
synchronized (userName.intern()) {
this.userPointsServiceImpl.execIncrUserPoints(userName, points, detail);
public void incrUserPoints(PointsDetail detail) {
synchronized (detail.getUserName().intern()) {
this.userPointsServiceImpl.privIncrUserPoints(detail);
}
}
......@@ -123,14 +124,12 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
/**
* 扣减用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
@Override
public void decrUserPoints(String userName, int points, PointsDetailDTO detail) {
synchronized (userName.intern()) {
this.userPointsServiceImpl.execDecrUserPoints(userName, points, detail);
public void decrUserPoints(PointsDetail detail) {
synchronized (detail.getUserName().intern()) {
this.userPointsServiceImpl.privDecrUserPoints(detail);
}
}
......@@ -138,17 +137,17 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
/**
* 增加用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
@Transactional(rollbackFor = Exception.class)
public void execIncrUserPoints(String userName, int points, PointsDetailDTO detail) {
public void privIncrUserPoints(PointsDetail detail) {
int points = detail.getDetailPoints();
if (points < 1) {
throw new ServiceException("增加用户积分失败,增加的积分分值不能小于0。");
}
// 更新用户积分
String userName = detail.getUserName();
BbsUserPoints userPoints = this.userPointsServiceImpl.getUserPoints(userName);
Integer currentPoints = userPoints.getCurrentPoints();
int incrCurrentPoints = currentPoints + points;
......@@ -172,17 +171,17 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
/**
* 扣减用户积分
*
* @param userName 用户名
* @param points 积分
* @param detail 积分明细
*/
@Transactional(rollbackFor = Exception.class)
public void execDecrUserPoints(String userName, int points, PointsDetailDTO detail) {
public void privDecrUserPoints(PointsDetail detail) {
int points = detail.getDetailPoints();
if (points < 1) {
throw new ServiceException("扣减用户积分失败,扣减的积分分值不能小于0。");
}
// 更新用户积分
String userName = detail.getUserName();
BbsUserPoints userPoints = this.userPointsServiceImpl.getUserPoints(userName);
Integer currentPoints = userPoints.getCurrentPoints();
if (points > currentPoints) {
......
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