You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/common/db/relation/friend_model.go

84 lines
2.7 KiB

package relation
//import (
// "fmt"
// "time"
//)
//
//func InsertToFriend(toInsertFollow *Friend) error {
// toInsertFollow.CreateTime = time.Now()
// err := FriendDB.Table("friends").Create(toInsertFollow).Error
// if err != nil {
// return err
// }
// return nil
//}
//
//func GetFriendRelationshipFromFriend(OwnerUserID, FriendUserID string) (*Friend, error) {
// var friend Friend
// err := FriendDB.Table("friends").Where("owner_user_id=? and friend_user_id=?", OwnerUserID, FriendUserID).Take(&friend).Error
// if err != nil {
// return nil, err
// }
// return &friend, err
//}
//
//func GetFriendListByUserID(OwnerUserID string) ([]Friend, error) {
// var friends []Friend
// var x Friend
// x.OwnerUserID = OwnerUserID
// err := FriendDB.Table("friends").Where("owner_user_id=?", OwnerUserID).Find(&friends).Error
// if err != nil {
// return nil, err
// }
// return friends, nil
//}
//
//func GetFriendIDListByUserID(OwnerUserID string) ([]string, error) {
// var friendIDList []string
// err := FriendDB.Table("friends").Where("owner_user_id=?", OwnerUserID).Pluck("friend_user_id", &friendIDList).Error
// if err != nil {
// return nil, err
// }
// return friendIDList, nil
//}
//
//func UpdateFriendComment(OwnerUserID, FriendUserID, Remark string) error {
// return FriendDB.Exec("update friends set remark=? where owner_user_id=? and friend_user_id=?", Remark, OwnerUserID, FriendUserID).Error
//}
//
//func DeleteSingleFriendInfo(OwnerUserID, FriendUserID string) error {
// return FriendDB.Table("friends").Where("owner_user_id=? and friend_user_id=?", OwnerUserID, FriendUserID).Delete(Friend{}).Error
//}
//
//type FriendUser struct {
// Friend
// Nickname string `gorm:"column:name;size:255"`
//}
//
//func GetUserFriendsCMS(ownerUserID, friendUserName string, pageNumber, showNumber int32) (friendUserList []*FriendUser, count int64, err error) {
// DB := FriendDB.Table("friends").
// Select("friends.*, users.name").
// Where("friends.owner_user_id=?", ownerUserID).Limit(int(showNumber)).
// Joins("left join users on friends.friend_user_id = users.user_id").
// Offset(int(showNumber * (pageNumber - 1)))
// if friendUserName != "" {
// DB = DB.Where("users.name like ?", fmt.Sprintf("%%%s%%", friendUserName))
// }
// if err = DB.Count(&count).Error; err != nil {
// return
// }
// err = DB.Find(&friendUserList).Error
// return
//}
//
//func GetFriendByIDCMS(ownerUserID, friendUserID string) (friendUser *FriendUser, err error) {
// friendUser = &FriendUser{}
// err = FriendDB.Table("friends").
// Select("friends.*, users.name").
// Where("friends.owner_user_id=? and friends.friend_user_id=?", ownerUserID, friendUserID).
// Joins("left join users on friends.friend_user_id = users.user_id").
// Take(friendUser).Error
// return friendUser, err
//}