fix: use unprefixed kafka audit tables

This commit is contained in:
richjohnrambo
2026-08-28 16:16:25 +08:00
parent ed4f186d8e
commit eff2f54641
3 changed files with 110 additions and 76 deletions
+7 -16
View File
@@ -32,22 +32,13 @@ func (q *qImDeadLetter) Handle(ctx context.Context, mqMsg queue.MqMsg) (err erro
if len(envelope.Payload) > 0 {
_ = json.Unmarshal(envelope.Payload, &payload)
}
_, err = g.DB().Model("im_kafka_dead_letter_events").Safe().Ctx(ctx).Data(g.Map{
"event_id": envelope.EventID,
"parent_event_id": envelope.ParentEventID,
"tenant_code": envelope.TenantCode,
"event_type": envelope.EventType,
"biz_type": envelope.BizType,
"biz_id": envelope.BizID,
"source_service": envelope.SourceService,
"target_service": envelope.TargetService,
"dead_id": stringValue(payload["dead_id"]),
"reason": firstString(payload["reason"], payload["last_reason"]),
"message": firstString(payload["message"], payload["last_error"]),
"payload": string(envelope.Payload),
"envelope": string(mqMsg.Body),
"received_at": gtime.Now(),
}).InsertIgnore()
_, err = g.DB().Exec(ctx, `INSERT IGNORE INTO im_kafka_dead_letter_events
(event_id,parent_event_id,tenant_code,event_type,biz_type,biz_id,source_service,target_service,dead_id,reason,message,payload,envelope,received_at)
VALUES(?,?,?,?,?,?,?,?,?,?,?,CAST(NULLIF(?, '') AS JSON),CAST(? AS JSON),?)`,
envelope.EventID, envelope.ParentEventID, envelope.TenantCode, envelope.EventType, envelope.BizType, envelope.BizID,
envelope.SourceService, envelope.TargetService, stringValue(payload["dead_id"]),
firstString(payload["reason"], payload["last_reason"]), firstString(payload["message"], payload["last_error"]),
string(envelope.Payload), string(mqMsg.Body), gtime.Now())
return err
}