新增一个简单的好友列表页面

This commit is contained in:
李寻欢
2023-11-30 11:37:02 +08:00
parent 6626f45af2
commit 6a259b0552
17 changed files with 523 additions and 40 deletions

View File

@@ -3,8 +3,37 @@ package service
import (
"go-wechat/client"
"go-wechat/entity"
"go-wechat/vo"
"strings"
)
// GetAllFriend
// @description: 取出所有好友
// @return friends
// @return groups
// @return err
func GetAllFriend() (friends, groups []vo.FriendItem, err error) {
var records []vo.FriendItem
err = client.MySQL.
Table("t_friend AS tf").
Joins("LEFT JOIN t_message AS tm ON tf.wxid = tm.from_user").
Select("tf.*", "MAX(tm.create_at) AS last_active_time").
Group("tf.wxid").
Order("last_active_time DESC").
Find(&records).Error
if err != nil {
return
}
for _, record := range records {
if strings.HasSuffix(record.Wxid, "@chatroom") {
groups = append(groups, record)
} else {
friends = append(friends, record)
}
}
return
}
// GetAllEnableAI
// @description: 取出所有启用了AI的好友或群组
// @return []entity.Friend