From cc2f1489f325117cb1ff9ea80f9e88da35f30ce2 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Tue, 7 Nov 2023 16:44:58 +0800
Subject: [PATCH] fix

---
 model/gmodel/fs_feishu_webhook_log_gen.go      | 17 +++++++++--------
 .../feishu-sync/internal/logic/webhooklogic.go | 18 ++++++++++--------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/model/gmodel/fs_feishu_webhook_log_gen.go b/model/gmodel/fs_feishu_webhook_log_gen.go
index 0963f399..d4eb40e2 100644
--- a/model/gmodel/fs_feishu_webhook_log_gen.go
+++ b/model/gmodel/fs_feishu_webhook_log_gen.go
@@ -7,14 +7,15 @@ import (
 
 // fs_feishu_webhook_log 飞书webhook记录表
 type FsFeishuWebhookLog struct {
-	Id         int64      `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
-	AppId      *string    `gorm:"default:'';" json:"app_id"`                       // app_id
-	EventId    *string    `gorm:"index;default:'';" json:"event_id"`               // 事件唯一id
-	EventType  *string    `gorm:"default:'';" json:"event_type"`                   // 事件名
-	HttpHeader *string    `gorm:"default:'';" json:"http_header"`                  // http响应头信息
-	HttpBody   *string    `gorm:"default:'';" json:"http_body"`                    // http body信息
-	MsgCtime   *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"msg_ctime"` //
-	Ctime      *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"`     //
+	Id          int64      `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
+	AppId       *string    `gorm:"default:'';" json:"app_id"`                       // app_id
+	EventId     *string    `gorm:"index;default:'';" json:"event_id"`               // 事件唯一id
+	EventType   *string    `gorm:"default:'';" json:"event_type"`                   // 事件名
+	HttpHeader  *string    `gorm:"default:'';" json:"http_header"`                  // http响应头信息
+	Data        *string    `gorm:"default:'';" json:"data"`                         //
+	DecryptData *string    `gorm:"default:'';" json:"decrypt_data"`                 //
+	MsgCtime    *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"msg_ctime"` //
+	Ctime       *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"`     //
 }
 type FsFeishuWebhookLogModel struct {
 	db   *gorm.DB
diff --git a/server/feishu-sync/internal/logic/webhooklogic.go b/server/feishu-sync/internal/logic/webhooklogic.go
index ca89ba2e..69192da1 100644
--- a/server/feishu-sync/internal/logic/webhooklogic.go
+++ b/server/feishu-sync/internal/logic/webhooklogic.go
@@ -105,7 +105,8 @@ func (l *WebhookLogic) Webhook(w http.ResponseWriter, r *http.Request) {
 	}
 	httpHeaderBytes, _ := json.Marshal(r.Header)
 	httpHeaderStr := string(httpHeaderBytes)
-	httpBodyStr := string(realMsgBytes)
+	//解密后的数据
+	decryptMsgStr := string(realMsgBytes)
 	feiShuMsgCreateTimeInt64, err := strconv.ParseInt(msgHeader.CreateTime, 10, 64)
 	if err != nil {
 		logx.Error("解析消息时间错误:", err)
@@ -115,13 +116,14 @@ func (l *WebhookLogic) Webhook(w http.ResponseWriter, r *http.Request) {
 	now := time.Now().UTC()
 	//把事件加入日志
 	err = l.svcCtx.AllModels.FsFeishuWebhookLog.Create(&gmodel.FsFeishuWebhookLog{
-		AppId:      &msgHeader.AppId,
-		EventId:    &msgHeader.EventId,
-		EventType:  &msgHeader.EventType,
-		HttpHeader: &httpHeaderStr,
-		HttpBody:   &httpBodyStr,
-		MsgCtime:   &feiShuMsgCreateTime,
-		Ctime:      &now,
+		AppId:       &msgHeader.AppId,
+		EventId:     &msgHeader.EventId,
+		EventType:   &msgHeader.EventType,
+		HttpHeader:  &httpHeaderStr,
+		Data:        &encryptMsg.Encrypt,
+		DecryptData: &decryptMsgStr,
+		MsgCtime:    &feiShuMsgCreateTime,
+		Ctime:       &now,
 	})
 	if err != nil {
 		logx.Error("保存webhook消息日志失败:", err)