diff --git a/doc/sql/llm_20260208_pg.sql b/doc/sql/llm_20260208_pg.sql index 36bbe75..4facda3 100644 --- a/doc/sql/llm_20260208_pg.sql +++ b/doc/sql/llm_20260208_pg.sql @@ -539,6 +539,7 @@ CREATE TABLE d_acl_ip_rule ( is_deleted INT NOT NULL DEFAULT 0, PRIMARY KEY (id) ); +COMMENT ON TABLE d_acl_ip_rule IS '访问控制-IP黑白名单规则'; CREATE INDEX idx_acl_ip_scope_status ON d_acl_ip_rule (scope_code, status); CREATE INDEX idx_acl_ip_priority ON d_acl_ip_rule (priority); @@ -557,6 +558,7 @@ CREATE TABLE d_acl_endpoint_rule ( is_deleted INT NOT NULL DEFAULT 0, PRIMARY KEY (id) ); +COMMENT ON TABLE d_acl_endpoint_rule IS '访问控制-接口封堵规则'; CREATE INDEX idx_acl_ep_scope_status ON d_acl_endpoint_rule (scope_code, status); CREATE INDEX idx_acl_ep_match_type ON d_acl_endpoint_rule (match_type); @@ -577,6 +579,7 @@ CREATE TABLE d_acl_custom_rule ( PRIMARY KEY (id), CONSTRAINT uk_acl_custom_rule_code UNIQUE (rule_code) ); +COMMENT ON TABLE d_acl_custom_rule IS '访问控制-自定义组合规则'; CREATE INDEX idx_acl_custom_scope_status ON d_acl_custom_rule (scope_code, status); CREATE INDEX idx_acl_custom_priority ON d_acl_custom_rule (priority); @@ -593,6 +596,7 @@ CREATE TABLE d_acl_custom_condition ( PRIMARY KEY (id), CONSTRAINT fk_acl_condition_rule FOREIGN KEY (rule_id) REFERENCES d_acl_custom_rule(id) ON DELETE CASCADE ); +COMMENT ON TABLE d_acl_custom_condition IS '访问控制-组合规则条件明细'; CREATE INDEX idx_acl_condition_rule_seq ON d_acl_custom_condition (rule_id, seq_no); -- ========================= @@ -616,6 +620,7 @@ CREATE TABLE d_content_policy ( PRIMARY KEY (id), CONSTRAINT uk_content_policy_code UNIQUE (policy_code) ); +COMMENT ON TABLE d_content_policy IS '内容管控-合规策略'; CREATE INDEX idx_content_policy_scope_status ON d_content_policy (scope_code, status); CREATE TABLE d_content_dlp_rule ( @@ -635,6 +640,7 @@ CREATE TABLE d_content_dlp_rule ( PRIMARY KEY (id), CONSTRAINT uk_content_dlp_code UNIQUE (rule_code) ); +COMMENT ON TABLE d_content_dlp_rule IS '内容管控-DLP识别规则'; CREATE INDEX idx_content_dlp_scope_status ON d_content_dlp_rule (scope_code, status); CREATE TABLE d_content_mask_policy ( @@ -654,6 +660,7 @@ CREATE TABLE d_content_mask_policy ( PRIMARY KEY (id), CONSTRAINT uk_content_mask_policy_code UNIQUE (policy_code) ); +COMMENT ON TABLE d_content_mask_policy IS '内容管控-脱敏策略'; CREATE INDEX idx_content_mask_scope_status ON d_content_mask_policy (scope_code, status); -- ========================= @@ -676,6 +683,7 @@ CREATE TABLE d_attack_switch ( PRIMARY KEY (id), CONSTRAINT uk_attack_switch_scope_key UNIQUE (scope_code, switch_key) ); +COMMENT ON TABLE d_attack_switch IS '攻击防护-开关矩阵'; CREATE INDEX idx_attack_switch_scope_sort ON d_attack_switch (scope_code, sort_order); CREATE TABLE d_attack_rule ( @@ -695,6 +703,7 @@ CREATE TABLE d_attack_rule ( PRIMARY KEY (id), CONSTRAINT uk_attack_rule_code UNIQUE (rule_code) ); +COMMENT ON TABLE d_attack_rule IS '攻击防护-注入/提示词规则'; CREATE INDEX idx_attack_rule_scope_category ON d_attack_rule (scope_code, category); CREATE INDEX idx_attack_rule_status ON d_attack_rule (status); @@ -713,6 +722,7 @@ CREATE TABLE d_attack_signature ( is_deleted INT NOT NULL DEFAULT 0, PRIMARY KEY (id) ); +COMMENT ON TABLE d_attack_signature IS '攻击防护-特征库'; CREATE INDEX idx_attack_signature_scope_status ON d_attack_signature (scope_code, status); CREATE INDEX idx_attack_signature_rule_code ON d_attack_signature (rule_code); @@ -731,6 +741,7 @@ CREATE TABLE d_log_attack_policy ( is_deleted INT NOT NULL DEFAULT 0, PRIMARY KEY (id) ); +COMMENT ON TABLE d_log_attack_policy IS '攻击防护-日志策略'; CREATE INDEX idx_log_attack_policy_scope_status ON d_log_attack_policy (scope_code, status); -- ========================= @@ -773,6 +784,7 @@ CREATE TABLE d_log_alert_event ( PRIMARY KEY (id), CONSTRAINT uk_alert_event_no UNIQUE (event_no) ); +COMMENT ON TABLE d_log_alert_event IS '告警命中日志主表(记录请求触发的告警)'; CREATE INDEX idx_alert_request ON d_log_alert_event (request_id); CREATE INDEX idx_alert_trace ON d_log_alert_event (trace_id); CREATE INDEX idx_alert_scope_time ON d_log_alert_event (scope_code, occurred_at); @@ -798,4 +810,5 @@ CREATE TABLE d_log_alert_hit ( PRIMARY KEY (id), CONSTRAINT fk_log_alert_hit_event FOREIGN KEY (event_id) REFERENCES d_log_alert_event(id) ON DELETE CASCADE ); +COMMENT ON TABLE d_log_alert_hit IS '告警命中日志明细表(一条事件可包含多条命中明细)'; CREATE INDEX idx_alert_hit_event ON d_log_alert_hit (event_id, hit_order); diff --git a/doc/sql/llm_20260208_pg_表结构.xlsx b/doc/sql/llm_20260208_pg_表结构.xlsx new file mode 100644 index 0000000..81b36e7 Binary files /dev/null and b/doc/sql/llm_20260208_pg_表结构.xlsx differ diff --git a/doc/sql/sql_tables_with_cnname(1).xlsx b/doc/sql/sql_tables_with_cnname(1).xlsx new file mode 100644 index 0000000..e826b31 Binary files /dev/null and b/doc/sql/sql_tables_with_cnname(1).xlsx differ diff --git a/llm-guard-auth/pom.xml b/llm-guard-auth/pom.xml index e442b10..df806bd 100644 --- a/llm-guard-auth/pom.xml +++ b/llm-guard-auth/pom.xml @@ -52,18 +52,41 @@ - + ${project.artifactId} - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.llm.guard.auth.LlmAuthApplication + true + lib/ + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + copy-dependencies + package - repackage + copy-dependencies + + ${project.build.directory}/lib + false + diff --git a/llm-guard-common/llm-guard-common-datascope/src/main/java/com/llm/guard/common/datascope/aspect/DataScopeAspect.java b/llm-guard-common/llm-guard-common-datascope/src/main/java/com/llm/guard/common/datascope/aspect/DataScopeAspect.java index ff971e4..588c6a4 100644 --- a/llm-guard-common/llm-guard-common-datascope/src/main/java/com/llm/guard/common/datascope/aspect/DataScopeAspect.java +++ b/llm-guard-common/llm-guard-common-datascope/src/main/java/com/llm/guard/common/datascope/aspect/DataScopeAspect.java @@ -122,11 +122,11 @@ public class DataScopeAspect if (scopeCustomIds.size() > 1) { // 多个自定数据权限使用in查询,避免多次拼接。 - sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptAlias, String.join(",", scopeCustomIds))); + sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM d_sys_role_dept WHERE role_id in ({}) ) ", deptAlias, String.join(",", scopeCustomIds))); } else { - sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId())); + sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM d_sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId())); } } else if (DATA_SCOPE_DEPT.equals(dataScope)) @@ -135,7 +135,7 @@ public class DataScopeAspect } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { - sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); + sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM d_sys_dept WHERE dept_id = {} or concat(',', ancestors, ',') like concat('%,', {}, ',%') )", deptAlias, user.getDeptId(), user.getDeptId())); } else if (DATA_SCOPE_SELF.equals(dataScope)) { diff --git a/llm-guard-gateway/pom.xml b/llm-guard-gateway/pom.xml index dfdd642..c0d95ce 100644 --- a/llm-guard-gateway/pom.xml +++ b/llm-guard-gateway/pom.xml @@ -107,13 +107,36 @@ ${project.artifactId} - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.llm.guard.gateway.LlmGatewayApplication + true + lib/ + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + copy-dependencies + package - repackage + copy-dependencies + + ${project.build.directory}/lib + false + diff --git a/llm-guard-modules/llm-guard-biz/pom.xml b/llm-guard-modules/llm-guard-biz/pom.xml index d728d68..35931bf 100644 --- a/llm-guard-modules/llm-guard-biz/pom.xml +++ b/llm-guard-modules/llm-guard-biz/pom.xml @@ -115,13 +115,36 @@ ${project.artifactId} - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.llm.guard.biz.LlmBizApplication + true + lib/ + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + copy-dependencies + package - repackage + copy-dependencies + + ${project.build.directory}/lib + false + diff --git a/llm-guard-modules/llm-guard-system/pom.xml b/llm-guard-modules/llm-guard-system/pom.xml index 98cf30b..a060d9b 100644 --- a/llm-guard-modules/llm-guard-system/pom.xml +++ b/llm-guard-modules/llm-guard-system/pom.xml @@ -79,17 +79,41 @@ + ${project.artifactId} - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.llm.guard.system.LlmSystemApplication + true + lib/ + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + copy-dependencies + package - repackage + copy-dependencies + + ${project.build.directory}/lib + false + diff --git a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysConfigMapper.xml b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysConfigMapper.xml index 5b862bb..f9b327a 100644 --- a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysConfigMapper.xml +++ b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -51,10 +51,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND config_key like concat('%', #{configKey}, '%') - and date_format(create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d') + and date(create_time) >= date(#{params.beginTime}) - and date_format(create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') + and date(create_time) <= date(#{params.endTime}) @@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{configType}, #{createBy}, #{remark}, - sysdate() + now() ) @@ -98,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" config_type = #{configType}, update_by = #{updateBy}, remark = #{remark}, - update_time = sysdate() + update_time = now() where config_id = #{configId} diff --git a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysDeptMapper.xml b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysDeptMapper.xml index a2afa30..4406f52 100644 --- a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -73,11 +73,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -79,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status = #{status}, remark = #{remark}, update_by = #{updateBy}, - update_time = sysdate() + update_time = now() where dict_id = #{dictId} @@ -98,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{remark}, #{createBy}, - sysdate() + now() ) diff --git a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysLogininforMapper.xml b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysLogininforMapper.xml index 5540bb0..356fe48 100644 --- a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysLogininforMapper.xml +++ b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysLogininforMapper.xml @@ -15,7 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into d_sys_logininfor (user_name, status, ipaddr, msg, access_time) - values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate()) + values (#{userName}, #{status}, #{ipaddr}, #{msg}, now()) @@ -141,7 +141,7 @@ order_num = #{orderNum}, path = #{path}, component = #{component}, - `query` = #{query}, + query = #{query}, route_name = #{routeName}, is_frame = #{isFrame}, is_cache = #{isCache}, @@ -152,7 +152,7 @@ icon = #{icon}, remark = #{remark}, update_by = #{updateBy}, - update_time = sysdate() + update_time = now() where menu_id = #{menuId} @@ -165,7 +165,7 @@ order_num, path, component, - `query`, + query, route_name, is_frame, is_cache, @@ -195,7 +195,7 @@ #{icon}, #{remark}, #{createBy}, - sysdate() + now() ) @@ -203,4 +203,4 @@ delete from d_sys_menu where menu_id = #{menuId} - \ No newline at end of file + diff --git a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysNoticeMapper.xml index 2d404c5..6fb2214 100644 --- a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{remark}, #{createBy}, - sysdate() + now() ) @@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" notice_content = #{noticeContent}, status = #{status}, update_by = #{updateBy}, - update_time = sysdate() + update_time = now() where notice_id = #{noticeId} diff --git a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysOperLogMapper.xml index 3cbea48..bdcef9a 100644 --- a/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/llm-guard-modules/llm-guard-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into d_sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, cost_time, oper_time) - values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate()) + values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, now())