🎨 逻辑优化

This commit is contained in:
李寻欢
2023-12-10 08:14:09 +08:00
parent cab6b2633e
commit 3bc95e1317
2 changed files with 9 additions and 1 deletions

View File

@@ -4,12 +4,18 @@ import (
"go-wechat/client"
"go-wechat/entity"
"log"
"os"
"strconv"
)
// SaveMessage
// @description: 消息入库
// @param msg
func SaveMessage(msg entity.Message) {
if flag, _ := strconv.ParseBool(os.Getenv("DONT_SAVE")); flag {
return
}
// 检查消息是否存在,存在就跳过
var count int64
err := client.MySQL.Model(&entity.Message{}).Where("msg_id = ?", msg.MsgId).Count(&count).Error