🎨 优化写法

This commit is contained in:
李寻欢 2023-12-07 23:00:57 +08:00
parent ac9f68c80d
commit 8b7487b42b

View File

@ -6,7 +6,6 @@ import (
"go-wechat/entity" "go-wechat/entity"
"go-wechat/model" "go-wechat/model"
"go-wechat/utils" "go-wechat/utils"
"log"
) )
// handleNewUserJoin // handleNewUserJoin
@ -15,12 +14,8 @@ import (
func handleNewUserJoin(m model.Message) { func handleNewUserJoin(m model.Message) {
// 判断是否开启迎新 // 判断是否开启迎新
var count int64 var count int64
err := client.MySQL.Model(&entity.Friend{}). client.MySQL.Model(&entity.Friend{}).Where("enable_welcome IS TRUE").Where("wxid = ?", m.FromUser).Count(&count)
Where("enable_welcome IS TRUE"). if count < 1 {
Where("wxid = ?", m.FromUser).
Count(&count).Error
if err != nil {
log.Printf("查询是否开启迎新失败: %s", err.Error())
return return
} }
if count < 1 { if count < 1 {