Эх сурвалжийг харах

管理员处罚界面更新

fangqing 2 сар өмнө
parent
commit
be64101c38

+ 14 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -178,6 +178,11 @@ public class SysUser extends BaseEntity {
      */
     private String userState;
 
+    /**
+     * 封禁时间
+     */
+    @Excel(name = "封禁时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
+    private Date reportTime;
 
     public SysUser() {
 
@@ -323,6 +328,14 @@ public class SysUser extends BaseEntity {
         this.loginDate = loginDate;
     }
 
+    public Date getReportTime() {
+        return reportTime;
+    }
+
+    public void setReportTime(Date reportTime) {
+        this.reportTime = reportTime;
+    }
+
     public SysDept getDept() {
         return dept;
     }
@@ -450,6 +463,7 @@ public class SysUser extends BaseEntity {
                 .append("remark", getRemark())
                 .append("dept", getDept())
                 .append("userState", getUserState())
+                .append("reportTime", getReportTime())
                 .toString();
     }
 

+ 91 - 16
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityReportController.java

@@ -1,31 +1,35 @@
 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;
 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.generator.domain.Community.*;
 import com.ruoyi.generator.mapper.community.CommunityReportDataMapper;
 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.CommunityUserNotificationVo;
 import com.ruoyi.generator.vo.CommunityUserPrivacyVo;
+import com.ruoyi.system.service.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.concurrent.TimeUnit;
 
 /**
  * 社区设置管理
@@ -47,7 +51,14 @@ public class CommunityReportController {
     @Autowired
     private CommunityReportUserMapper communityReportUserMapper;
 
+    @Autowired
+    private ISysUserService userService;
+
+    @Autowired
+    private ICommunityArticleService communityArticleService;
 
+    @Autowired
+    private ICommunityCommentReplyService communityCommentReplyService;
     /**
      * 获取举报类型信息
      * @param
@@ -87,7 +98,7 @@ public class CommunityReportController {
      * @return 用户举报
      */
     @ApiOperation("用户举报")
-    @GetMapping("/reportTypes")
+    @PostMapping("/reportTypes")
     //@Anonymous
     public AjaxResult reportMessage(@RequestBody CommunityReportUser communityReportUser) {
         if (Objects.isNull(communityReportUser.getUserId())) {
@@ -127,26 +138,90 @@ public class CommunityReportController {
     }
 
     /**
-     * 管理员查看界面
+     * 管理员处罚
      * @param
      * @return
      */
-    @ApiOperation("管理员处罚界面")
-    @GetMapping("/adminReportPunish")
+    @ApiOperation("管理员处罚")
+    @PostMapping("/ReportPunish")
     //@Anonymous
-    public AjaxResult adminReportPunish() {
-        List<CommunityReportUserVo> communityReportUsers = null;
+    public AjaxResult adminReportPunish(@RequestBody CommunityReportPunishVo communityReportPunishVo) {
+        if (communityReportPunishVo.getId() == null) {
+            return AjaxResult.error("ID不能为空");
+        }
         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) {
             System.out.println(e.getMessage());
             throw new ProjectException();
         }
-        return AjaxResult.success(communityReportUsers);
+        return AjaxResult.success(communityReportPunishVo);
     }
 
 }

+ 7 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityReportUser.java

@@ -89,6 +89,13 @@ public class CommunityReportUser implements Serializable {
     @ApiModelProperty("文章/评论ID")
     private String typeId;
 
+    /**
+     * 封禁理由
+     */
+    @ApiModelProperty("封禁理由")
+    private String punishContent;
+
+
     /**
      * 是否已删除
      */

+ 75 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityReportPunishVo.java

@@ -0,0 +1,75 @@
+package com.ruoyi.generator.vo;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CommunityReportPunishVo {
+
+    /**
+     *
+     */
+    @NotNull(message="[id]不能为空")
+    @ApiModelProperty("id")
+    @TableId("id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    /**
+     * 举报类型
+     */
+    @ApiModelProperty("type")
+    private Long type;
+
+    /**
+     * 文章/评论ID
+     */
+    @ApiModelProperty("文章/评论ID")
+    private Long typeId;
+
+    /**
+     * 被举报人ID
+     */
+    @ApiModelProperty("被举报人ID")
+    private Long userId;
+
+
+    /**
+     * 是否回复
+     */
+    @ApiModelProperty("是否回复")
+    private Boolean isReply;
+
+    /**
+     * 处置类型
+     */
+    @ApiModelProperty("处置类型")
+    private Long disposalType;
+
+    /**
+     * 处置时间
+     */
+    @ApiModelProperty("处置时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Long disposalTime;
+
+    /**
+     * 处置理由
+     */
+    @ApiModelProperty("处置理由")
+    private String dispositionReason;
+
+
+}

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -202,6 +202,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			<if test="remark != null">remark = #{remark},</if>
 			<if test="userState != null and userState != ''">user_state = #{userState},</if>
+			<if test="reportTime != null">report_time = #{reportTime},</if>
  			update_time = sysdate()
  		</set>
  		where user_id = #{userId}