Documentation ¶
Overview ¶
Package model @Title friend.go @Description @Author peanut996 @Update peanut996 2021/5/22 10:05
Package model @Title group.go @Description @Author peanut996 @Update peanut996 2021/5/22 17:23
Package model @Title groupuser.go @Description @Author peanut996 @Update peanut996 2021/5/22 17:40
Package model @Title model.go @Description @Author peanut996 @Update peanut996 2021/5/24 9:45
Index ¶
- Constants
- func AddNewFriend(friendA, friendB string) error
- func CreateGroupUser(groupID, user string) error
- func GetAssociatedUIDsByUID(uid string) ([]string, error)
- func GetFriendUIDsByUID(user string) ([]string, error)
- func GetFriendsByRoomID(roomID string) ([]string, error)
- func GetGroupIDsByUID(uid string) ([]string, error)
- func GetRoomIDsByUID(uid string) ([]string, error)
- func GetUIDFromAccount(account string) (string, error)
- func GetUserIDsByGroup(group *Group) ([]string, error)
- func GetUserIDsByGroupID(groupID string) ([]string, error)
- func GetUserIDsByGroups(groups ...*Group) ([]string, error)
- func InsertChatMessage(c *ChatMessage) error
- func InsertUser(user *User) error
- func UpdateUser(user *User) error
- type ChatMessage
- func ChatMessageFrom(from, to, content, Type string, height, width float64, size int, ...) *ChatMessage
- func GetFriendMessageWithPage(friend *Friend, current, pageSize int64) ([]*ChatMessage, error)
- func GetGroupMessageWithPage(group *Group, current, pageSize int64) ([]*ChatMessage, error)
- func NewChatMessage() *ChatMessage
- type Friend
- type FriendData
- type FriendWithRoomID
- type Group
- type GroupData
- type GroupUser
- type Room
- type User
- func FindUsersByAccount(account string) ([]*User, error)
- func GetUserByAccount(account string) (*User, error)
- func GetUserByUID(uid string) (*User, error)
- func GetUsersByGroup(group *Group) ([]*User, error)
- func GetUsersByGroups(groups ...*Group) ([]*User, error)
- func GetUsersFromUIDs(uids ...string) ([]*User, error)
- func NewUser(account string, password string) *User
Constants ¶
View Source
const ( MongoCollectionChatMessage = "ChatMessage" MongoCollectionFriend = "Friend" MongoCollectionUser = "User" MongoCollectionGroup = "Group" MongoCollectionGroupUser = "GroupUser" MongoCollectionRoom = "Room" DefaultFriendPageSize = 20 )
Variables ¶
This section is empty.
Functions ¶
func AddNewFriend ¶
AddNewFriend Add friends by UID
func CreateGroupUser ¶
func GetAssociatedUIDsByUID ¶
func GetFriendUIDsByUID ¶
func GetFriendsByRoomID ¶
func GetGroupIDsByUID ¶
func GetRoomIDsByUID ¶
GetRoomIDsByUID Get User-related rooms
func GetUIDFromAccount ¶
func GetUserIDsByGroup ¶
func GetUserIDsByGroupID ¶
func GetUserIDsByGroups ¶
func InsertChatMessage ¶
func InsertChatMessage(c *ChatMessage) error
func InsertUser ¶
func UpdateUser ¶
Types ¶
type ChatMessage ¶
type ChatMessage struct { From string `json:"from" bson:"from"` To string `json:"to,omitempty" bson:"to"` Content string `json:"content" bson:"content"` Time string `json:"time,omitempty" bson:"time"` Type string `json:"type" bson:"type"` FileName string `json:"fileName" bson:"fileName"` Size int `json:"size" bson:"size"` Height float64 `json:"height" bson:"height"` Width float64 `json:"width" bson:"width"` }
func ChatMessageFrom ¶
func ChatMessageFrom(from, to, content, Type string, height, width float64, size int, fileName string) *ChatMessage
func GetFriendMessageWithPage ¶
func GetFriendMessageWithPage(friend *Friend, current, pageSize int64) ([]*ChatMessage, error)
GetFriendMessageWithPage pull message with page. !!! Param Friend must have a roomID
func GetGroupMessageWithPage ¶
func GetGroupMessageWithPage(group *Group, current, pageSize int64) ([]*ChatMessage, error)
func NewChatMessage ¶
func NewChatMessage() *ChatMessage
type Friend ¶
type Friend struct { FriendA string `json:"friendA" bson:"userA"` FriendB string `json:"friendB" bson:"userB"` RoomID string `json:"roomID" bson:"roomID"` CreateTime string `json:"-" bson:"createTime"` }
func DeleteFriend ¶
func GetFriendsByUID ¶
type FriendData ¶
type FriendData struct { User `json:",inline"` RoomID string `json:"roomID"` Messages []*ChatMessage `json:"messages"` }
func GetFriendDataByFriend ¶
func GetFriendDataByFriend(friend *Friend) (*FriendData, error)
func GetFriendDataByIDs ¶
func GetFriendDataByIDs(friendA, friendB string) (*FriendData, error)
func GetFriendDatasByUID ¶
func GetFriendDatasByUID(uid string) ([]*FriendData, error)
type FriendWithRoomID ¶
func GetFriendWithRoomIDsByUID ¶
func GetFriendWithRoomIDsByUID(uid string) ([]*FriendWithRoomID, error)
func NewFriendWithRoomID ¶
func NewFriendWithRoomID(user *User, roomID string) *FriendWithRoomID
type Group ¶
type Group struct { RoomID string `json:"roomID" bson:"roomID"` GroupID string `json:"groupID" bson:"groupID"` GroupName string `json:"groupName" bson:"groupName"` GroupAdmin string `json:"groupAdmin" bson:"groupAdmin"` CreateTime string `json:"-" bson:"createTime"` }
func CreateGroup ¶
func FindGroupsByGroupName ¶
func GetGroupByGroupID ¶
func GetGroupsByUID ¶
type GroupData ¶
type GroupData struct { Group `json:",inline"` Members []*User `json:"members"` Messages []*ChatMessage `json:"messages"` }
func GetGroupDataByGroupID ¶
func GetGroupDatasByUID ¶
type GroupUser ¶
type GroupUser struct { GroupID string `json:"groupID" bson:"groupID"` UID string `json:"uid" bson:"uid"` CreateTime string `json:"-" bson:"createTime"` }
func DeleteGroupUser ¶
func NewGroupUser ¶
func NewGroupUser() *GroupUser
type Room ¶
type Room struct { RoomID string `json:"roomID" bson:"roomID"` OneToOne bool `json:"oneToOne" bson:"oneToOne"` Status string `json:"status" bson:"status"` CreateTime string `json:"createTime,omitempty" bson:"createTime"` }
func GetRoomByID ¶
func GetRoomsByUID ¶
func NewFriendRoom ¶
func NewFriendRoom() *Room
func NewGroupRoom ¶
func NewGroupRoom() *Room
type User ¶
type User struct { UID string `json:"uid,omitempty" bson:"uid"` Account string `json:"account" bson:"account"` Password string `json:"-" bson:"password"` Avatar string `json:"avatar,omitempty" bson:"avatar"` CreateTime string `json:"-" bson:"createTime"` }
User means a people who use the system.
func FindUsersByAccount ¶
func GetUserByAccount ¶
func GetUserByUID ¶
func GetUsersByGroup ¶
func GetUsersByGroups ¶
func GetUsersFromUIDs ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.