|
@@ -1,31 +1,35 @@
|
|
package com.ruoyi.generator.controller;
|
|
package com.ruoyi.generator.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.text.Convert;
|
|
import com.ruoyi.common.core.text.Convert;
|
|
import com.ruoyi.common.exception.user.ProjectException;
|
|
import com.ruoyi.common.exception.user.ProjectException;
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
import com.ruoyi.generator.domain.Community.*;
|
|
import com.ruoyi.generator.domain.Community.*;
|
|
import com.ruoyi.generator.mapper.community.CommunityReportDataMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityReportDataMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityReportUserMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityReportUserMapper;
|
|
-import com.ruoyi.generator.service.ICommunityNotificationService;
|
|
|
|
-import com.ruoyi.generator.service.ICommunityPrivacyService;
|
|
|
|
-import com.ruoyi.generator.service.ICommunityReportDataService;
|
|
|
|
-import com.ruoyi.generator.service.ICommunityReportUserService;
|
|
|
|
|
|
+import com.ruoyi.generator.service.*;
|
|
|
|
+import com.ruoyi.generator.vo.CommunityReportPunishVo;
|
|
import com.ruoyi.generator.vo.CommunityReportUserVo;
|
|
import com.ruoyi.generator.vo.CommunityReportUserVo;
|
|
import com.ruoyi.generator.vo.CommunityUserNotificationVo;
|
|
import com.ruoyi.generator.vo.CommunityUserNotificationVo;
|
|
import com.ruoyi.generator.vo.CommunityUserPrivacyVo;
|
|
import com.ruoyi.generator.vo.CommunityUserPrivacyVo;
|
|
|
|
+import com.ruoyi.system.service.ISysUserService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 社区设置管理
|
|
* 社区设置管理
|
|
@@ -47,7 +51,14 @@ public class CommunityReportController {
|
|
@Autowired
|
|
@Autowired
|
|
private CommunityReportUserMapper communityReportUserMapper;
|
|
private CommunityReportUserMapper communityReportUserMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService userService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommunityArticleService communityArticleService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommunityCommentReplyService communityCommentReplyService;
|
|
/**
|
|
/**
|
|
* 获取举报类型信息
|
|
* 获取举报类型信息
|
|
* @param
|
|
* @param
|
|
@@ -87,7 +98,7 @@ public class CommunityReportController {
|
|
* @return 用户举报
|
|
* @return 用户举报
|
|
*/
|
|
*/
|
|
@ApiOperation("用户举报")
|
|
@ApiOperation("用户举报")
|
|
- @GetMapping("/reportTypes")
|
|
|
|
|
|
+ @PostMapping("/reportTypes")
|
|
//@Anonymous
|
|
//@Anonymous
|
|
public AjaxResult reportMessage(@RequestBody CommunityReportUser communityReportUser) {
|
|
public AjaxResult reportMessage(@RequestBody CommunityReportUser communityReportUser) {
|
|
if (Objects.isNull(communityReportUser.getUserId())) {
|
|
if (Objects.isNull(communityReportUser.getUserId())) {
|
|
@@ -127,26 +138,90 @@ public class CommunityReportController {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 管理员查看界面
|
|
|
|
|
|
+ * 管理员处罚
|
|
* @param
|
|
* @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation("管理员处罚界面")
|
|
|
|
- @GetMapping("/adminReportPunish")
|
|
|
|
|
|
+ @ApiOperation("管理员处罚")
|
|
|
|
+ @PostMapping("/ReportPunish")
|
|
//@Anonymous
|
|
//@Anonymous
|
|
- public AjaxResult adminReportPunish() {
|
|
|
|
- List<CommunityReportUserVo> communityReportUsers = null;
|
|
|
|
|
|
+ public AjaxResult adminReportPunish(@RequestBody CommunityReportPunishVo communityReportPunishVo) {
|
|
|
|
+ if (communityReportPunishVo.getId() == null) {
|
|
|
|
+ return AjaxResult.error("ID不能为空");
|
|
|
|
+ }
|
|
try {
|
|
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);
|
|
|
|
|
|
+ String disposalType = communityReportPunishVo.getDisposalType().toString(); //封禁类型
|
|
|
|
+ Long disposalTime = communityReportPunishVo.getDisposalTime(); //封禁时间
|
|
|
|
+ String dispositionReason = communityReportPunishVo.getDispositionReason(); //封禁理由
|
|
|
|
+ Long typeId = communityReportPunishVo.getTypeId();//封禁ID
|
|
|
|
+ //计算封禁的时间
|
|
|
|
+ Date date = DateUtils.parseDate(DateUtils.getTime());
|
|
|
|
+ Date futureDate = null;
|
|
|
|
+ if (disposalTime != null && disposalTime >= 0) {
|
|
|
|
+ long millisecondsToAdd = TimeUnit.MINUTES.toMillis(disposalTime); //转换时间
|
|
|
|
+ long currentTimeMillis = date.getTime();
|
|
|
|
+ long futureTimeMillis = currentTimeMillis + millisecondsToAdd;
|
|
|
|
+ futureDate = new Date(futureTimeMillis); //封禁时间
|
|
|
|
+ }
|
|
|
|
+ //更新个人信息表
|
|
|
|
+ SysUser user = new SysUser();
|
|
|
|
+ user.setUserId(communityReportPunishVo.getUserId());
|
|
|
|
+ user.setUserState(String.valueOf(communityReportPunishVo.getDisposalType()));
|
|
|
|
+ user.setReportTime(futureDate);
|
|
|
|
+
|
|
|
|
+ //更新处罚记录表
|
|
|
|
+ CommunityReportUser reportUser = new CommunityReportUser();
|
|
|
|
+ reportUser.setId(communityReportPunishVo.getId());
|
|
|
|
+ reportUser.setUserState(disposalType);
|
|
|
|
+ reportUser.setPunishContent(dispositionReason);
|
|
|
|
+ reportUser.setUpdateBy(SecurityUtils.getUserId());
|
|
|
|
+ reportUser.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ switch (disposalType) {
|
|
|
|
+ case "0": //不处理
|
|
|
|
+ break;
|
|
|
|
+ case "1": //封号
|
|
|
|
+ userService.updateUserProfile(user);
|
|
|
|
+ communityReportUserMapper.updateById(reportUser);
|
|
|
|
+ break;
|
|
|
|
+ case "2": //禁言
|
|
|
|
+ userService.updateUserProfile(user);
|
|
|
|
+ communityReportUserMapper.updateById(reportUser);
|
|
|
|
+ break;
|
|
|
|
+ case "3": //静置
|
|
|
|
+ CommunityArticle communityArticle = new CommunityArticle();
|
|
|
|
+ communityArticle.setIsDraft(true);
|
|
|
|
+ communityArticleService.update(communityArticle, new UpdateWrapper<CommunityArticle>().eq("id", communityReportPunishVo.getTypeId()));
|
|
|
|
+ communityReportUserMapper.updateById(reportUser);
|
|
|
|
+ break;
|
|
|
|
+ case "4": //删除
|
|
|
|
+ if (communityReportPunishVo.getIsReply()){
|
|
|
|
+ CommunityCommentReply communityCommentReply = new CommunityCommentReply();
|
|
|
|
+ communityCommentReply.setId(typeId);
|
|
|
|
+ communityCommentReply.setDelete(true);
|
|
|
|
+ communityCommentReply.setUpdateBy(SecurityUtils.getUserId());
|
|
|
|
+ communityCommentReply.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityCommentReplyService.updateById(communityCommentReply);
|
|
|
|
+ communityReportUserMapper.updateById(reportUser);
|
|
|
|
+ }else {
|
|
|
|
+ CommunityArticleComment communityArticleComment = new CommunityArticleComment();
|
|
|
|
+ communityArticleComment.setId(typeId);
|
|
|
|
+ communityArticleComment.setDelete(true);
|
|
|
|
+ communityArticleComment.setUpdateBy(SecurityUtils.getUserId());
|
|
|
|
+ communityArticleComment.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityArticleService.deleteComment(communityArticleComment);
|
|
|
|
+ communityReportUserMapper.updateById(reportUser);
|
|
|
|
+ }
|
|
|
|
+ //有评论也有回复
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
System.out.println(e.getMessage());
|
|
System.out.println(e.getMessage());
|
|
throw new ProjectException();
|
|
throw new ProjectException();
|
|
}
|
|
}
|
|
- return AjaxResult.success(communityReportUsers);
|
|
|
|
|
|
+ return AjaxResult.success(communityReportPunishVo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|