From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-biz-common/jnpf-biz-common-audit/src/main/resources/mapper/AuditQueryMapper.xml | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/jnpf-biz-common/jnpf-biz-common-audit/src/main/resources/mapper/AuditQueryMapper.xml b/jnpf-biz-common/jnpf-biz-common-audit/src/main/resources/mapper/AuditQueryMapper.xml
new file mode 100644
index 0000000..fcc8b21
--- /dev/null
+++ b/jnpf-biz-common/jnpf-biz-common-audit/src/main/resources/mapper/AuditQueryMapper.xml
@@ -0,0 +1,114 @@
+<?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="jnpf.bizcommon.audit.mapper.AuditQueryMapper">
+
+ <!-- 鑷畾涔� SQL 鎵嬪啓缁撴灉鏄犲皠锛圠007锛欯Select/XML 鑷畾涔� SQL 涓嶈 MyBatis-Plus @TableField 娉ㄨВ锛�
+ 闇�鏄惧紡鍒楀嚭 column->property锛屾澶勪笉鐢� SELECT * 闅愬紡渚濊禆澶у皬鍐�/涓嬪垝绾胯嚜鍔ㄨ浆鎹級銆� -->
+ <resultMap id="AuditEventResultMap" type="jnpf.bizcommon.audit.entity.AuditEventEntity">
+ <id column="id" property="id"/>
+ <result column="client_event_id" property="clientEventId"/>
+ <result column="operation_id" property="operationId"/>
+ <result column="event_time" property="eventTime"/>
+ <result column="tenant_id" property="tenantId"/>
+ <result column="operator_id" property="operatorId"/>
+ <result column="operator_name" property="operatorName"/>
+ <result column="operator_org_id" property="operatorOrgId"/>
+ <result column="app_name" property="appName"/>
+ <result column="biz_module" property="bizModule"/>
+ <result column="ip" property="ip"/>
+ <result column="ip_region" property="ipRegion"/>
+ <result column="browser" property="browser"/>
+ <result column="os" property="os"/>
+ <result column="request_uri" property="requestUri"/>
+ <result column="event_type" property="eventType"/>
+ <result column="event_category" property="eventCategory"/>
+ <result column="action_code" property="actionCode"/>
+ <result column="action_label" property="actionLabel"/>
+ <result column="source_layer" property="sourceLayer"/>
+ <result column="target_table" property="targetTable"/>
+ <result column="target_id" property="targetId"/>
+ <result column="biz_type" property="bizType"/>
+ <result column="biz_code" property="bizCode"/>
+ <result column="field_diffs" property="fieldDiffs"/>
+ <result column="extra" property="extra"/>
+ <result column="data_snapshot" property="dataSnapshot"/>
+ <result column="reason" property="reason"/>
+ <result column="record_title" property="recordTitle"/>
+ <result column="entry_type" property="entryType"/>
+ <result column="entry_id" property="entryId"/>
+ <result column="entry_name" property="entryName"/>
+ <result column="prev_hash" property="prevHash"/>
+ <result column="created_at" property="createdAt"/>
+ </resultMap>
+
+ <resultMap id="OperationGroupRowMap" type="jnpf.bizcommon.audit.entity.model.AuditOperationGroupRow">
+ <result column="gid" property="gid"/>
+ <result column="grp_time" property="grpTime"/>
+ </resultMap>
+
+ <select id="selectOperationPage" resultMap="OperationGroupRowMap">
+ SELECT matched.gid, matched.grp_time
+ FROM (
+ SELECT COALESCE(operation_id, client_event_id) AS gid,
+ MAX(event_time) AS grp_time
+ FROM audit_events
+ ${ew.customSqlSegment}
+ GROUP BY gid
+ ) matched
+ WHERE EXISTS (
+ SELECT 1 FROM audit_events business
+ WHERE COALESCE(business.operation_id, business.client_event_id) = matched.gid
+ AND business.event_category = 'BUSINESS'
+ )
+ ORDER BY matched.grp_time DESC
+ LIMIT #{size} OFFSET #{offset}
+ </select>
+
+ <select id="countOperations" resultType="long">
+ SELECT COUNT(*)
+ FROM (
+ SELECT COALESCE(operation_id, client_event_id) AS gid
+ FROM audit_events
+ ${ew.customSqlSegment}
+ GROUP BY gid
+ ) matched
+ WHERE EXISTS (
+ SELECT 1 FROM audit_events business
+ WHERE COALESCE(business.operation_id, business.client_event_id) = matched.gid
+ AND business.event_category = 'BUSINESS'
+ )
+ </select>
+
+ <select id="selectByOperationGids" resultMap="AuditEventResultMap">
+ SELECT id, client_event_id, operation_id, event_time, tenant_id,
+ operator_id, operator_name, operator_org_id, app_name, biz_module,
+ ip, ip_region, browser, os, request_uri,
+ event_type, event_category, action_code, action_label, source_layer,
+ target_table, target_id, biz_type, biz_code,
+ field_diffs, extra, data_snapshot, reason, prev_hash, created_at,
+ record_title, entry_type, entry_id, entry_name
+ FROM audit_events
+ WHERE COALESCE(operation_id, client_event_id) IN
+ <foreach collection="gids" item="gid" open="(" separator="," close=")">
+ #{gid}
+ </foreach>
+ ORDER BY event_time ASC, id ASC
+ </select>
+
+ <select id="selectTimeline" resultMap="AuditEventResultMap">
+ SELECT id, client_event_id, operation_id, event_time, tenant_id,
+ operator_id, operator_name, operator_org_id, app_name, biz_module,
+ ip, ip_region, browser, os, request_uri,
+ event_type, event_category, action_code, action_label, source_layer,
+ target_table, target_id, biz_type, biz_code,
+ field_diffs, extra, data_snapshot, reason, prev_hash, created_at,
+ record_title, entry_type, entry_id, entry_name
+ FROM audit_events
+ WHERE target_id = #{targetId}
+ ORDER BY id ASC
+ LIMIT #{limit}
+ </select>
+
+</mapper>
--
Gitblit v1.8.0