Documentation
¶
Index ¶
- Constants
- Variables
- func AddChatMessage(msg *ChatMessage) error
- func AddChatMessageTx(msg *ChatMessage) error
- func AddGroup(group *Group, opts ...*SetOptions) (int64, error)
- func AddGroupMembers(groupID int64, data *AddGroupMembersData, opts ...*SetOptions) (int64, error)
- func AddUser(user *User, opts ...*SetOptions) error
- func AddUserRelation(relation *UserRelation, opts ...*SetOptions) (id int64, err error)
- func AddUserRelationInvite(invite *UserRelationInvite, opts ...*SetOptions) error
- func CreateUserRelationTx(relation *UserRelation) (id int64, err error)
- func GetGroupMemberCount(groupID int64, opts ...*GetOptions) (int64, error)
- func GetGroupMemberIDs(groupID int64, opts ...*GetOptions) ([]int64, error)
- func GetGroupMemberIDsString(groupID int64, opts ...*GetOptions) ([]string, error)
- func RemoveGroupMembers(filter *RemoveGroupMembersFilter, opts ...*SetOptions) (int64, error)
- func RollbackChatMessage(roomID string, sessionType int, senderID, msgID int64) (bool, error)
- func UpdateGroup(groupID int64, data *UpdateGroupData, opts ...*SetOptions) error
- func UpdateGroupMember(groupID, userID int64, data *UpdateGroupMemberData, opts ...*SetOptions) error
- func UpdateGroupTx(groupID int64, data *UpdateGroupData) (err error)
- func UpdateUserRelation(filter *UpdateUserRelationFilter, data *UpdateUserRelationData, ...) (int64, error)
- func UpdateUserRelationInvite(filter *UpdateUserRelationInviteFilter, data *UpdateUserRelationInviteData, ...) (int64, error)
- func UpdateUserRelationTx(filter *UpdateUserRelationFilter, data *UpdateUserRelationData) (rowsAffected int64, err error)
- func UserExist(id int64) (bool, error)
- func UserExistByUsername(username string) (bool, error)
- type AddGroupMembersData
- type ChatMessage
- type ChatMessageBody
- type ChatRoom
- type Database
- type GetChatMessageListFilter
- type GetChatMessageListOptions
- type GetOptions
- type Group
- type GroupMember
- type RemoveGroupMembersFilter
- type SQLOptions
- type SearchUsersFilter
- type SetOptions
- type UpdateGroupData
- type UpdateGroupMemberData
- type UpdateUserRelationData
- type UpdateUserRelationFilter
- type UpdateUserRelationInviteData
- type UpdateUserRelationInviteFilter
- type User
- type UserRelation
- type UserRelationInvite
Constants ¶
const ( // ChatMessageSessionTypePrivate 私聊会话类型 ChatMessageSessionTypePrivate = 1 // ChatMessageSessionTypeGroup 群聊会话类型 ChatMessageSessionTypeGroup = 2 // ChatMessageSessionTypeWorld 世界会话类型 ChatMessageSessionTypeWorld = 99 )
const ( // ChatMessageTypePlainText 文本类型 ChatMessageTypePlainText = 1 // ChatMessageTypePicture 图像类型 ChatMessageTypePicture = 2 // ChatMessageTypeVoice 语音类型 ChatMessageTypeVoice = 3 // ChatMessageTypeVideo 视频类型 ChatMessageTypeVideo = 4 // ChatMessageTypeLocation 位置类型 ChatMessageTypeLocation = 5 )
const ( // ChatMessageBodyFormatGIF GIF类型 ChatMessageBodyFormatGIF = "gif" // ChatMessageBodyFormatJPEG JPEG类型 ChatMessageBodyFormatJPEG = "jpeg" // ChatMessageBodyFormatWEBP GIF类型 ChatMessageBodyFormatWEBP = "webp" // ChatMessageBodyFormatMP3 mp3类型 ChatMessageBodyFormatMP3 = "mp3" // ChatMessageBodyFormatVMA vma类型 ChatMessageBodyFormatVMA = "vma" // ChatMessageBodyFormatMP4 mp4类型 ChatMessageBodyFormatMP4 = "mp4" )
const ( // UserRelationInviteStatusPending 等待确认用户关系邀请 UserRelationInviteStatusPending = iota // UserRelationInviteStatusAgree 接收用户关系邀请 UserRelationInviteStatusAgree // UserRelationInviteStatusReject 拒绝用户关系邀请 UserRelationInviteStatusReject )
const (
GroupMaxMember = 10
)
Variables ¶
var ( // MYSQL 库跟表 DatabaseMySQLIM = "`jim`" // TableGroups 群组数据表 TableGroups = DatabaseMySQLIM + ".`groups`" // TableGroupMembers 群组成员表 TableGroupMembers = DatabaseMySQLIM + ".`group_member`" // TableUsers 用户数据表 TableUsers = DatabaseMySQLIM + ".`users`" // TableUserRelation 用户关系表 TableUserRelation = DatabaseMySQLIM + ".`user_relation`" // TableUserRelationInvite 用户关系邀请表 TableUserRelationInvite = DatabaseMySQLIM + ".`user_relation_invite`" // MongoDB 库跟集合 DatabaseMongodbIM = "jim" CollectionRoom = "room" CollectionMessage = "message" )
var ( CacheKeyPrefix = config.GlobConfig().Main.ServerName GlobCtx = context.Background() GlobDB *Database GlobCache *jcache.Client )
Functions ¶
func AddGroupMembers ¶
func AddGroupMembers(groupID int64, data *AddGroupMembersData, opts ...*SetOptions) (int64, error)
AddGroupMembers 增加群成员
func AddUserRelation ¶
func AddUserRelation(relation *UserRelation, opts ...*SetOptions) (id int64, err error)
AddUserRelation 添加一条用户关系
func AddUserRelationInvite ¶
func AddUserRelationInvite(invite *UserRelationInvite, opts ...*SetOptions) error
AddUserRelationInvite 添加一条用户关系建立的请求记录
func CreateUserRelationTx ¶
func CreateUserRelationTx(relation *UserRelation) (id int64, err error)
CreateUserRelationTx 事务方式创建用户关系 1. 更新用户好友邀请表 2. 添加用户关系表
func GetGroupMemberCount ¶
func GetGroupMemberCount(groupID int64, opts ...*GetOptions) (int64, error)
GetGroupMemberCount 获取群成员数量
func GetGroupMemberIDs ¶
func GetGroupMemberIDs(groupID int64, opts ...*GetOptions) ([]int64, error)
GetGroupMemberIDs 获取群成员ID数组
func GetGroupMemberIDsString ¶
func GetGroupMemberIDsString(groupID int64, opts ...*GetOptions) ([]string, error)
GetGroupMemberIDsString 获取
func RemoveGroupMembers ¶
func RemoveGroupMembers(filter *RemoveGroupMembersFilter, opts ...*SetOptions) (int64, error)
RemoveGroupMembers 移除群成员,不区分管理员
func RollbackChatMessage ¶
RollbackChatMessage 撤回一条消息
func UpdateGroup ¶
func UpdateGroup(groupID int64, data *UpdateGroupData, opts ...*SetOptions) error
UpdateGroup 更新群信息
func UpdateGroupMember ¶
func UpdateGroupMember(groupID, userID int64, data *UpdateGroupMemberData, opts ...*SetOptions) error
UpdateGroupMember 更新群组成员信息
func UpdateGroupTx ¶
func UpdateGroupTx(groupID int64, data *UpdateGroupData) (err error)
UpdateGroupTx 使用事务方式更新群信息
func UpdateUserRelation ¶
func UpdateUserRelation(filter *UpdateUserRelationFilter, data *UpdateUserRelationData, opts ...*SetOptions) (int64, error)
UpdateUserRelation 更新用户关系资料
func UpdateUserRelationInvite ¶
func UpdateUserRelationInvite(filter *UpdateUserRelationInviteFilter, data *UpdateUserRelationInviteData, opts ...*SetOptions) (int64, error)
UpdateUserRelationInvite 更新用户关系邀请
func UpdateUserRelationTx ¶
func UpdateUserRelationTx(filter *UpdateUserRelationFilter, data *UpdateUserRelationData) (rowsAffected int64, err error)
UpdateUserRelationTx 事务模式更新用户关系资料 1. 更新用户关系表 2. 更新用户好友邀请表
func UserExistByUsername ¶
UserExistByUsername 根据用户名判断用户是否存在
Types ¶
type AddGroupMembersData ¶
type ChatMessage ¶
type ChatMessage struct {
// ID
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
// 消息ID
MessageID int64 `bson:"message_id" json:"message_id"`
// 房间号ID
RoomID string `bson:"room_id" json:"room_id"`
// 消息类型: 1-纯文本,2-图片,3-语音,4-视频, 5-位置
Type int `bson:"type" json:"type"`
// 会话类型, 1-私聊,2-群聊
SessionType int `bson:"session_type" json:"session_type"`
// 发送人ID
SenderID int64 `bson:"sender_id" json:"sender_id"`
// 接收人ID
ReceiverID int64 `bson:"receiver_id" json:"receiver_id"`
// 消息发送状态,1-已发送,2-未抵达,3-已抵达
SendStatus int `bson:"send_status" json:"send_status"`
// 已读状态, 0-未读,1-已读
ReadStatus int `bson:"read_status" json:"read_status"`
// 消息状态, 1-正常,2-已删除,3-已撤回
Status int `bson:"status" json:"status"`
// 消息主体
Body ChatMessageBody `bson:"body" json:"body"`
// 消息发送时间, 要用时间戳?
CreatedAt int64 `bson:"created_at" json:"created_at"` // 消息时间
// 消息最后更新时间,要用时间戳?
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
{
"msg_id":1, // 递增
"type":1, // 消息类型: 1-纯文本,2-图片,3-语音,4-视频, 5-位置
"session_type":1, // 会话类型, 1-私聊,2-群聊
"room_id":"12345", // 房间号
"sender_id":1, // 发送人ID
"receiver_id":1, // 接收人ID, // 当,sessin_type=1时为私聊对象ID,当session_type=2时为群聊房间ID
"send_status":1, // 消息发送状态,1-已发送,2-未抵达,3-已抵达
"read_status":1, // 已读状态, 0-未读,1-已读
"status":1, // 消息状态, 1-正常,2-已删除,3-已撤回
"body":"{ // 消息主体
// 文本信息。适用消息类型: 1
\"text\": \"纯文本消息\",
// 来源地址。通用字段,适用消息类型: 2,3,4
\"src\": \"图片、语音、视频等地址\",
// 文件格式。适用消息类型: 2,3,4
\"format\": \"avi\",
// 文件大小。适用消息类型: 2,3,4
\"size\": \"123GB\",
// 位置信息。适用消息类型: 5
\"longitude\":\"100644.12323\",
// 位置信息-纬度。 适用消息类型: 5
\"latitude\":\"100644.12323\",
// 位置信息-地图缩放级别。 适用消息类型: 5
"\scale\": 123.3,
// 位置信息。适用消息类型: 5
\"location_label\": \"福建省厦门市某个地址\"
}",
"time":1, // 消息发送时间, 时间戳?
}
ChatMessage 聊天消息体
func GetChatMessageList ¶
func GetChatMessageList(filter *GetChatMessageListFilter) ([]*ChatMessage, error)
GetChatMessageList 获取消息列表
func GetLastChatMessageList ¶
func GetLastChatMessageList(roomID string, sessionType int, opts ...*GetOptions) ([]*ChatMessage, error)
GetLastChatMessageList 获取最近的聊天消息列表
func (*ChatMessage) MarshalBinary ¶
func (m *ChatMessage) MarshalBinary() ([]byte, error)
MarshalBinary 实现encoding.BinaryMarshaler接口
func (*ChatMessage) UnmarshalBinary ¶
func (m *ChatMessage) UnmarshalBinary(data []byte) error
UnmarshalBinary 实现encoding.BinaryUnmarshaler接口
type ChatMessageBody ¶
type ChatMessageBody struct {
// 文本信息。适用消息类型: 1
Text string `bson:"text,omitempty" json:"text,omitempty"`
// 来源地址。通用字段,适用消息类型: 2,3,4
Src string `bson:"src,omitempty" json:"src,omitempty"`
// 文件格式。适用消息类型: 2,3,4
Format string `bson:"format,omitempty" json:"format,omitempty"`
// 文件大小。适用消息类型: 2,3,4
Size string `bson:"size,omitempty" json:"size,omitempty"`
// 位置信息-经度。 适用消息类型: 5
Longitude string `bson:"longitude,omitempty" json:"longitude,omitempty"`
// 位置信息-纬度。 适用消息类型: 5
Latitude string `bson:"latitude,omitempty" json:"latitude,omitempty"`
// 位置信息-地图缩放级别。 适用消息类型: 5
Scale float64 `bson:"scale,omitempty" json:"scale,omitempty"`
// 位置信息标签。适用消息类型: 5
LocationLabel string `bson:"location_label,omitempty" json:"location_label,omitempty"`
}
ChatMessageBody 消息主体
type ChatRoom ¶
type ChatRoom struct {
// ID 房间号
ID primitive.ObjectID `bson:"id" json:"id"`
// RoomID 房间ID
RoomID string `bson:"room_id" json:"room_id"`
// SessionType 房间类型, 1-私聊,2-群聊
SessionType int `bson:"session_type" json:"session_type"`
// LastMessageID 最后一条消息ID,用于前端进行过滤排序
LastMessageID int64 `bson:"last_message_id" json:"last_message_id"`
// LastMessage 最后一条消息
LastMessage ChatMessage `bson:"last_message" json:"last_message"`
// CreatedAt 创建时间
CreatedAt int64 `bson:"created_at" json:"created_at"`
// UpdatedAt 最后更新时间
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
ChatRoom 聊天室房间数据
type GetChatMessageListFilter ¶ added in v1.0.3
type GetChatMessageListFilter struct {
RoomID string `bson:"room_id"`
SessionType int `bson:"session_type"`
Sort any `bson:"sort"`
LastMessageID *int64 `bson:"last_message_id"`
Limit *int `bson:"limit"`
}
func (*GetChatMessageListFilter) SetLastMessageID ¶ added in v1.0.5
func (f *GetChatMessageListFilter) SetLastMessageID(val int64) *GetChatMessageListFilter
func (*GetChatMessageListFilter) SetLimit ¶ added in v1.0.5
func (f *GetChatMessageListFilter) SetLimit(val int) *GetChatMessageListFilter
func (*GetChatMessageListFilter) SetSort ¶ added in v1.0.5
func (f *GetChatMessageListFilter) SetSort(val any) *GetChatMessageListFilter
type GetChatMessageListOptions ¶
type GetChatMessageListOptions struct {
GetOptions
Sort any
LastMessageID int64
Limit int64
}
func NewChatMessageListOptions ¶
func NewChatMessageListOptions() *GetChatMessageListOptions
func (*GetChatMessageListOptions) SetLastMessageID ¶
func (opt *GetChatMessageListOptions) SetLastMessageID(val int64) *GetChatMessageListOptions
func (*GetChatMessageListOptions) SetLimit ¶
func (opt *GetChatMessageListOptions) SetLimit(val int64) *GetChatMessageListOptions
func (*GetChatMessageListOptions) SetSort ¶
func (opt *GetChatMessageListOptions) SetSort(val any) *GetChatMessageListOptions
type GetOptions ¶
type GetOptions struct {
SQLOptions
// contains filtered or unexported fields
}
GetOptions 获取数据的配置
func NewGetOptionsFromSetOptions ¶
func NewGetOptionsFromSetOptions(setOpt *SetOptions) *GetOptions
NewGetOptionsFromSetOptions 从新生成一个获取信息的配置
func (*GetOptions) SetSQLExt ¶
func (opt *GetOptions) SetSQLExt(ext sqlx.Ext) *GetOptions
SetSQLExt 设置是否使用其他sql执行器
func (*GetOptions) SetUpdateCache ¶
func (opt *GetOptions) SetUpdateCache(val bool) *GetOptions
SetUpdateCache 设置获取数据时同时更新缓存
func (*GetOptions) SetUseCache ¶
func (opt *GetOptions) SetUseCache(val bool) *GetOptions
SetUseCache 设置是否优先使用缓存
type Group ¶
type Group struct {
ID int64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
MaxMember int `db:"max_member" json:"max_member"`
OwnerID int64 `db:"owner_id" json:"owner_id"`
SpeakStatus int `db:"speak_status" json:"speak_status"`
CreatorID int64 `db:"creator_id" json:"creator_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdaterID int64 `db:"updater_id" json:"updater_id"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
Group 群组信息
func CreateGroupTx ¶
CreateGroupTx 事务方式创建群组
type GroupMember ¶
type GroupMember struct {
ID int64 `db:"id" json:"id"`
GroupID int64 `db:"group_id" json:"group_id"`
UserID int64 `db:"user_id" json:"user_id"`
Role int `db:"role" json:"role"`
SpeakStatus int `db:"speak_status" json:"speak_status"`
UpdaterID int64 `db:"updater_id" json:"updater_id"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
CreatorID int64 `db:"creator_id" json:"creator_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
}
GroupMember 群成员信息
func GetGroupAllMembers ¶
func GetGroupAllMembers(groupID int64, opts ...*GetOptions) ([]*GroupMember, error)
GetGroupAllMembers 获取群成员资料
func GetGroupMember ¶
func GetGroupMember(groupID, memberID int64, opts ...*GetOptions) (*GroupMember, error)
GetGroupMember 获取某个群成员资料
func GetGroupMembers ¶
func GetGroupMembers(groupID int64, memberIDs []int64, opts ...*GetOptions) ([]*GroupMember, error)
GetGroupMembers 获取多个群成员资料
type SQLOptions ¶
type SQLOptions struct {
// contains filtered or unexported fields
}
func (*SQLOptions) SetSQLExt ¶
func (opt *SQLOptions) SetSQLExt(ext sqlx.Ext) *SQLOptions
SetSQLExt 设置sql执行器
type SearchUsersFilter ¶
type SearchUsersFilter struct {
// UserID 用户ID
UserID *int64 `json:"user_id,omitempty" db:"user_id"`
// Nickname 昵称
Nickname *string `json:"nickname,omitempty" db:"nickname"`
// StartID 开始ID
StartID int64 `json:"start_id" db:"start_id"`
// Limit 限制集合大小
Limit int64 `json:"limit" db:"limit"`
}
SearchUsersFilter 获取用户过滤条件
type SetOptions ¶
type SetOptions struct {
SQLOptions
// contains filtered or unexported fields
}
SetOptions 获取数据的配置
func NewSetOptionsFromGetOptions ¶
func NewSetOptionsFromGetOptions(getOpt *GetOptions) *SetOptions
NewSetOptionsFromGetOptions 从新生成一个获取信息的配置
func NewSetOptionsWithSQLExt ¶
func NewSetOptionsWithSQLExt(ext sqlx.Ext) *SetOptions
NewSetOptionsWithSQLExt 新生成一个设置获取信息的配置
func (*SetOptions) SetSQLExt ¶
func (opt *SetOptions) SetSQLExt(ext sqlx.Ext) *SetOptions
SetSQLExt 设置是否使用其他sql执行器
func (*SetOptions) SetUpdateCache ¶
func (opt *SetOptions) SetUpdateCache(val bool) *SetOptions
SetUpdateCache 设置是否更新缓存
type UpdateGroupData ¶
type UpdateGroupData struct {
Name *string `db:"name" json:"name"`
MaxMember *int `db:"max_member" json:"max_member"`
OwnerID *int64 `db:"owner_id" json:"owner_id"`
SpeakStatus *int `db:"speak_status" json:"speak_status"`
UpdaterID int64 `db:"updater_id" json:"updater_id"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
type UpdateGroupMemberData ¶
type UpdateGroupMemberData struct {
// Role 成员角色; 0:普通成员,1:拥有者,2:管理员
Role *int `db:"role" json:"role"`
// SpeakStatus 发言状态; 1:可发言, 0:禁止发言
SpeakStatus *int `db:"speak_status" json:"speak_status"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
UpdaterID int64 `db:"updater_id" json:"updater_id"`
}
UpdateGroupMemberData 更新群组成员数据
type UpdateUserRelationData ¶
type UpdateUserRelationData struct {
// RemarkOnA B给A的备注
RemarkOnA *string `db:"remark_on_a" json:"remark_on_a"`
// RemarkOnB A给B的备注
RemarkOnB *string `db:"remark_on_b" json:"remark_on_b"`
// Status 好友状态
Status *int `db:"status" json:"status"`
// BlockStatus 拉黑状态
BlockStatus *int `db:"block_status" json:"block_status"`
// UpdatedAt 更新时间
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
UpdateUserRelationData 更新用户关系配置
func (*UpdateUserRelationData) SetBlockStatus ¶
func (opt *UpdateUserRelationData) SetBlockStatus(val int) *UpdateUserRelationData
SetBlockStatus 设置拉黑状态
func (*UpdateUserRelationData) SetStatus ¶
func (opt *UpdateUserRelationData) SetStatus(val int) *UpdateUserRelationData
SetStatus 设置好友状态
func (*UpdateUserRelationData) SetUpdatedAt ¶
func (opt *UpdateUserRelationData) SetUpdatedAt(val time.Time) *UpdateUserRelationData
SetUpdatedAt 设置更新时间
type UpdateUserRelationFilter ¶
type UpdateUserRelationFilter struct {
ID int64 `db:"id" json:"id"`
// UserAID 用户A ID
UserAID int64 `db:"user_a_id" json:"user_a_id"`
// UserBID 用户B ID
UserBID int64 `db:"user_b_id" json:"user_b_id"`
}
UpdateUserRelationFilter 更新用户关系过滤器
type UpdateUserRelationInviteData ¶
type UpdateUserRelationInviteData struct {
// Status 邀请状态,更新是只能大于0. (设置结果)
Status int `db:"status"`
// Reply 状态回复. (设置结果)
Reply string `db:"reply"`
// UpdatedAt 更新时间,如果未设置,将自动生成当前时间. (设置结果)
UpdatedAt time.Time `db:"updated_at"`
}
UpdateUserRelationInviteData 更新用户关系邀请数据
type UpdateUserRelationInviteFilter ¶
type UpdateUserRelationInviteFilter struct {
// ID 邀请记录ID. (查询条件)
ID int64 `db:"id"`
// UserID 用户ID
UserID int64 `db:"user_id"`
// TargetID 目标ID
TargetID int64 `db:"target_id"`
}
UpdateUserRelationInviteFilter 更新用户关系邀请过滤器
type User ¶
type User struct {
ID int64 `db:"id" json:"id"`
Username string `db:"username" json:"username"`
Password string `db:"password_hash" json:"password_hash"`
Nickname string `db:"nickname" json:"nickname"`
Avatar string `db:"avatar" json:"avatar"`
BirthDate *time.Time `db:"birth_date" json:"birth_date"`
OnlineStatus int `db:"online_status" json:"online_status"`
Status int `db:"status" json:"status"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
func GetUserByUsername ¶
func GetUserByUsername(username string, opts ...*GetOptions) (*User, error)
GetUserByUsername 根据用户名获取用户信息
func SearchUsers ¶
func SearchUsers(filter *SearchUsersFilter, opts ...*GetOptions) ([]*User, error)
SearchUsers 获取用户列表
func (*User) MarshalBinary ¶
func (*User) UnmarshalBinary ¶
type UserRelation ¶
type UserRelation struct {
ID int64 `db:"id" json:"id"`
// UserAID 用户A ID
UserAID int64 `db:"user_a_id" json:"user_a_id"`
// UserBID 用户B ID
UserBID int64 `db:"user_b_id" json:"user_b_id"`
// Status 好友状态
Status int `db:"status" json:"status"`
// BlockStatus 拉黑状态
BlockStatus int `db:"block_status" json:"block_status"`
// RemarkOnA B对A的备注,也就是B显示A的备注名称
RemarkOnA string `db:"remark_on_a" json:"remark_on_a"`
// RemarkOnB A对B的备注,也就是A显示B的备注名称
RemarkOnB string `db:"remark_on_b" json:"remark_on_b"`
// UpdatedAt 更新时间
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
// CreatedAt 创建时间
CreatedAt time.Time `db:"created_at" json:"created_at"`
}
UserRelation 用户关系信息
func GetUserRelation ¶
func GetUserRelation(id int64, opts ...*GetOptions) (*UserRelation, error)
GetUserRelation 获取用户关系信息
func GetUserRelationByUsersID ¶
func GetUserRelationByUsersID(userAID int64, userBID int64, opts ...*GetOptions) (*UserRelation, error)
GetUserRelationByUsersID 根据用户id获取用户关系
func (*UserRelation) MarshalBinary ¶
func (r *UserRelation) MarshalBinary() (data []byte, err error)
func (*UserRelation) UnmarshalBinary ¶
func (r *UserRelation) UnmarshalBinary(data []byte) error
type UserRelationInvite ¶
type UserRelationInvite struct {
// ID 请求ID
ID int64 `db:"id" json:"id"`
// UserID 用户ID
UserID int64 `db:"user_id" json:"user_id"`
// TargetID 申请目标的用户ID
TargetID int64 `db:"target_id" json:"target_id"`
// Note 申请备注
Note string `db:"note" json:"note,omitempty"`
// Reply 申请回复
Reply string `db:"reply" json:"reply,omitempty"`
// Status 状态 0:待确认,1:已通过,2:已拒绝
Status int `db:"status" json:"status"`
// UpdatedAt 更新时间
UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"`
// CreatedAt 创建时间
CreatedAt time.Time `db:"created_at" json:"created_at"`
// UQFlag 控制记录是唯一的申请记录标记, 使用userID跟targetID联合
UQFlag string `db:"uq_flag" json:"uq_flag,omitempty"`
}
UserRelationInvite 用户关系邀请
func GetLastUserRelationInvite ¶
func GetLastUserRelationInvite(userID, targetID int64, opts ...*GetOptions) (*UserRelationInvite, error)
GetLastUserRelationInvite 获取一条建立用户关系请求记录
func GetUserRelationInvite ¶
func GetUserRelationInvite(id int64, opts ...*GetOptions) (*UserRelationInvite, error)
GetUserRelationInvite 获取一条建立关系邀请记录
func (*UserRelationInvite) MarshalBinary ¶
func (i *UserRelationInvite) MarshalBinary() (data []byte, err error)
func (*UserRelationInvite) UnmarshalBinary ¶
func (i *UserRelationInvite) UnmarshalBinary(data []byte) error