2023-11-30 23:12:38 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go-wechat/client"
|
2024-07-04 14:10:46 +08:00
|
|
|
"go-wechat/model/vo"
|
2023-11-30 23:12:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetGroupUsersByGroupId
|
|
|
|
// @description: 根据群Id取出群成员列表
|
|
|
|
// @param groupId
|
|
|
|
// @return records
|
|
|
|
// @return err
|
|
|
|
func GetGroupUsersByGroupId(groupId string) (records []vo.GroupUserItem, err error) {
|
|
|
|
err = client.MySQL.
|
|
|
|
Table("t_group_user AS tgu").
|
2024-01-25 16:27:12 +08:00
|
|
|
//Joins("LEFT JOIN t_message AS tm ON tm.from_user = tgu.group_id AND tm.group_user = tgu.wxid").
|
|
|
|
//Select("tgu.*", "MAX(tm.create_at) AS last_active").
|
|
|
|
Select("tgu.*").
|
2023-11-30 23:12:38 +08:00
|
|
|
Where("tgu.group_id = ?", groupId).
|
|
|
|
Group("tgu.group_id, tgu.wxid").
|
2023-12-01 10:22:01 +08:00
|
|
|
Order("tgu.join_time DESC").
|
2023-11-30 23:12:38 +08:00
|
|
|
Find(&records).Error
|
|
|
|
return
|
|
|
|
}
|