|
@@ -3,7 +3,6 @@ package com.ruoyi.generator.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.ruoyi.common.annotation.Anonymous;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
@@ -11,12 +10,15 @@ import com.ruoyi.common.exception.user.ProjectException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
|
-import com.ruoyi.common.utils.ip.IpUtils;
|
|
|
import com.ruoyi.generator.domain.Community.*;
|
|
|
import com.ruoyi.generator.mapper.community.CommunityReportDataMapper;
|
|
|
import com.ruoyi.generator.mapper.community.CommunityReportUserMapper;
|
|
|
-import com.ruoyi.generator.service.*;
|
|
|
-import com.ruoyi.generator.vo.*;
|
|
|
+import com.ruoyi.generator.service.ICommunityArticleService;
|
|
|
+import com.ruoyi.generator.service.ICommunityCommentReplyService;
|
|
|
+import com.ruoyi.generator.service.ICommunityReportUserService;
|
|
|
+import com.ruoyi.generator.vo.CommunityReportPunishVo;
|
|
|
+import com.ruoyi.generator.vo.CommunityReportUserVo;
|
|
|
+import com.ruoyi.generator.vo.CommunityUserReportVo;
|
|
|
import com.ruoyi.system.mapper.SysUserMapper;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -25,13 +27,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.Instant;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -66,8 +63,10 @@ public class CommunityReportController {
|
|
|
|
|
|
@Autowired
|
|
|
private SysUserMapper sysUserMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取举报类型信息
|
|
|
+ *
|
|
|
* @param
|
|
|
* @return 获取举报类型信息
|
|
|
*/
|
|
@@ -81,14 +80,14 @@ public class CommunityReportController {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
Page<CommunityReportData> page = new Page<>(offset, pageSize);
|
|
|
|
|
|
- List<CommunityReportData> communityReportData = null ;
|
|
|
+ List<CommunityReportData> communityReportData = null;
|
|
|
try {
|
|
|
QueryWrapper<CommunityReportData> queryWrapper = new QueryWrapper<CommunityReportData>()
|
|
|
.eq("type", type)
|
|
|
.and((wrapper) -> {
|
|
|
wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
});
|
|
|
- communityReportData = communityReportDataMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
+ communityReportData = communityReportDataMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
@@ -101,6 +100,7 @@ public class CommunityReportController {
|
|
|
|
|
|
/**
|
|
|
* 用户举报
|
|
|
+ *
|
|
|
* @param
|
|
|
* @return 用户举报
|
|
|
*/
|
|
@@ -122,10 +122,11 @@ public class CommunityReportController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 管理员查看界面
|
|
|
- * @param id 明细ID
|
|
|
- * @param type 举报类型
|
|
|
- * @param name 用户名称
|
|
|
+ * 管理员查看界面
|
|
|
+ *
|
|
|
+ * @param id 明细ID
|
|
|
+ * @param type 举报类型
|
|
|
+ * @param name 用户名称
|
|
|
* @param reason 举报理由
|
|
|
* @param userId 用户ID
|
|
|
* @return
|
|
@@ -133,15 +134,15 @@ public class CommunityReportController {
|
|
|
@ApiOperation("管理员查看界面")
|
|
|
@GetMapping("/adminReport")
|
|
|
//@Anonymous
|
|
|
- public AjaxResult adminReport(Long id,Long type,String name,String reason,String userId) {
|
|
|
+ public AjaxResult adminReport(Long id, Long type, String name, String reason, String userId) {
|
|
|
List<CommunityReportUserVo> communityReportUsers = null;
|
|
|
- int total = 0 ;
|
|
|
+ int total = 0;
|
|
|
try {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
|
|
|
- communityReportUsers = communityReportUserMapper.selectCommunityReportUser(offset, pageSize, searchType,id,type,name,reason,userId);
|
|
|
+ communityReportUsers = communityReportUserMapper.selectCommunityReportUser(offset, pageSize, searchType, id, type, name, reason, userId);
|
|
|
|
|
|
total = communityReportUserMapper.selectList(new QueryWrapper<CommunityReportUser>()
|
|
|
.and((wrapper) -> {
|
|
@@ -149,16 +150,16 @@ public class CommunityReportController {
|
|
|
})).size();
|
|
|
|
|
|
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
|
}
|
|
|
- return AjaxResult.successByCounts(communityReportUsers,total);
|
|
|
+ return AjaxResult.successByCounts(communityReportUsers, total);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 管理员处罚
|
|
|
+ *
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
@@ -173,7 +174,7 @@ public class CommunityReportController {
|
|
|
try {
|
|
|
//判断已经处罚过的数据 不进行处理
|
|
|
communityReportUsers = communityReportUserMapper
|
|
|
- .selectCommunityReportUser(0, 100, 0,communityReportPunishVo.getId(),null,null,null,null);
|
|
|
+ .selectCommunityReportUser(0, 100, 0, communityReportPunishVo.getId(), null, null, null, null);
|
|
|
if (!communityReportUsers.isEmpty()) {
|
|
|
CommunityReportUserVo firstUser = communityReportUsers.get(0);
|
|
|
Long updateBy = firstUser.getUpdateBy();
|
|
@@ -195,15 +196,14 @@ public class CommunityReportController {
|
|
|
if (reportTime != null && reportTime.after(date)) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM HH:mm:ss"); // 修改日期格式
|
|
|
String formattedReportTime = sdf.format(reportTime); // 格式化日期
|
|
|
- if ("1".equals(userState)){
|
|
|
+ if ("1".equals(userState)) {
|
|
|
return AjaxResult.success("该用户已经被封号! 截止日期为:" + formattedReportTime);
|
|
|
- }else if ("2".equals(userState) && "2".equals(disposalType)){
|
|
|
+ } else if ("2".equals(userState) && "2".equals(disposalType)) {
|
|
|
return AjaxResult.success("该用户已经被禁言! 截止日期为:" + formattedReportTime);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
//计算封禁的时间
|
|
|
|
|
|
Date futureDate = null;
|
|
@@ -248,7 +248,7 @@ public class CommunityReportController {
|
|
|
communityReportUserMapper.updateById(reportUser);
|
|
|
break;
|
|
|
case "4": //删除
|
|
|
- if (replyId != null){
|
|
|
+ if (replyId != null) {
|
|
|
CommunityCommentReply communityCommentReply = new CommunityCommentReply();
|
|
|
communityCommentReply.setId(Long.valueOf(communityReportPunishVo.getReplyId()));
|
|
|
communityCommentReply.setDelete(true);
|
|
@@ -256,7 +256,7 @@ public class CommunityReportController {
|
|
|
communityCommentReply.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
communityCommentReplyService.updateById(communityCommentReply);
|
|
|
communityReportUserMapper.updateById(reportUser);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
CommunityArticleComment communityArticleComment = new CommunityArticleComment();
|
|
|
communityArticleComment.setId(Long.valueOf(communityReportPunishVo.getCommentId()));
|
|
|
communityArticleComment.setDelete(true);
|
|
@@ -279,6 +279,7 @@ public class CommunityReportController {
|
|
|
|
|
|
/**
|
|
|
* 查询用户是否被封禁
|
|
|
+ *
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
@@ -290,6 +291,7 @@ public class CommunityReportController {
|
|
|
return AjaxResult.error("userId不能为空");
|
|
|
}
|
|
|
System.out.println(userId);
|
|
|
+ long result = 0L;
|
|
|
CommunityUserReportVo communityUserReportVo = new CommunityUserReportVo();
|
|
|
try {
|
|
|
|
|
@@ -300,10 +302,12 @@ public class CommunityReportController {
|
|
|
communityUserReportVo.setReportTime(reportTime);
|
|
|
|
|
|
//封禁时间
|
|
|
- Date date = DateUtils.parseDate(DateUtils.getTime());
|
|
|
- long diffInMillis = reportTime.getTime() - date.getTime();
|
|
|
- long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffInMillis);
|
|
|
- long result = Math.max(0, diffInMinutes);
|
|
|
+ if (reportTime != null) {
|
|
|
+ Date date = DateUtils.parseDate(DateUtils.getTime());
|
|
|
+ long diffInMillis = reportTime.getTime() - date.getTime();
|
|
|
+ long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffInMillis);
|
|
|
+ result = Math.max(0, diffInMinutes);
|
|
|
+ }
|
|
|
communityUserReportVo.setMinutes(result);
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|