You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
865 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package handle
import (
"WechatGateWay/global"
"fmt"
"github.com/jinzhu/gorm"
"log"
)
/**
@author: sre
@date: 2022/8/10 0010
@desc: RecordWechatBlockWords
**/
type WechatBlockWords struct {
gorm.Model
Content string
ContentMd5 string `sql:"unique_index:unique_index_md5"`
OpUser string
}
func RecordWechatBlockWords(text, textMd5, opUser string) {
newRecord := WechatBlockWords{
Content: text,
ContentMd5: textMd5,
OpUser: opUser,
}
result := global.DB.Create(&newRecord) // 通过数据的指针来创建
if result.RowsAffected != 1 {
log.Println(fmt.Sprintf("记录失败text: %s textMd5: %s opUser: %s", text, textMd5, opUser))
}
}
func WordsBlocked(textMd5 string) bool {
var Record WechatBlockWords
if global.DB.Where("content_md5 = ?", textMd5).First(&Record).RecordNotFound() {
return false
}
return true
}