916 lines
30 KiB
Markdown
916 lines
30 KiB
Markdown
# 缘池管理端设计文档
|
||
|
||
> 版本:V1.0
|
||
> 更新日期:2025-12-30
|
||
> 功能范围:板块管理 + 消息管理 + 自动审核
|
||
|
||
---
|
||
|
||
## 一、功能概述
|
||
|
||
缘池是直播平台的社交社区模块,用户可在不同板块发布消息进行交流。管理端提供板块配置、消息审核、自动审核规则设置等功能。
|
||
|
||
### 1.1 功能结构
|
||
|
||
```
|
||
缘池管理 (/community)
|
||
├── 板块管理 - 配置社区板块分类
|
||
├── 消息管理 - 查看/审核/管理用户消息
|
||
└── 审核配置 - 自动审核规则设置
|
||
```
|
||
|
||
### 1.2 自动审核机制
|
||
|
||
```
|
||
用户发布消息 → 敏感词检测 → 自动判定
|
||
↓
|
||
┌──────────┼──────────┐
|
||
↓ ↓ ↓
|
||
无敏感词 轻度敏感 重度敏感
|
||
↓ ↓ ↓
|
||
自动通过 待人工审核 自动拒绝
|
||
```
|
||
|
||
---
|
||
|
||
## 二、前端设计
|
||
|
||
### 2.1 路由配置
|
||
|
||
文件:`Zhibo/admin/src/router/modules/communityManage.js`
|
||
|
||
```javascript
|
||
import Layout from '@/layout';
|
||
|
||
const communityManageRouter = {
|
||
path: '/community',
|
||
component: Layout,
|
||
redirect: '/community/category',
|
||
name: 'Community',
|
||
alwaysShow: true,
|
||
meta: {
|
||
title: '缘池管理',
|
||
icon: 'el-icon-s-opportunity',
|
||
},
|
||
children: [
|
||
{
|
||
path: 'category',
|
||
component: () => import('@/views/community/category/index'),
|
||
name: 'CommunityCategory',
|
||
meta: { title: '板块管理', icon: '' },
|
||
},
|
||
{
|
||
path: 'message',
|
||
component: () => import('@/views/community/message/index'),
|
||
name: 'CommunityMessage',
|
||
meta: { title: '消息管理', icon: '' },
|
||
},
|
||
{
|
||
path: 'audit-config',
|
||
component: () => import('@/views/community/auditConfig/index'),
|
||
name: 'CommunityAuditConfig',
|
||
meta: { title: '审核配置', icon: '' },
|
||
},
|
||
],
|
||
};
|
||
|
||
export default communityManageRouter;
|
||
```
|
||
|
||
### 2.2 API接口
|
||
|
||
文件:`Zhibo/admin/src/api/community.js`
|
||
|
||
```javascript
|
||
import request from '@/utils/request';
|
||
|
||
// ==================== 板块管理 ====================
|
||
|
||
// 获取板块列表
|
||
export function categoryList(params) {
|
||
return request({
|
||
url: '/admin/community/category/list',
|
||
method: 'get',
|
||
params,
|
||
});
|
||
}
|
||
|
||
// 保存板块(新增/编辑)
|
||
export function categorySave(data) {
|
||
return request({
|
||
url: '/admin/community/category/save',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
|
||
// 删除板块
|
||
export function categoryDelete(id) {
|
||
return request({
|
||
url: `/admin/community/category/delete/${id}`,
|
||
method: 'delete',
|
||
});
|
||
}
|
||
|
||
// 更新板块状态
|
||
export function categoryStatus(data) {
|
||
return request({
|
||
url: '/admin/community/category/status',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
|
||
// ==================== 消息管理 ====================
|
||
|
||
// 获取消息列表(分页)
|
||
export function messageList(data) {
|
||
return request({
|
||
url: '/admin/community/message/list',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
|
||
// 审核消息
|
||
export function messageAudit(data) {
|
||
return request({
|
||
url: '/admin/community/message/audit',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
|
||
// 删除消息
|
||
export function messageDelete(id) {
|
||
return request({
|
||
url: `/admin/community/message/delete/${id}`,
|
||
method: 'delete',
|
||
});
|
||
}
|
||
|
||
// ==================== 审核配置 ====================
|
||
|
||
// 获取审核配置
|
||
export function getAuditConfig() {
|
||
return request({
|
||
url: '/admin/community/audit/config',
|
||
method: 'get',
|
||
});
|
||
}
|
||
|
||
// 保存审核配置
|
||
export function saveAuditConfig(data) {
|
||
return request({
|
||
url: '/admin/community/audit/config/save',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
```
|
||
|
||
### 2.3 页面设计
|
||
|
||
#### 2.3.1 板块管理页面
|
||
|
||
文件:`Zhibo/admin/src/views/community/category/index.vue`
|
||
|
||
```
|
||
┌─────────────────────────────────────────────────────────────┐
|
||
│ [+ 新增板块] │
|
||
├─────────────────────────────────────────────────────────────┤
|
||
│ 图标 │ 名称 │ 排序 │ 状态 │ 创建时间 │ 操作 │
|
||
├──────┼────────┼──────┼────────┼────────────┼───────────────┤
|
||
│ 🎮 │ 游戏 │ 100 │ ●启用 │ 2025-01-01 │ [编辑][删除] │
|
||
│ 🎵 │ 音乐 │ 90 │ ●启用 │ 2025-01-01 │ [编辑][删除] │
|
||
│ 💬 │ 交友 │ 80 │ ○禁用 │ 2025-01-01 │ [编辑][删除] │
|
||
└─────────────────────────────────────────────────────────────┘
|
||
```
|
||
|
||
**功能说明:**
|
||
- 新增板块:弹窗表单,填写名称、图标、排序
|
||
- 编辑板块:弹窗表单,修改板块信息
|
||
- 删除板块:确认弹窗后删除
|
||
- 状态切换:开关组件,启用/禁用板块
|
||
|
||
#### 2.3.2 消息管理页面
|
||
|
||
文件:`Zhibo/admin/src/views/community/message/index.vue`
|
||
|
||
```
|
||
┌─────────────────────────────────────────────────────────────────────┐
|
||
│ 板块[全部▼] 状态[全部▼] 审核方式[全部▼] 时间[起始-结束] [搜索] │
|
||
├─────────────────────────────────────────────────────────────────────┤
|
||
│ 用户 │ 板块 │ 内容 │ 图片 │ 状态 │ 审核方式│ 操作 │
|
||
├──────────┼──────┼──────────────┼──────┼────────┼─────────┼─────────┤
|
||
│ 👤张三 │ 游戏 │ 今天开黑吗.. │ 🖼x2 │ 已通过 │ 自动 │ [删除] │
|
||
│ 👤李四 │ 交友 │ 有人一起.. │ 🖼x1 │ 待审核 │ - │ [✓][✗] │
|
||
│ 👤王五 │ 音乐 │ 推荐一首.. │ - │ 已拒绝 │ 自动 │ [删除] │
|
||
└─────────────────────────────────────────────────────────────────────┘
|
||
```
|
||
|
||
**筛选条件:**
|
||
- 板块:下拉选择板块
|
||
- 状态:全部/待审核/已通过/已拒绝
|
||
- 审核方式:全部/自动/人工
|
||
- 时间范围:日期选择器
|
||
|
||
**操作说明:**
|
||
- 待审核消息:显示[通过][拒绝]按钮
|
||
- 已审核消息:显示[删除]按钮
|
||
- 点击内容可展开查看完整内容和图片
|
||
|
||
#### 2.3.3 审核配置页面
|
||
|
||
文件:`Zhibo/admin/src/views/community/auditConfig/index.vue`
|
||
|
||
```
|
||
┌─────────────────────────────────────────────────────────────┐
|
||
│ 自动审核配置 │
|
||
├─────────────────────────────────────────────────────────────┤
|
||
│ │
|
||
│ 开启自动审核 [========●] │
|
||
│ 说明:开启后系统自动检测敏感词并审核 │
|
||
│ │
|
||
│ 无敏感词自动通过 [========●] │
|
||
│ 说明:消息不含敏感词时自动通过审核 │
|
||
│ │
|
||
│ 重度敏感词自动拒绝 [========●] │
|
||
│ 说明:消息含违禁词时自动拒绝 │
|
||
│ │
|
||
│ [保存配置] │
|
||
└─────────────────────────────────────────────────────────────┘
|
||
```
|
||
|
||
---
|
||
|
||
## 三、数据库设计
|
||
|
||
### 3.1 板块表 (eb_community_category)
|
||
|
||
| 字段 | 类型 | 说明 |
|
||
|------|------|------|
|
||
| id | int | 板块ID,主键自增 |
|
||
| name | varchar(50) | 板块名称 |
|
||
| icon | varchar(255) | 板块图标URL |
|
||
| sort | int | 排序(越大越靠前) |
|
||
| status | tinyint | 状态 0禁用 1启用 |
|
||
| create_time | datetime | 创建时间 |
|
||
| update_time | datetime | 更新时间 |
|
||
|
||
### 3.2 消息表 (eb_community_message)
|
||
|
||
| 字段 | 类型 | 说明 |
|
||
|------|------|------|
|
||
| id | bigint | 消息ID,主键自增 |
|
||
| uid | int | 用户ID |
|
||
| category_id | int | 板块ID |
|
||
| content | text | 消息内容 |
|
||
| images | varchar(1000) | 图片URL(逗号分隔) |
|
||
| status | tinyint | 状态 0待审核 1通过 2拒绝 |
|
||
| audit_type | tinyint | 审核方式 0自动 1人工 |
|
||
| audit_remark | varchar(255) | 审核备注 |
|
||
| is_delete | tinyint | 是否删除 0否 1是 |
|
||
| create_time | datetime | 创建时间 |
|
||
| update_time | datetime | 更新时间 |
|
||
|
||
### 3.3 审核配置表 (eb_community_audit_config)
|
||
|
||
| 字段 | 类型 | 说明 |
|
||
|------|------|------|
|
||
| id | int | 配置ID,固定为1 |
|
||
| auto_audit | tinyint | 开启自动审核 0关闭 1开启 |
|
||
| auto_pass | tinyint | 无敏感词自动通过 0否 1是 |
|
||
| auto_reject | tinyint | 重度敏感词自动拒绝 0否 1是 |
|
||
| update_time | datetime | 更新时间 |
|
||
|
||
### 3.4 建表SQL
|
||
|
||
```sql
|
||
-- ============================================
|
||
-- 缘池管理数据库表
|
||
-- ============================================
|
||
|
||
-- 1. 板块表
|
||
CREATE TABLE `eb_community_category` (
|
||
`id` int NOT NULL AUTO_INCREMENT COMMENT '板块ID',
|
||
`name` varchar(50) NOT NULL COMMENT '板块名称',
|
||
`icon` varchar(255) DEFAULT '' COMMENT '板块图标URL',
|
||
`sort` int DEFAULT 0 COMMENT '排序(越大越靠前)',
|
||
`status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用',
|
||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池板块表';
|
||
|
||
-- 2. 消息表
|
||
CREATE TABLE `eb_community_message` (
|
||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息ID',
|
||
`uid` int NOT NULL COMMENT '用户ID',
|
||
`category_id` int NOT NULL COMMENT '板块ID',
|
||
`content` text COMMENT '消息内容',
|
||
`images` varchar(1000) DEFAULT '' COMMENT '图片URL(逗号分隔)',
|
||
`status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝',
|
||
`audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工',
|
||
`audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注(敏感词等)',
|
||
`is_delete` tinyint DEFAULT 0 COMMENT '是否删除 0否 1是',
|
||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_uid` (`uid`),
|
||
KEY `idx_category` (`category_id`),
|
||
KEY `idx_status` (`status`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池消息表';
|
||
|
||
-- 3. 审核配置表
|
||
CREATE TABLE `eb_community_audit_config` (
|
||
`id` int NOT NULL AUTO_INCREMENT,
|
||
`auto_audit` tinyint DEFAULT 1 COMMENT '开启自动审核 0关闭 1开启',
|
||
`auto_pass` tinyint DEFAULT 1 COMMENT '无敏感词自动通过 0否 1是',
|
||
`auto_reject` tinyint DEFAULT 1 COMMENT '重度敏感词自动拒绝 0否 1是',
|
||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池审核配置表';
|
||
|
||
-- 初始化审核配置
|
||
INSERT INTO `eb_community_audit_config` (`id`, `auto_audit`, `auto_pass`, `auto_reject`)
|
||
VALUES (1, 1, 1, 1);
|
||
|
||
-- 初始化默认板块
|
||
INSERT INTO `eb_community_category` (`name`, `icon`, `sort`, `status`) VALUES
|
||
('交友', 'el-icon-user', 100, 1),
|
||
('游戏', 'el-icon-video-play', 90, 1),
|
||
('音乐', 'el-icon-headset', 80, 1),
|
||
('运动', 'el-icon-football', 70, 1),
|
||
('美食', 'el-icon-food', 60, 1);
|
||
```
|
||
|
||
---
|
||
|
||
## 四、后端设计
|
||
|
||
### 4.1 实体类
|
||
|
||
#### CommunityCategory.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityCategory.java`
|
||
|
||
```java
|
||
package com.zbkj.common.model.community;
|
||
|
||
import com.baomidou.mybatisplus.annotation.IdType;
|
||
import com.baomidou.mybatisplus.annotation.TableId;
|
||
import com.baomidou.mybatisplus.annotation.TableName;
|
||
import lombok.Data;
|
||
import java.util.Date;
|
||
|
||
@Data
|
||
@TableName("eb_community_category")
|
||
public class CommunityCategory {
|
||
@TableId(type = IdType.AUTO)
|
||
private Integer id;
|
||
private String name;
|
||
private String icon;
|
||
private Integer sort;
|
||
private Integer status;
|
||
private Date createTime;
|
||
private Date updateTime;
|
||
}
|
||
```
|
||
|
||
#### CommunityMessage.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityMessage.java`
|
||
|
||
```java
|
||
package com.zbkj.common.model.community;
|
||
|
||
import com.baomidou.mybatisplus.annotation.IdType;
|
||
import com.baomidou.mybatisplus.annotation.TableId;
|
||
import com.baomidou.mybatisplus.annotation.TableName;
|
||
import lombok.Data;
|
||
import java.util.Date;
|
||
|
||
@Data
|
||
@TableName("eb_community_message")
|
||
public class CommunityMessage {
|
||
@TableId(type = IdType.AUTO)
|
||
private Long id;
|
||
private Integer uid;
|
||
private Integer categoryId;
|
||
private String content;
|
||
private String images;
|
||
private Integer status; // 0待审核 1通过 2拒绝
|
||
private Integer auditType; // 0自动 1人工
|
||
private String auditRemark;
|
||
private Integer isDelete;
|
||
private Date createTime;
|
||
private Date updateTime;
|
||
}
|
||
```
|
||
|
||
#### CommunityAuditConfig.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityAuditConfig.java`
|
||
|
||
```java
|
||
package com.zbkj.common.model.community;
|
||
|
||
import com.baomidou.mybatisplus.annotation.IdType;
|
||
import com.baomidou.mybatisplus.annotation.TableId;
|
||
import com.baomidou.mybatisplus.annotation.TableName;
|
||
import lombok.Data;
|
||
import java.util.Date;
|
||
|
||
@Data
|
||
@TableName("eb_community_audit_config")
|
||
public class CommunityAuditConfig {
|
||
@TableId(type = IdType.AUTO)
|
||
private Integer id;
|
||
private Integer autoAudit; // 开启自动审核
|
||
private Integer autoPass; // 无敏感词自动通过
|
||
private Integer autoReject; // 重度敏感词自动拒绝
|
||
private Date updateTime;
|
||
}
|
||
```
|
||
|
||
### 4.2 Controller
|
||
|
||
文件:`crmeb-admin/src/main/java/com/zbkj/admin/controller/CommunityAdminController.java`
|
||
|
||
```java
|
||
package com.zbkj.admin.controller;
|
||
|
||
import com.github.pagehelper.PageInfo;
|
||
import com.zbkj.common.model.community.*;
|
||
import com.zbkj.common.request.CommunityMessageRequest;
|
||
import com.zbkj.common.request.CommunityAuditRequest;
|
||
import com.zbkj.common.response.CommunityMessageVO;
|
||
import com.zbkj.common.result.CommonResult;
|
||
import com.zbkj.service.service.CommunityService;
|
||
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.List;
|
||
|
||
@RestController
|
||
@RequestMapping("/admin/community")
|
||
@Api(tags = "缘池管理")
|
||
public class CommunityAdminController {
|
||
|
||
@Autowired
|
||
private CommunityService communityService;
|
||
|
||
// ==================== 板块管理 ====================
|
||
|
||
@ApiOperation("板块列表")
|
||
@GetMapping("/category/list")
|
||
public CommonResult<List<CommunityCategory>> categoryList() {
|
||
return CommonResult.success(communityService.getCategoryList());
|
||
}
|
||
|
||
@ApiOperation("保存板块")
|
||
@PostMapping("/category/save")
|
||
public CommonResult<String> categorySave(@RequestBody CommunityCategory category) {
|
||
communityService.saveCategory(category);
|
||
return CommonResult.success("保存成功");
|
||
}
|
||
|
||
@ApiOperation("删除板块")
|
||
@DeleteMapping("/category/delete/{id}")
|
||
public CommonResult<String> categoryDelete(@PathVariable Integer id) {
|
||
communityService.deleteCategory(id);
|
||
return CommonResult.success("删除成功");
|
||
}
|
||
|
||
@ApiOperation("更新板块状态")
|
||
@PostMapping("/category/status")
|
||
public CommonResult<String> categoryStatus(@RequestBody CommunityCategory category) {
|
||
communityService.updateCategoryStatus(category.getId(), category.getStatus());
|
||
return CommonResult.success("更新成功");
|
||
}
|
||
|
||
// ==================== 消息管理 ====================
|
||
|
||
@ApiOperation("消息列表")
|
||
@PostMapping("/message/list")
|
||
public CommonResult<PageInfo<CommunityMessageVO>> messageList(
|
||
@RequestBody CommunityMessageRequest request) {
|
||
return CommonResult.success(communityService.getMessageList(request));
|
||
}
|
||
|
||
@ApiOperation("审核消息")
|
||
@PostMapping("/message/audit")
|
||
public CommonResult<String> messageAudit(@RequestBody CommunityAuditRequest request) {
|
||
communityService.auditMessage(request.getId(), request.getStatus(), request.getRemark());
|
||
return CommonResult.success("审核成功");
|
||
}
|
||
|
||
@ApiOperation("删除消息")
|
||
@DeleteMapping("/message/delete/{id}")
|
||
public CommonResult<String> messageDelete(@PathVariable Long id) {
|
||
communityService.deleteMessage(id);
|
||
return CommonResult.success("删除成功");
|
||
}
|
||
|
||
// ==================== 审核配置 ====================
|
||
|
||
@ApiOperation("获取审核配置")
|
||
@GetMapping("/audit/config")
|
||
public CommonResult<CommunityAuditConfig> getAuditConfig() {
|
||
return CommonResult.success(communityService.getAuditConfig());
|
||
}
|
||
|
||
@ApiOperation("保存审核配置")
|
||
@PostMapping("/audit/config/save")
|
||
public CommonResult<String> saveAuditConfig(@RequestBody CommunityAuditConfig config) {
|
||
communityService.saveAuditConfig(config);
|
||
return CommonResult.success("保存成功");
|
||
}
|
||
}
|
||
```
|
||
|
||
### 4.3 Service
|
||
|
||
文件:`crmeb-service/src/main/java/com/zbkj/service/service/CommunityService.java`
|
||
|
||
```java
|
||
package com.zbkj.service.service;
|
||
|
||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
import com.github.pagehelper.PageHelper;
|
||
import com.github.pagehelper.PageInfo;
|
||
import com.zbkj.common.model.community.*;
|
||
import com.zbkj.common.request.CommunityMessageRequest;
|
||
import com.zbkj.common.response.CommunityMessageVO;
|
||
import com.zbkj.service.dao.*;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Service;
|
||
import java.util.List;
|
||
|
||
@Service
|
||
public class CommunityService {
|
||
|
||
@Autowired
|
||
private CommunityCategoryDao categoryDao;
|
||
@Autowired
|
||
private CommunityMessageDao messageDao;
|
||
@Autowired
|
||
private CommunityAuditConfigDao auditConfigDao;
|
||
@Autowired
|
||
private SensitiveWordService sensitiveWordService;
|
||
|
||
// ==================== 板块管理 ====================
|
||
|
||
public List<CommunityCategory> getCategoryList() {
|
||
return categoryDao.selectList(new QueryWrapper<CommunityCategory>()
|
||
.orderByDesc("sort"));
|
||
}
|
||
|
||
public void saveCategory(CommunityCategory category) {
|
||
if (category.getId() != null) {
|
||
categoryDao.updateById(category);
|
||
} else {
|
||
categoryDao.insert(category);
|
||
}
|
||
}
|
||
|
||
public void deleteCategory(Integer id) {
|
||
categoryDao.deleteById(id);
|
||
}
|
||
|
||
public void updateCategoryStatus(Integer id, Integer status) {
|
||
CommunityCategory category = new CommunityCategory();
|
||
category.setId(id);
|
||
category.setStatus(status);
|
||
categoryDao.updateById(category);
|
||
}
|
||
|
||
// ==================== 消息管理 ====================
|
||
|
||
public PageInfo<CommunityMessageVO> getMessageList(CommunityMessageRequest request) {
|
||
PageHelper.startPage(request.getPage(), request.getLimit());
|
||
List<CommunityMessageVO> list = messageDao.selectMessageList(request);
|
||
return new PageInfo<>(list);
|
||
}
|
||
|
||
public void auditMessage(Long id, Integer status, String remark) {
|
||
CommunityMessage message = new CommunityMessage();
|
||
message.setId(id);
|
||
message.setStatus(status);
|
||
message.setAuditType(1); // 人工审核
|
||
message.setAuditRemark(remark != null ? remark : (status == 1 ? "人工审核通过" : "人工审核拒绝"));
|
||
messageDao.updateById(message);
|
||
}
|
||
|
||
public void deleteMessage(Long id) {
|
||
CommunityMessage message = new CommunityMessage();
|
||
message.setId(id);
|
||
message.setIsDelete(1);
|
||
messageDao.updateById(message);
|
||
}
|
||
|
||
// ==================== 自动审核(移动端发布时调用) ====================
|
||
|
||
public void autoAuditMessage(CommunityMessage message) {
|
||
CommunityAuditConfig config = getAuditConfig();
|
||
|
||
// 未开启自动审核,待人工审核
|
||
if (config.getAutoAudit() != 1) {
|
||
message.setStatus(0);
|
||
return;
|
||
}
|
||
|
||
// 敏感词检测
|
||
String content = message.getContent();
|
||
List<String> sensitiveWords = sensitiveWordService.findAll(content);
|
||
|
||
if (sensitiveWords.isEmpty()) {
|
||
// 无敏感词
|
||
if (config.getAutoPass() == 1) {
|
||
message.setStatus(1);
|
||
message.setAuditRemark("自动审核通过");
|
||
} else {
|
||
message.setStatus(0);
|
||
}
|
||
message.setAuditType(0);
|
||
} else if (sensitiveWordService.hasSevereWord(sensitiveWords)) {
|
||
// 重度敏感词
|
||
if (config.getAutoReject() == 1) {
|
||
message.setStatus(2);
|
||
message.setAuditRemark("含违禁词自动拒绝");
|
||
} else {
|
||
message.setStatus(0);
|
||
message.setAuditRemark("含敏感词:" + String.join(",", sensitiveWords));
|
||
}
|
||
message.setAuditType(0);
|
||
} else {
|
||
// 轻度敏感词,待人工审核
|
||
message.setStatus(0);
|
||
message.setAuditRemark("含敏感词:" + String.join(",", sensitiveWords));
|
||
message.setAuditType(0);
|
||
}
|
||
}
|
||
|
||
// ==================== 审核配置 ====================
|
||
|
||
public CommunityAuditConfig getAuditConfig() {
|
||
return auditConfigDao.selectById(1);
|
||
}
|
||
|
||
public void saveAuditConfig(CommunityAuditConfig config) {
|
||
config.setId(1);
|
||
auditConfigDao.updateById(config);
|
||
}
|
||
}
|
||
```
|
||
|
||
### 4.4 DAO层
|
||
|
||
#### CommunityCategoryDao.java
|
||
|
||
文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityCategoryDao.java`
|
||
|
||
```java
|
||
package com.zbkj.service.dao;
|
||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||
import com.zbkj.common.model.community.CommunityCategory;
|
||
import org.apache.ibatis.annotations.Mapper;
|
||
|
||
@Mapper
|
||
public interface CommunityCategoryDao extends BaseMapper<CommunityCategory> {
|
||
}
|
||
```
|
||
|
||
#### CommunityMessageDao.java
|
||
|
||
文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityMessageDao.java`
|
||
|
||
```java
|
||
package com.zbkj.service.dao;
|
||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||
import com.zbkj.common.model.community.CommunityMessage;
|
||
import com.zbkj.common.request.CommunityMessageRequest;
|
||
import com.zbkj.common.response.CommunityMessageVO;
|
||
import org.apache.ibatis.annotations.Mapper;
|
||
import org.apache.ibatis.annotations.Param;
|
||
import java.util.List;
|
||
|
||
@Mapper
|
||
public interface CommunityMessageDao extends BaseMapper<CommunityMessage> {
|
||
List<CommunityMessageVO> selectMessageList(@Param("req") CommunityMessageRequest request);
|
||
}
|
||
```
|
||
|
||
#### CommunityAuditConfigDao.java
|
||
|
||
文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityAuditConfigDao.java`
|
||
|
||
```java
|
||
package com.zbkj.service.dao;
|
||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||
import com.zbkj.common.model.community.CommunityAuditConfig;
|
||
import org.apache.ibatis.annotations.Mapper;
|
||
|
||
@Mapper
|
||
public interface CommunityAuditConfigDao extends BaseMapper<CommunityAuditConfig> {
|
||
}
|
||
```
|
||
|
||
### 4.5 Mapper XML
|
||
|
||
文件:`crmeb-service/src/main/resources/mapper/community/CommunityMessageMapper.xml`
|
||
|
||
```xml
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
<mapper namespace="com.zbkj.service.dao.CommunityMessageDao">
|
||
|
||
<select id="selectMessageList" resultType="com.zbkj.common.response.CommunityMessageVO">
|
||
SELECT
|
||
m.id, m.uid, m.category_id, m.content, m.images,
|
||
m.status, m.audit_type, m.audit_remark, m.create_time,
|
||
u.nickname, u.avatar,
|
||
c.name as category_name
|
||
FROM eb_community_message m
|
||
LEFT JOIN eb_user u ON m.uid = u.uid
|
||
LEFT JOIN eb_community_category c ON m.category_id = c.id
|
||
WHERE m.is_delete = 0
|
||
<if test="req.categoryId != null">
|
||
AND m.category_id = #{req.categoryId}
|
||
</if>
|
||
<if test="req.status != null">
|
||
AND m.status = #{req.status}
|
||
</if>
|
||
<if test="req.auditType != null">
|
||
AND m.audit_type = #{req.auditType}
|
||
</if>
|
||
<if test="req.startTime != null and req.endTime != null">
|
||
AND m.create_time BETWEEN #{req.startTime} AND #{req.endTime}
|
||
</if>
|
||
ORDER BY m.create_time DESC
|
||
</select>
|
||
|
||
</mapper>
|
||
```
|
||
|
||
### 4.6 Request/Response类
|
||
|
||
#### CommunityMessageRequest.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/request/CommunityMessageRequest.java`
|
||
|
||
```java
|
||
package com.zbkj.common.request;
|
||
|
||
import lombok.Data;
|
||
|
||
@Data
|
||
public class CommunityMessageRequest {
|
||
private Integer page = 1;
|
||
private Integer limit = 20;
|
||
private Integer categoryId; // 板块ID
|
||
private Integer status; // 状态
|
||
private Integer auditType; // 审核方式
|
||
private String startTime; // 开始时间
|
||
private String endTime; // 结束时间
|
||
}
|
||
```
|
||
|
||
#### CommunityAuditRequest.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/request/CommunityAuditRequest.java`
|
||
|
||
```java
|
||
package com.zbkj.common.request;
|
||
|
||
import lombok.Data;
|
||
|
||
@Data
|
||
public class CommunityAuditRequest {
|
||
private Long id; // 消息ID
|
||
private Integer status; // 审核状态 1通过 2拒绝
|
||
private String remark; // 审核备注
|
||
}
|
||
```
|
||
|
||
#### CommunityMessageVO.java
|
||
|
||
文件:`crmeb-common/src/main/java/com/zbkj/common/response/CommunityMessageVO.java`
|
||
|
||
```java
|
||
package com.zbkj.common.response;
|
||
|
||
import lombok.Data;
|
||
import java.util.Date;
|
||
|
||
@Data
|
||
public class CommunityMessageVO {
|
||
private Long id;
|
||
private Integer uid;
|
||
private Integer categoryId;
|
||
private String content;
|
||
private String images;
|
||
private Integer status;
|
||
private Integer auditType;
|
||
private String auditRemark;
|
||
private Date createTime;
|
||
// 关联字段
|
||
private String nickname; // 用户昵称
|
||
private String avatar; // 用户头像
|
||
private String categoryName; // 板块名称
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 五、文件清单
|
||
|
||
### 5.1 前端文件
|
||
|
||
```
|
||
Zhibo/admin/src/
|
||
├── api/
|
||
│ └── community.js # API接口
|
||
├── router/modules/
|
||
│ └── communityManage.js # 路由配置
|
||
└── views/community/
|
||
├── category/
|
||
│ └── index.vue # 板块管理页面
|
||
├── message/
|
||
│ └── index.vue # 消息管理页面
|
||
└── auditConfig/
|
||
└── index.vue # 审核配置页面
|
||
```
|
||
|
||
### 5.2 后端文件
|
||
|
||
```
|
||
Zhibo/zhibo-h/
|
||
├── crmeb-admin/src/main/java/com/zbkj/admin/controller/
|
||
│ └── CommunityAdminController.java # 控制器
|
||
├── crmeb-service/src/main/java/com/zbkj/service/
|
||
│ ├── service/
|
||
│ │ └── CommunityService.java # 服务层
|
||
│ └── dao/
|
||
│ ├── CommunityCategoryDao.java # 板块DAO
|
||
│ ├── CommunityMessageDao.java # 消息DAO
|
||
│ └── CommunityAuditConfigDao.java # 配置DAO
|
||
├── crmeb-service/src/main/resources/mapper/community/
|
||
│ └── CommunityMessageMapper.xml # Mapper XML
|
||
└── crmeb-common/src/main/java/com/zbkj/common/
|
||
├── model/community/
|
||
│ ├── CommunityCategory.java # 板块实体
|
||
│ ├── CommunityMessage.java # 消息实体
|
||
│ └── CommunityAuditConfig.java # 配置实体
|
||
├── request/
|
||
│ ├── CommunityMessageRequest.java # 消息查询请求
|
||
│ └── CommunityAuditRequest.java # 审核请求
|
||
└── response/
|
||
└── CommunityMessageVO.java # 消息响应VO
|
||
```
|
||
|
||
### 5.3 数据库
|
||
|
||
```
|
||
eb_community_category # 板块表
|
||
eb_community_message # 消息表
|
||
eb_community_audit_config # 审核配置表
|
||
```
|
||
|
||
---
|
||
|
||
## 六、菜单配置SQL
|
||
|
||
```sql
|
||
-- 添加缘池管理菜单
|
||
INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES
|
||
(0, '缘池管理', 'el-icon-s-opportunity', '', '/community', 'M', 140, 1);
|
||
|
||
SET @community_id = LAST_INSERT_ID();
|
||
|
||
INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES
|
||
(@community_id, '板块管理', '', 'admin:community:category', '/community/category', 'C', 3, 1),
|
||
(@community_id, '消息管理', '', 'admin:community:message', '/community/message', 'C', 2, 1),
|
||
(@community_id, '审核配置', '', 'admin:community:audit', '/community/audit-config', 'C', 1, 1);
|
||
```
|
||
|
||
---
|
||
|
||
## 七、开发顺序
|
||
|
||
1. **数据库** - 执行建表SQL
|
||
2. **后端实体类** - 创建Model类
|
||
3. **后端DAO** - 创建DAO接口和Mapper
|
||
4. **后端Service** - 实现业务逻辑
|
||
5. **后端Controller** - 实现API接口
|
||
6. **前端API** - 创建接口文件
|
||
7. **前端路由** - 配置路由
|
||
8. **前端页面** - 实现三个管理页面
|
||
9. **菜单配置** - 执行菜单SQL
|