mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-09 04:49:02 +08:00
✨ Introducing new features. 【系统管理】敏感词维护管理
This commit is contained in:
1 parent
60758a9567
commit
e690edb1d6
18 files changed
+789
-108
No files matched your search
+27
-2
@@ -465,8 +465,21 @@ CREATE TABLE `sys_log` (
|
||||
-- ----------------------------
|
||||
-- Records of sys_log
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
DROP TABLE IF EXISTS `sys_sensitive_word`;
|
||||
CREATE TABLE `sys_sensitive_word` (
|
||||
`sensitive_id` bigint NOT NULL COMMENT '主键',
|
||||
`sensitive_word` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '敏感词',
|
||||
`sensitive_type` char(1) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '类型',
|
||||
`remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
|
||||
`create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
`tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (`sensitive_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='敏感词';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_menu
|
||||
@@ -584,6 +597,12 @@ INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `p
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2913, '行政区划表删除', 'sys_sysArea_del', NULL, NULL, 2910, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:21', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2914, '导入导出', 'sys_sysArea_export', NULL, NULL, 2910, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:26', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2915, '行政区划表修改', 'sys_sysArea_edit', NULL, NULL, 2910, '1', '1', 2, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:31', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2920, '敏感词管理', '', '/admin/sensitive/index', NULL, 2000, 'iconfont icon-wenducanshu-05', '1', 12, '0', NULL, '0', '', NULL, 'admin', '2024-07-07 15:09:27', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2921, '敏感词查看', 'admin_sysSensitiveWord_view', NULL, NULL, 2920, '1', '1', 0, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2922, '敏感词新增', 'admin_sysSensitiveWord_add', NULL, NULL, 2920, '1', '1', 1, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2923, '敏感词修改', 'admin_sysSensitiveWord_edit', NULL, NULL, 2920, '1', '1', 2, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2924, '敏感词删除', 'admin_sysSensitiveWord_del', NULL, NULL, 2920, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2925, '导入导出', 'admin_sysSensitiveWord_export', NULL, NULL, 2920, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3000, '公众号平台', NULL, '/mp', NULL, 9900, 'iconfont icon-putong', '1', 3, '0', '0', '0', 'admin', '2023-02-24 10:40:44', 'admin', '2023-11-27 14:52:28', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3001, '账号管理', NULL, '/biz/mp/wx-account/index', NULL, 3000, 'iconfont icon-putong', '1', 0, '0', '0', '0', 'admin', '2023-02-24 10:43:03', ' ', '2023-11-01 17:28:07', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3002, '菜单设置', NULL, '/biz/mp/wx-menu/index', NULL, 3000, 'iconfont icon--chaifenlie', '1', 1, '0', '0', '0', 'admin', '2023-02-24 11:16:32', 'admin', '2023-11-01 17:28:11', '0', 1);
|
||||
@@ -954,6 +973,12 @@ INSERT INTO `sys_role_menu` VALUES (1, 2912);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2913);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2914);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2915);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2920);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2921);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2922);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2923);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2924);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2925);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3000);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3001);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3002);
|
||||
|
||||
@@ -335,6 +335,21 @@ CREATE TABLE `sys_file_group` (
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='文件分类表';
|
||||
|
||||
DROP TABLE IF EXISTS `sys_sensitive_word`;
|
||||
CREATE TABLE `sys_sensitive_word` (
|
||||
`sensitive_id` bigint NOT NULL COMMENT '主键',
|
||||
`sensitive_word` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '敏感词',
|
||||
`sensitive_type` char(1) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '类型',
|
||||
`remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
|
||||
`create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
`tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (`sensitive_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='敏感词';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_i18n
|
||||
-- ----------------------------
|
||||
@@ -581,6 +596,12 @@ INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `p
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2913, '行政区划表删除', 'sys_sysArea_del', NULL, NULL, 2910, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:21', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2914, '导入导出', 'sys_sysArea_export', NULL, NULL, 2910, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:26', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2915, '行政区划表修改', 'sys_sysArea_edit', NULL, NULL, 2910, '1', '1', 2, '0', NULL, '1', ' ', NULL, ' ', '2024-02-17 14:31:31', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2920, '敏感词管理', '', '/admin/sensitive/index', NULL, 2000, 'iconfont icon-wenducanshu-05', '1', 12, '0', NULL, '0', '', NULL, 'admin', '2024-07-07 15:09:27', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2921, '敏感词查看', 'admin_sysSensitiveWord_view', NULL, NULL, 2920, '1', '1', 0, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2922, '敏感词新增', 'admin_sysSensitiveWord_add', NULL, NULL, 2920, '1', '1', 1, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2923, '敏感词修改', 'admin_sysSensitiveWord_edit', NULL, NULL, 2920, '1', '1', 2, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2924, '敏感词删除', 'admin_sysSensitiveWord_del', NULL, NULL, 2920, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (2925, '导入导出', 'admin_sysSensitiveWord_export', NULL, NULL, 2920, '1', '1', 3, '0', NULL, '1', ' ', NULL, ' ', NULL, '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3000, '公众号平台', NULL, '/mp', NULL, 9900, 'iconfont icon-putong', '1', 3, '0', '0', '0', 'admin', '2023-02-24 10:40:44', 'admin', '2023-11-27 14:52:28', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3001, '账号管理', NULL, '/biz/mp/wx-account/index', NULL, 3000, 'iconfont icon-putong', '1', 0, '0', '0', '0', 'admin', '2023-02-24 10:43:03', ' ', '2023-11-01 17:28:07', '0', 1);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `name`, `permission`, `path`, `component`, `parent_id`, `icon`, `visible`, `sort_order`, `keep_alive`, `embedded`, `menu_type`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `tenant_id`) VALUES (3002, '菜单设置', NULL, '/biz/mp/wx-menu/index', NULL, 3000, 'iconfont icon--chaifenlie', '1', 1, '0', '0', '0', 'admin', '2023-02-24 11:16:32', 'admin', '2023-11-01 17:28:11', '0', 1);
|
||||
@@ -950,6 +971,12 @@ INSERT INTO `sys_role_menu` VALUES (1, 2912);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2913);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2914);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2915);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2920);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2921);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2922);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2923);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2924);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 2925);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3000);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3001);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 3002);
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<docker.plugin.version>0.33.0</docker.plugin.version>
|
||||
<cloud.plugin.version>1.0.0</cloud.plugin.version>
|
||||
<sentinel.version>1.8.4</sentinel.version>
|
||||
<sensitive.word.version>0.17.0</sensitive.word.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -189,6 +190,13 @@
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 必备:敏感词-->
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>${sensitive.word.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
|
||||
+91
-86
@@ -8,111 +8,116 @@ package com.pig4cloud.pigx.common.core.constant;
|
||||
*/
|
||||
public interface CacheConstants {
|
||||
|
||||
/**
|
||||
* 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
|
||||
* <p/>
|
||||
* {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")}
|
||||
*/
|
||||
String GLOBALLY = "gl:";
|
||||
/**
|
||||
* 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
|
||||
* <p/>
|
||||
* {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")}
|
||||
*/
|
||||
String GLOBALLY = "gl:";
|
||||
|
||||
/**
|
||||
* 验证码前缀
|
||||
*/
|
||||
String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY:";
|
||||
/**
|
||||
* 验证码前缀
|
||||
*/
|
||||
String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY:";
|
||||
|
||||
/**
|
||||
* 菜单信息缓存
|
||||
*/
|
||||
String MENU_DETAILS = "menu_details";
|
||||
/**
|
||||
* 菜单信息缓存
|
||||
*/
|
||||
String MENU_DETAILS = "menu_details";
|
||||
|
||||
/**
|
||||
* 用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS = "user_details";
|
||||
/**
|
||||
* 用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS = "user_details";
|
||||
|
||||
/**
|
||||
* 移动端用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS_MINI = "user_details_mini";
|
||||
/**
|
||||
* 移动端用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS_MINI = "user_details_mini";
|
||||
|
||||
/**
|
||||
* 角色信息缓存
|
||||
*/
|
||||
String ROLE_DETAILS = "role_details";
|
||||
/**
|
||||
* 角色信息缓存
|
||||
*/
|
||||
String ROLE_DETAILS = "role_details";
|
||||
|
||||
/**
|
||||
* 字典信息缓存
|
||||
*/
|
||||
String DICT_DETAILS = "dict_details";
|
||||
/**
|
||||
* 字典信息缓存
|
||||
*/
|
||||
String DICT_DETAILS = "dict_details";
|
||||
|
||||
/**
|
||||
* oauth 客户端信息
|
||||
*/
|
||||
String CLIENT_DETAILS_KEY = "pigx_oauth:client:details";
|
||||
/**
|
||||
* oauth 客户端信息
|
||||
*/
|
||||
String CLIENT_DETAILS_KEY = "pigx_oauth:client:details";
|
||||
|
||||
/**
|
||||
* spring boot admin 事件key
|
||||
*/
|
||||
String EVENT_KEY = GLOBALLY + "event_key";
|
||||
/**
|
||||
* spring boot admin 事件key
|
||||
*/
|
||||
String EVENT_KEY = GLOBALLY + "event_key";
|
||||
|
||||
/**
|
||||
* 路由存放
|
||||
*/
|
||||
String ROUTE_KEY = GLOBALLY + "gateway_route_key";
|
||||
/**
|
||||
* 路由存放
|
||||
*/
|
||||
String ROUTE_KEY = GLOBALLY + "gateway_route_key";
|
||||
|
||||
/**
|
||||
* 内存reload 时间
|
||||
*/
|
||||
String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic";
|
||||
/**
|
||||
* 内存reload 时间
|
||||
*/
|
||||
String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic";
|
||||
|
||||
/**
|
||||
* redis 重新加载 路由信息
|
||||
*/
|
||||
String ROUTE_REDIS_RELOAD_TOPIC = "upms_redis_route_reload_topic";
|
||||
/**
|
||||
* redis 重新加载 路由信息
|
||||
*/
|
||||
String ROUTE_REDIS_RELOAD_TOPIC = "upms_redis_route_reload_topic";
|
||||
|
||||
/**
|
||||
* redis 重新加载客户端信息
|
||||
*/
|
||||
String CLIENT_REDIS_RELOAD_TOPIC = "upms_redis_client_reload_topic";
|
||||
/**
|
||||
* redis 重新加载客户端信息
|
||||
*/
|
||||
String CLIENT_REDIS_RELOAD_TOPIC = "upms_redis_client_reload_topic";
|
||||
|
||||
/**
|
||||
* 公众号 reload
|
||||
*/
|
||||
String MP_REDIS_RELOAD_TOPIC = "mp_redis_reload_topic";
|
||||
/**
|
||||
* 敏感词重新加载
|
||||
*/
|
||||
String SENSITIVE_REDIS_RELOAD_TOPIC = "sensitive_client_reload_topic";
|
||||
|
||||
/**
|
||||
* 支付 reload 事件
|
||||
*/
|
||||
String PAY_REDIS_RELOAD_TOPIC = "pay_redis_reload_topic";
|
||||
/**
|
||||
* 公众号 reload
|
||||
*/
|
||||
String MP_REDIS_RELOAD_TOPIC = "mp_redis_reload_topic";
|
||||
|
||||
/**
|
||||
* 参数缓存
|
||||
*/
|
||||
String PARAMS_DETAILS = "params_details";
|
||||
/**
|
||||
* 支付 reload 事件
|
||||
*/
|
||||
String PAY_REDIS_RELOAD_TOPIC = "pay_redis_reload_topic";
|
||||
|
||||
/**
|
||||
* 租户缓存 (不区分租户)
|
||||
*/
|
||||
String TENANT_DETAILS = GLOBALLY + "tenant_details";
|
||||
/**
|
||||
* 参数缓存
|
||||
*/
|
||||
String PARAMS_DETAILS = "params_details";
|
||||
|
||||
/**
|
||||
* i18n缓存 (不区分租户)
|
||||
*/
|
||||
String I18N_DETAILS = GLOBALLY + "i18n_details";
|
||||
/**
|
||||
* 租户缓存 (不区分租户)
|
||||
*/
|
||||
String TENANT_DETAILS = GLOBALLY + "tenant_details";
|
||||
|
||||
/**
|
||||
* 客户端配置缓存
|
||||
*/
|
||||
String CLIENT_FLAG = "client_config_flag";
|
||||
/**
|
||||
* i18n缓存 (不区分租户)
|
||||
*/
|
||||
String I18N_DETAILS = GLOBALLY + "i18n_details";
|
||||
|
||||
/**
|
||||
* 登录错误次数
|
||||
*/
|
||||
String LOGIN_ERROR_TIMES = "login_error_times";
|
||||
/**
|
||||
* 客户端配置缓存
|
||||
*/
|
||||
String CLIENT_FLAG = "client_config_flag";
|
||||
|
||||
/**
|
||||
* oauth 缓存前缀
|
||||
*/
|
||||
String PROJECT_OAUTH_ACCESS = "token::access_token";
|
||||
/**
|
||||
* 登录错误次数
|
||||
*/
|
||||
String LOGIN_ERROR_TIMES = "login_error_times";
|
||||
|
||||
/**
|
||||
* oauth 缓存前缀
|
||||
*/
|
||||
String PROJECT_OAUTH_ACCESS = "token::access_token";
|
||||
|
||||
}
|
||||
@@ -40,25 +40,26 @@
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 必备:敏感词-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-extra</artifactId>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-feign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+87
-7
@@ -1,10 +1,23 @@
|
||||
package com.pig4cloud.pigx.common.sensitive;
|
||||
|
||||
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.sensitive.core.SensitiveService;
|
||||
import com.pig4cloud.pigx.common.sensitive.util.RemoteSensitiveService;
|
||||
import com.pig4cloud.pigx.common.sensitive.util.SensitiveWordsProperties;
|
||||
import com.pig4cloud.pigx.common.sensitive.word.SensitiveWordCustomizer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.ChannelTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -17,14 +30,11 @@ import java.util.Objects;
|
||||
* @author lengleng
|
||||
* @date 2024/6/27
|
||||
*/
|
||||
@Slf4j
|
||||
@AutoConfiguration
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(SensitiveWordsProperties.class)
|
||||
public class SensitiveAutoConfiguration {
|
||||
/**
|
||||
* 不脱敏的权限
|
||||
*/
|
||||
public static String NO_MASK = "no_mask";
|
||||
|
||||
|
||||
/**
|
||||
* 注入默认的脱敏权限判断
|
||||
@@ -33,7 +43,7 @@ public class SensitiveAutoConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SensitiveService sensitiveService() {
|
||||
public SensitiveService sensitiveService(SensitiveWordsProperties sensitiveWordsProperties) {
|
||||
return sensitive -> {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (Objects.isNull(authentication)) {
|
||||
@@ -42,7 +52,77 @@ public class SensitiveAutoConfiguration {
|
||||
|
||||
// 判断角色是否包含 no_mask 的权限
|
||||
return authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority)
|
||||
.noneMatch(s -> s.equals(NO_MASK));
|
||||
.noneMatch(s -> s.equals(sensitiveWordsProperties.getMask()));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化敏感词定制
|
||||
*
|
||||
* @return SensitiveWordCustomizer
|
||||
*/
|
||||
@Bean
|
||||
@Lazy
|
||||
public SensitiveWordCustomizer sensitiveWordCustomizer(RemoteSensitiveService remoteSensitiveService) {
|
||||
return new SensitiveWordCustomizer(remoteSensitiveService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载初始化引导类
|
||||
*
|
||||
* @return 初始化引导类
|
||||
*/
|
||||
@Bean
|
||||
@Lazy
|
||||
public SensitiveWordBs sensitiveWordBs(@Lazy SensitiveWordCustomizer sensitiveWordCustomizer
|
||||
, SensitiveWordsProperties sensitiveWordsProperties) {
|
||||
|
||||
|
||||
return SensitiveWordBs.newInstance()
|
||||
// 加载白名单数据
|
||||
.wordAllow(sensitiveWordCustomizer)
|
||||
// 加载黑名单数据
|
||||
.wordDeny(WordDenys.chains(WordDenys.defaults(), sensitiveWordCustomizer))
|
||||
// 忽略大小写
|
||||
.ignoreCase(sensitiveWordsProperties.isIgnoreCase())
|
||||
// 忽略半角圆角
|
||||
.ignoreWidth(sensitiveWordsProperties.isIgnoreWidth())
|
||||
// 忽略数字的写法
|
||||
.ignoreNumStyle(sensitiveWordsProperties.isIgnoreNumStyle())
|
||||
// 忽略中文的书写格式:简繁体
|
||||
.ignoreChineseStyle(sensitiveWordsProperties.isIgnoreChineseStyle())
|
||||
// 忽略英文的书写格式
|
||||
.ignoreEnglishStyle(sensitiveWordsProperties.isIgnoreEnglishStyle())
|
||||
// 忽略重复词
|
||||
.ignoreRepeat(sensitiveWordsProperties.isIgnoreRepeat())
|
||||
// 是否启用数字检测
|
||||
.enableNumCheck(sensitiveWordsProperties.isEnableNumCheck())
|
||||
// 是否启用邮箱检测
|
||||
.enableEmailCheck(sensitiveWordsProperties.isEnableEmailCheck())
|
||||
// 是否启用链接检测
|
||||
.enableUrlCheck(sensitiveWordsProperties.isEnableUrlCheck())
|
||||
// 数字检测,自定义指定长度
|
||||
.numCheckLen(sensitiveWordsProperties.getNumCheckLen())
|
||||
.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* redis 监听配置
|
||||
*
|
||||
* @param redisConnectionFactory redis 配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisContainer(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(redisConnectionFactory);
|
||||
container.addMessageListener((message, bytes) -> {
|
||||
log.info("开始重新加载敏感词库");
|
||||
SpringContextHolder.getBean(SensitiveWordBs.class).init();
|
||||
log.info("敏感词库加载完成");
|
||||
},
|
||||
new ChannelTopic(CacheConstants.SENSITIVE_REDIS_RELOAD_TOPIC));
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -18,13 +18,13 @@
|
||||
package com.pig4cloud.pigx.common.sensitive.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.BeanProperty;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.sensitive.annotation.Sensitive;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -56,7 +56,7 @@ public class SensitiveSerialize extends JsonSerializer<String> implements Contex
|
||||
}
|
||||
|
||||
// 判断是否有可以查看原文
|
||||
SensitiveService sensitiveService = SpringUtil.getBean(SensitiveService.class);
|
||||
SensitiveService sensitiveService = SpringContextHolder.getBean(SensitiveService.class);
|
||||
if (!sensitiveService.isSensitive(sensitive)) {
|
||||
jsonGenerator.writeString(origin);
|
||||
return;
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.pig4cloud.pigx.common.sensitive.util;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.feign.annotation.NoToken;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2024/7/7
|
||||
*/
|
||||
@FeignClient(contextId = "remoteSensitiveService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||
public interface RemoteSensitiveService {
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/sysSensitiveWord/remote/list/{type}")
|
||||
R<List<String>> list(@PathVariable String type);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.pig4cloud.pigx.common.sensitive.util;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 敏感词配置类
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2024/3/26
|
||||
* <p>
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(SensitiveWordsProperties.PREFIX)
|
||||
public class SensitiveWordsProperties {
|
||||
|
||||
public static final String PREFIX = "pigx.sensitive.word";
|
||||
|
||||
/**
|
||||
* The sensitive words to detect.
|
||||
*/
|
||||
private String mask = "*";
|
||||
|
||||
/**
|
||||
* Whether the sensitive words detection is enabled.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore case when detecting sensitive words.
|
||||
*/
|
||||
private boolean ignoreCase = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore width (full-width and half-width characters) when detecting
|
||||
* sensitive words.
|
||||
*/
|
||||
private boolean ignoreWidth = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore number style (Arabic numerals, Roman numerals, etc.) when
|
||||
* detecting sensitive words.
|
||||
*/
|
||||
private boolean ignoreNumStyle = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore Chinese style (simplified and traditional) when detecting
|
||||
* sensitive words.
|
||||
*/
|
||||
private boolean ignoreChineseStyle = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore English style (US and UK spelling) when detecting sensitive
|
||||
* words.
|
||||
*/
|
||||
private boolean ignoreEnglishStyle = true;
|
||||
|
||||
/**
|
||||
* Whether to ignore repeated words when detecting sensitive words.
|
||||
*/
|
||||
private boolean ignoreRepeat = true;
|
||||
|
||||
/**
|
||||
* Whether to enable number check when detecting sensitive words.
|
||||
*/
|
||||
private boolean enableNumCheck = true;
|
||||
|
||||
/**
|
||||
* Whether to enable email check when detecting sensitive words.
|
||||
*/
|
||||
private boolean enableEmailCheck = true;
|
||||
|
||||
/**
|
||||
* Whether to enable URL check when detecting sensitive words.
|
||||
*/
|
||||
private boolean enableUrlCheck = true;
|
||||
|
||||
/**
|
||||
* The length of numbers to check when detecting sensitive words.
|
||||
*/
|
||||
private int numCheckLen = 8;
|
||||
|
||||
/**
|
||||
* The error message to return when sensitive words are detected.
|
||||
*/
|
||||
private String errorMsg = "您的输入包含敏感词,请重新输入";
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.pig4cloud.pigx.common.sensitive.word;
|
||||
|
||||
import com.github.houbb.sensitive.word.api.IWordAllow;
|
||||
import com.github.houbb.sensitive.word.api.IWordDeny;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.YesNoEnum;
|
||||
import com.pig4cloud.pigx.common.core.util.RetOps;
|
||||
import com.pig4cloud.pigx.common.sensitive.util.RemoteSensitiveService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2024/7/6
|
||||
* <p>
|
||||
* 敏感词定制
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class SensitiveWordCustomizer implements IWordAllow, IWordDeny {
|
||||
|
||||
private final RemoteSensitiveService remoteSensitiveService;
|
||||
|
||||
/**
|
||||
* 白名单列表
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
public List<String> allow() {
|
||||
return RetOps.of(remoteSensitiveService.list(YesNoEnum.YES.getCode())).getData().orElseGet(ArrayList::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 黑名单列表
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
public List<String> deny() {
|
||||
return RetOps.of(remoteSensitiveService.list(YesNoEnum.NO.getCode())).getData().orElseGet(ArrayList::new);
|
||||
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
com.pig4cloud.pigx.common.sensitive.util.RemoteSensitiveService
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.pig4cloud.pigx.admin.api.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 敏感词
|
||||
*
|
||||
* @author pig
|
||||
* @date 2024-07-06 15:54:43
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("sys_sensitive_word")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "敏感词")
|
||||
public class SysSensitiveWordEntity extends Model<SysSensitiveWordEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
private Long sensitiveId;
|
||||
|
||||
/**
|
||||
* 敏感词
|
||||
*/
|
||||
@Schema(description="敏感词")
|
||||
private String sensitiveWord;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description="类型")
|
||||
private String sensitiveType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+1
-1
@@ -23,11 +23,11 @@ import com.pig4cloud.pigx.common.core.util.TenantTable;
|
||||
import com.pig4cloud.pigx.common.core.util.ValidGroup;
|
||||
import com.pig4cloud.pigx.common.sensitive.annotation.Sensitive;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSensitiveWordEntity;
|
||||
import com.pig4cloud.pigx.admin.service.SysSensitiveWordService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 敏感词
|
||||
*
|
||||
* @author pig
|
||||
* @date 2024-07-06 15:54:43
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/sysSensitiveWord")
|
||||
@Tag(description = "sysSensitiveWord", name = "敏感词管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SysSensitiveWordController {
|
||||
|
||||
private final SysSensitiveWordService sysSensitiveWordService;
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_view')")
|
||||
public R getSysSensitiveWordPage(@ParameterObject Page page, @ParameterObject SysSensitiveWordEntity sysSensitiveWord) {
|
||||
LambdaQueryWrapper<SysSensitiveWordEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(sysSensitiveWord.getSensitiveWord())
|
||||
, SysSensitiveWordEntity::getSensitiveWord, sysSensitiveWord.getSensitiveWord());
|
||||
wrapper.eq(StrUtil.isNotBlank(sysSensitiveWord.getSensitiveType())
|
||||
, SysSensitiveWordEntity::getSensitiveType, sysSensitiveWord.getSensitiveType());
|
||||
return R.ok(sysSensitiveWordService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "查询所有敏感词", description = "查询所有敏感词")
|
||||
@GetMapping("/remote/list/{type}")
|
||||
public R list(@PathVariable String type) {
|
||||
return R.ok(sysSensitiveWordService.list(Wrappers.<SysSensitiveWordEntity>lambdaQuery()
|
||||
.eq(SysSensitiveWordEntity::getSensitiveType, type)).stream().map(SysSensitiveWordEntity::getSensitiveWord).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询敏感词
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/details")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_view')")
|
||||
public R getById(@ParameterObject SysSensitiveWordEntity sysSensitiveWord) {
|
||||
return R.ok(sysSensitiveWordService.getOne(Wrappers.lambdaQuery(sysSensitiveWord), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增敏感词
|
||||
*
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增敏感词", description = "新增敏感词")
|
||||
@SysLog("新增敏感词")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_add')")
|
||||
public R save(@RequestBody SysSensitiveWordEntity sysSensitiveWord) {
|
||||
return R.ok(sysSensitiveWordService.saveSensitive(sysSensitiveWord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改敏感词
|
||||
*
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改敏感词", description = "修改敏感词")
|
||||
@SysLog("修改敏感词")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_edit')")
|
||||
public R updateById(@RequestBody SysSensitiveWordEntity sysSensitiveWord) {
|
||||
sysSensitiveWordService.updateById(sysSensitiveWord);
|
||||
redisTemplate.convertAndSend(CacheConstants.SENSITIVE_REDIS_RELOAD_TOPIC, "刷新敏感词缓存");
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询敏感词
|
||||
*
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "查询敏感词", description = "查询敏感词")
|
||||
@SysLog("查询敏感词")
|
||||
@PostMapping("/match")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_del')")
|
||||
public R match(@RequestBody SysSensitiveWordEntity sysSensitiveWord) {
|
||||
return R.ok(sysSensitiveWordService.matchSensitiveWord(sysSensitiveWord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除敏感词
|
||||
*
|
||||
* @param ids sensitiveId列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除敏感词", description = "通过id删除敏感词")
|
||||
@SysLog("通过id删除敏感词")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
sysSensitiveWordService.removeBatchByIds(CollUtil.toList(ids));
|
||||
redisTemplate.convertAndSend(CacheConstants.SENSITIVE_REDIS_RELOAD_TOPIC, "刷新敏感词缓存");
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param sysSensitiveWord 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_export')")
|
||||
public List<SysSensitiveWordEntity> export(SysSensitiveWordEntity sysSensitiveWord, Long[] ids) {
|
||||
return sysSensitiveWordService.list(Wrappers.lambdaQuery(sysSensitiveWord).in(ArrayUtil.isNotEmpty(ids), SysSensitiveWordEntity::getSensitiveId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新敏感词缓存
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "刷新敏感词缓存", description = "刷新敏感词缓存")
|
||||
@GetMapping("/refresh")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysSensitiveWord_del')")
|
||||
public R refresh() {
|
||||
redisTemplate.convertAndSend(CacheConstants.SENSITIVE_REDIS_RELOAD_TOPIC, "刷新敏感词缓存");
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.pig4cloud.pigx.admin.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSensitiveWordEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysSensitiveWordMapper extends PigxBaseMapper<SysSensitiveWordEntity> {
|
||||
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.pig4cloud.pigx.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSensitiveWordEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysSensitiveWordService extends IService<SysSensitiveWordEntity> {
|
||||
|
||||
/**
|
||||
* 查询敏感词
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return 敏感词列表
|
||||
*/
|
||||
List<String> matchSensitiveWord(SysSensitiveWordEntity sysSensitiveWord);
|
||||
|
||||
/**
|
||||
* 保存敏感词
|
||||
* @param sysSensitiveWord
|
||||
* @return
|
||||
*/
|
||||
Boolean saveSensitive(SysSensitiveWordEntity sysSensitiveWord);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSensitiveWordEntity;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysSensitiveWordMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysSensitiveWordService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 敏感词
|
||||
*
|
||||
* @author pig
|
||||
* @date 2024-07-06 15:54:43
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysSensitiveWordServiceImpl extends ServiceImpl<SysSensitiveWordMapper, SysSensitiveWordEntity> implements SysSensitiveWordService {
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 查询敏感词
|
||||
*
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return 敏感词列表
|
||||
*/
|
||||
@Override
|
||||
public List<String> matchSensitiveWord(SysSensitiveWordEntity sysSensitiveWord) {
|
||||
SensitiveWordBs sensitiveWordBs = SpringUtil.getBean(SensitiveWordBs.class);
|
||||
return sensitiveWordBs.findAll(sysSensitiveWord.getSensitiveWord());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存敏感词
|
||||
*
|
||||
* @param sysSensitiveWord 敏感词
|
||||
* @return success/false
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveSensitive(SysSensitiveWordEntity sysSensitiveWord) {
|
||||
List<SysSensitiveWordEntity> wordEntityList = baseMapper.selectList(Wrappers.<SysSensitiveWordEntity>lambdaQuery().
|
||||
eq(SysSensitiveWordEntity::getSensitiveWord, sysSensitiveWord.getSensitiveWord()));
|
||||
|
||||
if (CollUtil.isEmpty(wordEntityList)) {
|
||||
save(sysSensitiveWord);
|
||||
} else {
|
||||
wordEntityList.forEach(wordEntity -> {
|
||||
wordEntity.setSensitiveType(sysSensitiveWord.getSensitiveType());
|
||||
updateById(wordEntity);
|
||||
});
|
||||
}
|
||||
|
||||
redisTemplate.convertAndSend(CacheConstants.SENSITIVE_REDIS_RELOAD_TOPIC, "刷新敏感词缓存");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.pig4cloud.pigx.admin.mapper.SysSensitiveWordMapper">
|
||||
|
||||
<resultMap id="sysSensitiveWordMap" type="com.pig4cloud.pigx.admin.api.entity.SysSensitiveWordEntity">
|
||||
<id property="sensitiveId" column="sensitive_id"/>
|
||||
<result property="sensitiveWord" column="sensitive_word"/>
|
||||
<result property="sensitiveType" column="sensitive_type"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user