Compare commits
No commits in common. "8b7487b42b81e4f1b0c8bf7097e69d44eb4d48d6" and "43ddd232580f420e629c3421c6d7480f80b96f5f" have entirely different histories.
8b7487b42b
...
43ddd23258
@ -4,7 +4,6 @@ import (
|
|||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/logger"
|
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,13 +17,7 @@ func InitMySQLClient() {
|
|||||||
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式
|
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式
|
||||||
DontSupportRenameColumn: true, // 用 `change` 重命名列
|
DontSupportRenameColumn: true, // 用 `change` 重命名列
|
||||||
}
|
}
|
||||||
|
conn, err := gorm.Open(mysql.New(mysqlConfig))
|
||||||
// gorm 配置
|
|
||||||
gormConfig := gorm.Config{
|
|
||||||
Logger: logger.Default.LogMode(logger.Info),
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := gorm.Open(mysql.New(mysqlConfig), &gormConfig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("初始化MySQL连接失败, 错误信息: %v", err)
|
log.Panicf("初始化MySQL连接失败, 错误信息: %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go-wechat/entity"
|
"go-wechat/entity"
|
||||||
"go-wechat/model"
|
"go-wechat/model"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleNewUserJoin
|
// handleNewUserJoin
|
||||||
@ -14,8 +15,12 @@ import (
|
|||||||
func handleNewUserJoin(m model.Message) {
|
func handleNewUserJoin(m model.Message) {
|
||||||
// 判断是否开启迎新
|
// 判断是否开启迎新
|
||||||
var count int64
|
var count int64
|
||||||
client.MySQL.Model(&entity.Friend{}).Where("enable_welcome IS TRUE").Where("wxid = ?", m.FromUser).Count(&count)
|
err := client.MySQL.Model(&entity.Friend{}).
|
||||||
if count < 1 {
|
Where("enable_welcome IS TRUE").
|
||||||
|
Where("wxid = ?", m.FromUser).
|
||||||
|
Count(&count).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("查询是否开启迎新失败: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if count < 1 {
|
if count < 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user