Commit 4e0fc896 authored by liwei's avatar liwei

修改了动态留言评论错误表相关功能,修改了禁言功能

parent d0e495d3
...@@ -106,7 +106,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -106,7 +106,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
private DictionaryUtil dictionaryUtil; private DictionaryUtil dictionaryUtil;
@Value("${cy.init.password}") @Value("${cy.init.password}")
private String password; private String password;
@Value("${forbidSpeech.limitCount}")
private Integer forbidSpeechLimitCount;
/** /**
* 保存 会员表 * 保存 会员表
...@@ -1066,6 +1067,14 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -1066,6 +1067,14 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
// 根据userId查询会员信息 // 根据userId查询会员信息
MemInfo memInfo = baseMapper.selectByUserId(userId); MemInfo memInfo = baseMapper.selectByUserId(userId);
memInfo.setMemMaliceLeaveMessageCount(memInfo.getMemMaliceLeaveMessageCount() + num); memInfo.setMemMaliceLeaveMessageCount(memInfo.getMemMaliceLeaveMessageCount() + num);
if (memInfo.getMemMaliceLeaveMessageCount() + num >= forbidSpeechLimitCount){
memInfo.setFlag("0");
// 修改用户表
SysUserRbac userRbac = new SysUserRbac();
userRbac.setBusinessId(memInfo.getUserId());
userRbac.setFlag("0");
sysUserRbacRepository.updateById(userRbac);
}
// 更新该会员的恶意留言次数 // 更新该会员的恶意留言次数
baseMapper.updateById(memInfo); baseMapper.updateById(memInfo);
} }
......
...@@ -51,10 +51,7 @@ import java.text.SimpleDateFormat; ...@@ -51,10 +51,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -219,6 +216,9 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -219,6 +216,9 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
// 自动审核 没通过 设置redis失败次数 达到一定次数 会被禁言 // 自动审核 没通过 设置redis失败次数 达到一定次数 会被禁言
userUtil.setUserForbidSpeech(userId); userUtil.setUserForbidSpeech(userId);
} }
} else {
// 人工审核
opmArticle.setExamStatus("0");
} }
//判断是否是普通动态 //判断是否是普通动态
if (opmArticle.getTopicId() == null){ if (opmArticle.getTopicId() == null){
...@@ -319,6 +319,22 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -319,6 +319,22 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
if (opmArticle.getRemarks()!= null){ if (opmArticle.getRemarks()!= null){
article.setRemarks(opmArticle.getRemarks()); article.setRemarks(opmArticle.getRemarks());
} }
if (opmArticle.getExamStatus().equals("2")){
// 手动驳回 新增错误信息
List<DictData> sysConfig = dictionaryService.selectByTypes("sys_config");
String style = sysConfig.get(0).getDictValue();
// 将opmArticle.getRemarks()是一个数组json,转成数组
List<String> msg = new ArrayList();
try {
JSONArray jsonArray = JSONUtil.parseArray(opmArticle.getRemarks());
for (int i = 0; i < jsonArray.size(); i++) {
msg.add(jsonArray.get(i).toString());
}
} catch (Exception e) {
msg.addAll(Collections.singleton(opmArticle.getRemarks()));
}
businessUtil.insertArticleCommentMessageError(msg,article.getBusinessId(),null,"1",style);
}
int line = baseMapper.updateById(article); int line = baseMapper.updateById(article);
//修改动态所有评论审核状态 //修改动态所有评论审核状态
//修改子表的评论数 给父级评论数+1 //修改子表的评论数 给父级评论数+1
......
package org.rcisoft.business.opmArticleCommentMessageError.entity; package org.rcisoft.business.opmArticleCommentMessageError.entity;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*; import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity; import org.rcisoft.core.entity.CyIdIncreEntity;
...@@ -28,7 +30,7 @@ public class OpmArticleCommentMessageError extends CyIdIncreEntity<OpmArticleCo ...@@ -28,7 +30,7 @@ public class OpmArticleCommentMessageError extends CyIdIncreEntity<OpmArticleCo
* @default * @default
*/ */
@Excel(name = "类型,1:动态 2:评论 3:留言", orderNum = "1", width = 20) @Excel(name = "类型,1:动态 2:评论 3:留言", orderNum = "1", width = 20)
private String type; private String eventType;
/** /**
* @desc 内容,评论/留言存内容,动态不存内容 * @desc 内容,评论/留言存内容,动态不存内容
...@@ -54,6 +56,19 @@ public class OpmArticleCommentMessageError extends CyIdIncreEntity<OpmArticleCo ...@@ -54,6 +56,19 @@ public class OpmArticleCommentMessageError extends CyIdIncreEntity<OpmArticleCo
@Excel(name = "失败原因", orderNum = "4", width = 20) @Excel(name = "失败原因", orderNum = "4", width = 20)
private String reason; private String reason;
/**
* 开始时间
*/
@TableField(exist = false)
private String beginTime;
/**
* 结束时间
*/
@TableField(exist = false)
private String endTime;
@TableField(exist = false)
private String createUserName;
} }
...@@ -120,12 +120,4 @@ public class ScheduleTasks { ...@@ -120,12 +120,4 @@ public class ScheduleTasks {
*/ */
@Scheduled(cron = "0 0 1 * * ?") @Scheduled(cron = "0 0 1 * * ?")
public void refreshMemMaliceLeaveCountSchedule() { memInfoService.refreshMemMaliceLeaveCountSchedule(); } public void refreshMemMaliceLeaveCountSchedule() { memInfoService.refreshMemMaliceLeaveCountSchedule(); }
/**
* 定时更新会员表和用户表 当恶意留言次数超过10时,就将该用户禁用
* 每分钟执行一次
*/
@Scheduled(cron = "0 0/1 * * * ?")
public void refreshMemFlagByMaliceLeaveCountSchedule() { memInfoService.refreshMemFlagByMaliceLeaveCountSchedule(); }
} }
...@@ -32,7 +32,7 @@ public class BusinessUtil { ...@@ -32,7 +32,7 @@ public class BusinessUtil {
} else { } else {
opmArticleCommentMessageError.setArticleId(null); opmArticleCommentMessageError.setArticleId(null);
} }
opmArticleCommentMessageError.setType(type); opmArticleCommentMessageError.setEventType(type);
opmArticleCommentMessageError.setReason(reason); opmArticleCommentMessageError.setReason(reason);
opmArticleCommentMessageError.setExamType(style); opmArticleCommentMessageError.setExamType(style);
opmArticleCommentMessageError.setContent(content); opmArticleCommentMessageError.setContent(content);
......
...@@ -68,14 +68,13 @@ public class UserUtil { ...@@ -68,14 +68,13 @@ public class UserUtil {
String month = today.format(monthFormatter); String month = today.format(monthFormatter);
String day = today.format(dayFormatter); String day = today.format(dayFormatter);
String date = month + day; String date = month + day;
Object redisOneHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":oneHourCount:" + userId); Object timeFlag = cyRedisServiceImpl.hget("user:forbidSpeech:" + date + ":timeFlag",userId);
Object redisTwoHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":twoHourCount:" + userId); if (timeFlag != null){
if (redisOneHourCount != null && redisTwoHourCount != null){ // 获取当前时间毫秒值
if ((Integer)redisTwoHourCount >= twoHourCount){ long currentTimeMillis = System.currentTimeMillis();
throw new CyServiceException(1008,"您已被禁言,请明天再试!"); if ((long)timeFlag >= currentTimeMillis){
} else if ((Integer)redisOneHourCount >= oneHourCount){ throw new CyServiceException(1008,"您已被禁言,请稍后再试!");
throw new CyServiceException(1009,"您已被禁言,请1小时后稍后再试!"); }
}
} }
} }
...@@ -91,18 +90,40 @@ public class UserUtil { ...@@ -91,18 +90,40 @@ public class UserUtil {
String month = today.format(monthFormatter); String month = today.format(monthFormatter);
String day = today.format(dayFormatter); String day = today.format(dayFormatter);
String date = month + day; String date = month + day;
// 获取当前时间 年月日时分秒
long currentTime = System.currentTimeMillis();
Object redisOneHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":oneHourCount:" + userId); Object redisOneHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":oneHourCount:" + userId);
Object redisTwoHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":twoHourCount:" + userId); Object redisTwoHourCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":twoHourCount:" + userId);
Object redisAllCount = cyRedisServiceImpl.get("user:forbidSpeech:" + date + ":allCount:" + userId);
if (redisOneHourCount == null && redisTwoHourCount == null){ if (redisOneHourCount == null && redisTwoHourCount == null){
// 没有被自动驳回过 设置初始值1 // 2小时内没有被自动驳回过 设置初始值1
cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":oneHourCount:" + userId,1, Long.valueOf(oneHourTime)); cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":oneHourCount:" + userId,1, 1*60*60L);
cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":twoHourCount:" + userId,1, 2*60*60*24L); cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":twoHourCount:" + userId,1, 2*60*60L);
if (redisAllCount != null){
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":allCount:" + userId,1L);
} else {
cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":allCount:" + userId,1,24*60*60L);
}
} else if (redisOneHourCount == null && redisTwoHourCount != null){ } else if (redisOneHourCount == null && redisTwoHourCount != null){
cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":oneHourCount:" + userId,1, Long.valueOf(oneHourTime)); // 2小时内被自动驳回过
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":twoHourCount:" + userId, Long.valueOf(1)); if ((int)redisTwoHourCount >= twoHourCount){
// 2小时内被驳回数大于限制数 禁言一天
cyRedisServiceImpl.hset("user:forbidSpeech:" + date + ":timeFlag",userId, currentTime + twoHourTime*1000);
} else {
cyRedisServiceImpl.set("user:forbidSpeech:" + date + ":oneHourCount:" + userId,1, 1*60*60L);
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":twoHourCount:" + userId, 1L);
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":allCount:" + userId,1L);
}
} else { } else {
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":oneHourCount:" + userId, Long.valueOf(1)); // 1小时内被驳回过
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":twoHourCount:" + userId, Long.valueOf(1)); if ((int)redisOneHourCount >= oneHourCount){
//1小时内被驳回数大于限制数 禁言1小时
cyRedisServiceImpl.hset("user:forbidSpeech:" + date + ":timeFlag",userId, currentTime + oneHourTime*1000);
} else {
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":oneHourCount:" + userId, 1L);
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":twoHourCount:" + userId, 1L);
cyRedisServiceImpl.incr("user:forbidSpeech:" + date + ":allCount:" + userId,1L);
}
} }
} }
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result column="del_flag" jdbcType="CHAR" property="delFlag"/> <result column="del_flag" jdbcType="CHAR" property="delFlag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/> <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="article_id" jdbcType="BIGINT" property="articleId"/> <result column="article_id" jdbcType="BIGINT" property="articleId"/>
<result column="type" jdbcType="CHAR" property="type"/> <result column="event_type" jdbcType="CHAR" property="eventType"/>
<result column="content" jdbcType="VARCHAR" property="content"/> <result column="content" jdbcType="VARCHAR" property="content"/>
<result column="exam_type" jdbcType="CHAR" property="examType"/> <result column="exam_type" jdbcType="CHAR" property="examType"/>
<result column="reason" jdbcType="VARCHAR" property="reason"/> <result column="reason" jdbcType="VARCHAR" property="reason"/>
...@@ -44,27 +44,35 @@ ...@@ -44,27 +44,35 @@
</select> </select>
<select id="queryOpmArticleCommentMessageErrorsPaged" resultMap="BaseResultMap"> <select id="queryOpmArticleCommentMessageErrorsPaged" resultMap="BaseResultMap">
select * from opm_article_comment_message_error select oacme.*, su.nick_name as createUserName
from opm_article_comment_message_error oacme
left join sys_user su on su.business_id = oacme.create_by
where 1=1 where 1=1
and del_flag = '0' and oacme.del_flag = '0'
<if test="entity.flag !=null and entity.flag != '' "> <if test="entity.flag !=null and entity.flag != '' ">
and flag = #{entity.flag} and oacme.flag = #{entity.flag}
</if> </if>
<if test="entity.articleId !=null and entity.articleId != '' "> <if test="entity.articleId !=null and entity.articleId != '' ">
and article_id = #{entity.articleId} and oacme.article_id = #{entity.articleId}
</if> </if>
<if test="entity.type !=null and entity.type != '' "> <if test="entity.eventType !=null and entity.eventType != '' ">
and type = #{entity.type} and oacme.eventType = #{entity.eventType}
</if> </if>
<if test="entity.content !=null and entity.content != '' "> <if test="entity.content !=null and entity.content != '' ">
and content like concat('%',#{entity.content},'%') and oacme.content like concat('%',#{entity.content},'%')
</if> </if>
<if test="entity.examType !=null and entity.examType != '' "> <if test="entity.examType !=null and entity.examType != '' ">
and exam_type = #{entity.examType} and oacme.exam_type = #{entity.examType}
</if> </if>
<if test="entity.reason !=null and entity.reason != '' "> <if test="entity.reason !=null and entity.reason != '' ">
and reason like concat('%',#{entity.reason},'%') and oacme.reason like concat('%',#{entity.reason},'%')
</if> </if>
ORDER BY business_id DESC <if test="entity.beginTime !=null and entity.beginTime != '' ">
and oacme.create_date &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and oacme.create_date &lt;= #{entity.endTime}
</if>
ORDER BY oacme.create_date DESC
</select> </select>
</mapper> </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