diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostReportController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostReportController.java index 49f53a7..3ae6e16 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostReportController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostReportController.java @@ -2,6 +2,8 @@ package com.inspur.web.controller.community; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.inspur.community.domain.vo.CommunityPostReportVO; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -42,7 +44,7 @@ public class CommunityPostReportController extends BaseController public TableDataInfo list(CommunityPostReport communityPostReport) { startPage(); - List list = communityPostReportService.selectCommunityPostReportList(communityPostReport); + List list = communityPostReportService.selectCommunityPostReportList(communityPostReport); return getDataTable(list); } @@ -54,8 +56,8 @@ public class CommunityPostReportController extends BaseController @PostMapping("/export") public void export(HttpServletResponse response, CommunityPostReport communityPostReport) { - List list = communityPostReportService.selectCommunityPostReportList(communityPostReport); - ExcelUtil util = new ExcelUtil(CommunityPostReport.class); + List list = communityPostReportService.selectCommunityPostReportList(communityPostReport); + ExcelUtil util = new ExcelUtil(CommunityPostReportVO.class); util.exportExcel(response, list, "社区帖子举报数据"); } diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityPostReport.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityPostReport.java index 5b35719..cdef9f4 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityPostReport.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityPostReport.java @@ -1,10 +1,13 @@ package com.inspur.community.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import com.inspur.common.annotation.Excel; import com.inspur.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.Date; + /** * 社区帖子举报对象 community_post_report * @@ -46,6 +49,12 @@ public class CommunityPostReport extends BaseEntity @Excel(name = "处理结果") private String result; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + public void setReportId(String reportId) { this.reportId = reportId; @@ -119,6 +128,22 @@ public class CommunityPostReport extends BaseEntity return result; } + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostReportVO.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostReportVO.java new file mode 100644 index 0000000..8b24dc3 --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostReportVO.java @@ -0,0 +1,44 @@ +package com.inspur.community.domain.vo; + +import com.inspur.common.annotation.Excel; +import lombok.Data; + +/** + * @Author zhangjunwen + * @create 2024/5/9 + */ +@Data +public class CommunityPostReportVO { + + private String reportId; + + /** 举报用户id */ + @Excel(name = "举报用户id") + private Long reportUserId; + + /** 被举报内容id */ + @Excel(name = "被举报内容id") + private String reportContentId; + + /** 举报时间 */ + @Excel(name = "举报时间") + private String reportTime; + + /** 举报原因 */ + @Excel(name = "举报原因") + private String reportReason; + + /** 状态:0 未处理,1 已处理 */ + @Excel(name = "状态:0 未处理,1 已处理") + private String status; + + /** 举报类型:0 帖子,1 回复 */ + @Excel(name = "举报类型:0 帖子,1 回复") + private String reportType; + + /** 处理结果 */ + @Excel(name = "处理结果") + private String result; + + private String userName; +} diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostReportMapper.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostReportMapper.java index 2bc493d..bc149f4 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostReportMapper.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostReportMapper.java @@ -2,6 +2,7 @@ package com.inspur.community.mapper; import java.util.List; import com.inspur.community.domain.CommunityPostReport; +import com.inspur.community.domain.vo.CommunityPostReportVO; /** * 社区帖子举报Mapper接口 @@ -17,7 +18,7 @@ public interface CommunityPostReportMapper * @param reportId 社区帖子举报主键 * @return 社区帖子举报 */ - public CommunityPostReport selectCommunityPostReportByReportId(String reportId); + public CommunityPostReportVO selectCommunityPostReportByReportId(String reportId); /** * 查询社区帖子举报列表 @@ -25,7 +26,7 @@ public interface CommunityPostReportMapper * @param communityPostReport 社区帖子举报 * @return 社区帖子举报集合 */ - public List selectCommunityPostReportList(CommunityPostReport communityPostReport); + public List selectCommunityPostReportList(CommunityPostReport communityPostReport); /** * 新增社区帖子举报 diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostReportService.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostReportService.java index cbf5fbb..15d3d86 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostReportService.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostReportService.java @@ -2,6 +2,7 @@ package com.inspur.community.service; import java.util.List; import com.inspur.community.domain.CommunityPostReport; +import com.inspur.community.domain.vo.CommunityPostReportVO; /** * 社区帖子举报Service接口 @@ -17,7 +18,7 @@ public interface ICommunityPostReportService * @param reportId 社区帖子举报主键 * @return 社区帖子举报 */ - public CommunityPostReport selectCommunityPostReportByReportId(String reportId); + public CommunityPostReportVO selectCommunityPostReportByReportId(String reportId); /** * 查询社区帖子举报列表 @@ -25,7 +26,7 @@ public interface ICommunityPostReportService * @param communityPostReport 社区帖子举报 * @return 社区帖子举报集合 */ - public List selectCommunityPostReportList(CommunityPostReport communityPostReport); + public List selectCommunityPostReportList(CommunityPostReport communityPostReport); /** * 新增社区帖子举报 diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReportServiceImpl.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReportServiceImpl.java index d5eb0d5..be70707 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReportServiceImpl.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReportServiceImpl.java @@ -1,11 +1,22 @@ package com.inspur.community.service.impl; import java.util.List; + +import com.inspur.common.utils.DateUtils; +import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.community.domain.CommunityPostInfo; +import com.inspur.community.domain.CommunityPostReply; +import com.inspur.community.domain.vo.CommunityPostReportVO; +import com.inspur.community.mapper.CommunityPostInfoMapper; +import com.inspur.community.mapper.CommunityPostReplyMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.community.mapper.CommunityPostReportMapper; import com.inspur.community.domain.CommunityPostReport; import com.inspur.community.service.ICommunityPostReportService; +import org.springframework.transaction.annotation.Transactional; + /** * 社区帖子举报Service业务层处理 @@ -19,6 +30,12 @@ public class CommunityPostReportServiceImpl implements ICommunityPostReportServi @Autowired private CommunityPostReportMapper communityPostReportMapper; + @Autowired + private CommunityPostInfoMapper communityPostInfoMapper; + + @Autowired + private CommunityPostReplyMapper communityPostReplyMapper; + /** * 查询社区帖子举报 * @@ -26,7 +43,7 @@ public class CommunityPostReportServiceImpl implements ICommunityPostReportServi * @return 社区帖子举报 */ @Override - public CommunityPostReport selectCommunityPostReportByReportId(String reportId) + public CommunityPostReportVO selectCommunityPostReportByReportId(String reportId) { return communityPostReportMapper.selectCommunityPostReportByReportId(reportId); } @@ -38,7 +55,7 @@ public class CommunityPostReportServiceImpl implements ICommunityPostReportServi * @return 社区帖子举报 */ @Override - public List selectCommunityPostReportList(CommunityPostReport communityPostReport) + public List selectCommunityPostReportList(CommunityPostReport communityPostReport) { return communityPostReportMapper.selectCommunityPostReportList(communityPostReport); } @@ -52,6 +69,10 @@ public class CommunityPostReportServiceImpl implements ICommunityPostReportServi @Override public int insertCommunityPostReport(CommunityPostReport communityPostReport) { + communityPostReport.setReportId(IdUtils.simpleUUID()); + communityPostReport.setReportUserId(SecurityUtils.getLoginUser().getUserId()); + communityPostReport.setReportTime(DateUtils.getTime()); + communityPostReport.setStatus("0"); return communityPostReportMapper.insertCommunityPostReport(communityPostReport); } @@ -61,9 +82,26 @@ public class CommunityPostReportServiceImpl implements ICommunityPostReportServi * @param communityPostReport 社区帖子举报 * @return 结果 */ + @Transactional(rollbackFor = Exception.class) @Override public int updateCommunityPostReport(CommunityPostReport communityPostReport) { + Integer processStatus = communityPostReport.getResult().split(":")[0] != null ? Integer.parseInt(communityPostReport.getResult().split(":")[0]) : 0; + if(processStatus != 0){ + //找到贴子或者评论 + if("0".equals(communityPostReport.getReportType())){//帖子 + CommunityPostInfo communityPostInfo = new CommunityPostInfo(); + communityPostInfo.setPostId(communityPostReport.getReportContentId()); + communityPostInfo.setStatus(String.valueOf(processStatus)); + communityPostInfoMapper.updateCommunityPostInfo(communityPostInfo); + }else{//回复 + CommunityPostReply communityPostReply = new CommunityPostReply(); + communityPostReply.setReplyId(communityPostReport.getReportContentId()); + communityPostReply.setStatus(String.valueOf(processStatus)); + communityPostReplyMapper.updateCommunityPostReply(communityPostReply); + } + } + communityPostReport.setStatus("1"); return communityPostReportMapper.updateCommunityPostReport(communityPostReport); } diff --git a/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostReportMapper.xml b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostReportMapper.xml index 285ee1f..2d1afa9 100644 --- a/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostReportMapper.xml +++ b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostReportMapper.xml @@ -15,24 +15,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + - select report_id, report_user_id, report_content_id, report_time, report_reason, status, report_type, result from community_post_report + select report_id, report_user_id, report_content_id, report_time, report_reason, a.status, report_type, result, b.nick_name as user_name from community_post_report a + left join sys_user b on a.report_user_id = b.user_id - and report_user_id = #{reportUserId} and report_content_id = #{reportContentId} - and report_time = #{reportTime} + and report_time >= #{startTime} + and report_time <= #{endTime} and report_reason = #{reportReason} - and status = #{status} + and a.status = #{status} and report_type = #{reportType} and result = #{result} + order by a.status - where report_id = #{reportId} diff --git a/inspur-ui/src/assets/icons/svg/report.svg b/inspur-ui/src/assets/icons/svg/report.svg new file mode 100644 index 0000000..90705ab --- /dev/null +++ b/inspur-ui/src/assets/icons/svg/report.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/inspur-ui/src/views/community/comment/Ipcomment.vue b/inspur-ui/src/views/community/comment/Ipcomment.vue index ccd33c7..680c86f 100644 --- a/inspur-ui/src/views/community/comment/Ipcomment.vue +++ b/inspur-ui/src/views/community/comment/Ipcomment.vue @@ -66,6 +66,7 @@ 回复 +
+ + 举报 +
回复 +
+ + 举报 +
{{blog.views}}
+
+ + 举报 +

{{blog.postTitle}} + + + + + + + + + + @@ -216,7 +271,13 @@ import { CommunityInfo, addViews, } from "@/api/community/info"; - +import { + listReport, + getReport, + delReport, + addReport, + updateReport, +} from "@/api/community/report"; export default { dicts: ["post_type", "community_field", "community_industry"], components: { @@ -228,6 +289,19 @@ export default { commentForm: { content: "", }, + //举报表单 + reportForm: {}, + reportRules: { + reportReason: [ + { + required: true, + message: "举报原因不能为空", + trigger: "blur", + }, + ], + }, + title: "举报内容", + open: false, }; }, watch: { @@ -242,6 +316,47 @@ export default { ...mapState(["userInfo", "administrator"]), }, methods: { + /** 提交按钮 */ + submitReportForm() { + this.$refs["reportForm"].validate((valid) => { + addReport(this.reportForm).then((response) => { + this.$modal.msgSuccess("举报成功"); + this.open = false; + this.reportForm = {}; + }); + }); + }, + cancelReport() { + this.open = false; + this.reset(); + }, + // 表单重置 + reset() { + this.form = { + reportId: null, + reportUserId: null, + reportContentId: null, + reportTime: null, + reportReason: null, + status: null, + reportType: null, + result: null, + }; + this.resetForm("reportForm"); + }, + //点击举报按钮 + handleReport(info, type) { + if (type == 0) { + //举报的贴子 + this.reportForm.reportContentId = info.postId; + this.reportForm.reportType = "0"; + } else { + //举报的评论 + this.reportForm.reportContentId = info.replyId; + this.reportForm.reportType = "1"; + } + this.open = true; + }, // 获取博客详情信息 async getBlogInfomation() { // 增加阅读量 @@ -391,6 +506,11 @@ hr.style-one { float: right; } +.blog-report { + text-align: right; + cursor: pointer; +} + .user-info { justify-content: space-around; align-items: center; diff --git a/inspur-ui/src/views/community/forum/index.vue b/inspur-ui/src/views/community/forum/index.vue index 7520ad7..df07c78 100644 --- a/inspur-ui/src/views/community/forum/index.vue +++ b/inspur-ui/src/views/community/forum/index.vue @@ -316,7 +316,7 @@
diff --git a/inspur-ui/src/views/community/report/index.vue b/inspur-ui/src/views/community/report/index.vue new file mode 100644 index 0000000..54b8041 --- /dev/null +++ b/inspur-ui/src/views/community/report/index.vue @@ -0,0 +1,552 @@ + + + + \ No newline at end of file