✨ 新增退群时间
This commit is contained in:
parent
e6198a88c1
commit
af4b4d1b4f
@ -1,5 +1,7 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
// Friend
|
||||
// @description: 好友列表
|
||||
type Friend struct {
|
||||
@ -23,6 +25,7 @@ type GroupUser struct {
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Wxid string `json:"wxid"` // 微信Id
|
||||
IsMember bool `json:"isMember" gorm:"type:tinyint(1)"` // 是否群成员
|
||||
LeaveTime time.Time `json:"leaveTime"` // 离开时间
|
||||
}
|
||||
|
||||
func (GroupUser) TableName() string {
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"log"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 同步群成员
|
||||
@ -115,7 +116,11 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
|
||||
log.Printf(" 群成员数: %d", len(wxIds))
|
||||
|
||||
// 修改不在数组的群成员状态为不在
|
||||
err = tx.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Where("wxid NOT IN (?)", wxIds).Update("is_member", false).Error
|
||||
pm := map[string]any{
|
||||
"is_member": false,
|
||||
"leave_time": time.Now().Local(),
|
||||
}
|
||||
err = tx.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Where("wxid NOT IN (?)", wxIds).Updates(pm).Error
|
||||
if err != nil {
|
||||
log.Printf("修改群成员状态失败: %s", err.Error())
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user