🎨 优化日志打印
BuildImage / build-image (push) Successful in 1m14s Details

This commit is contained in:
李寻欢 2023-12-08 11:41:59 +08:00
parent e9212f68cc
commit 58cb76ed75
2 changed files with 10 additions and 6 deletions

View File

@ -6,9 +6,11 @@ import (
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"strconv"
)
// MySQL客户端
// MySQL MySQL客户端
var MySQL *gorm.DB
func InitMySQLClient() {
@ -20,8 +22,10 @@ func InitMySQLClient() {
}
// gorm 配置
gormConfig := gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
gormConfig := gorm.Config{}
// 是否开启调试模式
if flag, _ := strconv.ParseBool(os.Getenv("GORM_DEBUG")); flag {
gormConfig.Logger = logger.Default.LogMode(logger.Info)
}
conn, err := gorm.Open(mysql.New(mysqlConfig), &gormConfig)

View File

@ -48,7 +48,7 @@ func Sync() {
if slices.Contains(constant.SpecialId, friend.Wxid) {
continue
}
log.Printf("昵称: %s -> 类型: %d -> 微信号: %s -> 微信原始Id: %s", friend.Nickname, friend.Type, friend.CustomAccount, friend.Wxid)
//log.Printf("昵称: %s -> 类型: %d -> 微信号: %s -> 微信原始Id: %s", friend.Nickname, friend.Type, friend.CustomAccount, friend.Wxid)
nowIds = append(nowIds, friend.Wxid)
// 判断是否存在,不存在的话就新增,存在就修改一下名字
@ -121,7 +121,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
// 昵称Id
wxIds := strings.Split(baseResp.Data.Members, "^G")
log.Printf(" 群成员数: %d", len(wxIds))
//log.Printf(" 群成员数: %d", len(wxIds))
// 修改不在数组的群成员状态为不在
pm := map[string]any{
@ -138,7 +138,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
// 获取成员信息
cp, _ := getContactProfile(wxid)
if cp.Wxid != "" {
log.Printf(" 微信Id: %s -> 昵称: %s -> 微信号: %s", wxid, cp.Nickname, cp.Account)
//log.Printf(" 微信Id: %s -> 昵称: %s -> 微信号: %s", wxid, cp.Nickname, cp.Account)
// 查询成员是否存在,不在就新增,否则修改
var count int64
err = tx.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Where("wxid = ?", wxid).Count(&count).Error