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.
84 lines
2.7 KiB
84 lines
2.7 KiB
2 years ago
|
package relation
|
||
4 years ago
|
|
||
2 years ago
|
//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) {
|
||
2 years ago
|
// DB := FriendDB.Table("friends").
|
||
2 years ago
|
// 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 != "" {
|
||
2 years ago
|
// DB = DB.Where("users.name like ?", fmt.Sprintf("%%%s%%", friendUserName))
|
||
2 years ago
|
// }
|
||
2 years ago
|
// if err = DB.Count(&count).Error; err != nil {
|
||
2 years ago
|
// return
|
||
|
// }
|
||
2 years ago
|
// err = DB.Find(&friendUserList).Error
|
||
2 years ago
|
// 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
|
||
|
//}
|