group

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GroupStatusDisabled 已禁用
	GroupStatusDisabled = 0
	// GroupStatusNormal 正常
	GroupStatusNormal = 1
)

群状态

View Source
const (
	// MemberRoleCommon 普通成员
	MemberRoleCommon = 0
	// MemberRoleCreator 创建者
	MemberRoleCreator = 1
	// MemberRoleManager 管理者
	MemberRoleManager = 2
)

群成员角色

View Source
const (
	// InviteStatusWait 等待确认
	InviteStatusWait = 0
	// InviteStatusOK 已确认
	InviteStatusOK = 1
)
View Source
const (
	ChannelServiceName = "channel"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddGroupReq

type AddGroupReq struct {
	GroupNo string
	Name    string
}

AddGroupReq 添加群

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB DB

func NewDB

func NewDB(ctx *config.Context) *DB

NewDB NewDB

func (*DB) DeleteMember

func (d *DB) DeleteMember(groupNo string, uid string, version int64) error

DeleteMember 删除群成员

func (*DB) DeleteMemberTx

func (d *DB) DeleteMemberTx(groupNo string, uid string, version int64, tx *dbr.Tx) error

DeleteMemberTx 删除群成员

func (*DB) ExistMember

func (d *DB) ExistMember(uid string, groupNo string) (bool, error)

ExistMember 群成员是否在群内

func (*DB) ExistMemberDelete

func (d *DB) ExistMemberDelete(uid string, groupNo string) (bool, error)

ExistMemberDelete 存在已删除的群成员数据

func (*DB) Insert

func (d *DB) Insert(m *Model) error

Insert 插入群信息

func (*DB) InsertInviteItemTx

func (d *DB) InsertInviteItemTx(model *InviteItemModel, tx *dbr.Tx) error

InsertInviteItemTx 添加邀请项

func (*DB) InsertInviteTx

func (d *DB) InsertInviteTx(model *InviteModel, tx *dbr.Tx) error

InsertInviteTx 添加邀请信息

func (*DB) InsertMember

func (d *DB) InsertMember(m *MemberModel) error

InsertMember 插入群成员信息

func (*DB) InsertMemberTx

func (d *DB) InsertMemberTx(m *MemberModel, tx *dbr.Tx) error

InsertMemberTx 插入群成员信息(带事务)

func (*DB) InsertTx

func (d *DB) InsertTx(m *Model, tx *dbr.Tx) error

InsertTx 插入群信息(含事务)

func (*DB) QueryDetailWithGroupNo

func (d *DB) QueryDetailWithGroupNo(groupNo string, uid string) (*DetailModel, error)

QueryDetailWithGroupNo 查询群详情

func (*DB) QueryDetailWithGroupNos

func (d *DB) QueryDetailWithGroupNos(groupNos []string, uid string) ([]*DetailModel, error)

QueryDetailWithGroupNos 查询群集合

func (*DB) QueryGroupManagerOrCreatorUIDS

func (d *DB) QueryGroupManagerOrCreatorUIDS(groupNo string) ([]string, error)

QueryGroupManagerOrCreatorUIDS 查询管理者或创建者的uid

func (*DB) QueryGroupsWithGroupNos

func (d *DB) QueryGroupsWithGroupNos(groupNos []string) ([]*Model, error)

QueryGroupsWithGroupNos 通过群ID查询一批群信息

func (*DB) QueryInviteDetail

func (d *DB) QueryInviteDetail(inviteNo string) (*InviteDetailModel, error)

QueryInviteDetail 查询邀请详情

func (*DB) QueryInviteItemDetail

func (d *DB) QueryInviteItemDetail(inviteNo string) ([]*InviteItemDetailModel, error)

QueryInviteItemDetail 查询邀请item详情

func (*DB) QueryIsGroupCreator

func (d *DB) QueryIsGroupCreator(groupNo string, uid string) (bool, error)

QueryIsGroupCreator 是否是群创建者

func (*DB) QueryIsGroupManagerOrCreator

func (d *DB) QueryIsGroupManagerOrCreator(groupNo string, uid string) (bool, error)

QueryIsGroupManagerOrCreator 是否是群管理者或创建者

func (*DB) QueryMemberCount

func (d *DB) QueryMemberCount(groupNo string) (int64, error)

QueryMemberCount 查询群成员数量

func (*DB) QueryMemberWithUID

func (d *DB) QueryMemberWithUID(uid string, groupNo string) (*MemberModel, error)

QueryMemberWithUID 查询群成员

func (*DB) QueryMembersFirstNine

func (d *DB) QueryMembersFirstNine(groupNo string) ([]*MemberModel, error)

QueryMembersFirstNine 查询最先加入群聊的九为群成员

func (*DB) QueryMembersFirstNineExclude

func (d *DB) QueryMembersFirstNineExclude(groupNo string, excludeUIDs []string) ([]*MemberModel, error)

QueryMembersFirstNineExclude 查询最先加入群聊的九位群成员 【excludeUIDs】为排除的用户

func (*DB) QueryMembersWithStatus

func (d *DB) QueryMembersWithStatus(groupNo string, status int) ([]*MemberModel, error)

QueryMembersWithStatus 通过成员状态查询成员

func (*DB) QueryMembersWithUids

func (d *DB) QueryMembersWithUids(uids []string, groupNo string) ([]*MemberModel, error)

QueryMembersWithUids 查询群内的指定成员

func (*DB) QuerySecondOldestMember

func (d *DB) QuerySecondOldestMember(groupNo string) (*MemberModel, error)

QuerySecondOldestMember 查询群里第二长老

func (*DB) QueryWithGroupNo

func (d *DB) QueryWithGroupNo(groupNo string) (*Model, error)

QueryWithGroupNo 根据群编号查询群信息

func (*DB) QueryWithGroupNos

func (d *DB) QueryWithGroupNos(groupNos []string) ([]*Model, error)

QueryWithGroupNo 根据群编号查询群信息

func (*DB) SyncMembers

func (d *DB) SyncMembers(groupNo string, version int64, limit uint64) ([]*MemberDetailModel, error)

SyncMembers 同步群成员

func (*DB) Update

func (d *DB) Update(model *Model) error

Update 更新群信息

func (*DB) UpdateGroupType

func (d *DB) UpdateGroupType(groupNo string, groupType GroupType) error

修改群类型

func (*DB) UpdateGroupTypeTx

func (d *DB) UpdateGroupTypeTx(groupNo string, groupType GroupType, tx *dbr.Tx) error

修改群类型

func (*DB) UpdateInviteItemStatusTx

func (d *DB) UpdateInviteItemStatusTx(status int, inviteNo string, tx *dbr.Tx) error

UpdateInviteItemStatusTx 更新邀请信息状态

func (*DB) UpdateInviteStatusTx

func (d *DB) UpdateInviteStatusTx(allower string, status int, inviteNo string, tx *dbr.Tx) error

UpdateInviteStatusTx 更新邀请信息状态

func (*DB) UpdateManagersToMember

func (d *DB) UpdateManagersToMember(groupNo string, members []string, version int64) error

UpdateManagersToMember 更新指定管理员为普通成员

func (*DB) UpdateMember

func (d *DB) UpdateMember(member *MemberModel) error

UpdateMember 更新群成员

func (*DB) UpdateMemberRoleTx

func (d *DB) UpdateMemberRoleTx(groupNo string, uid string, role int, version int64, tx *dbr.Tx) error

UpdateMemberRoleTx 更新群成员角色

func (*DB) UpdateMemberTx

func (d *DB) UpdateMemberTx(member *MemberModel, tx *dbr.Tx) error

UpdateMemberTx 更新成员信息

func (*DB) UpdateMembersToManager

func (d *DB) UpdateMembersToManager(groupNo string, members []string, version int64) error

UpdateMembersToManager 更新指定群成员为管理员

func (*DB) UpdateTx

func (d *DB) UpdateTx(model *Model, tx *dbr.Tx) error

UpdateTx 更新群信息(带事务)

type DetailModel

type DetailModel struct {
	Model
	Mute            int    // 免打扰
	Top             int    // 置顶
	ShowNick        int    // 显示昵称
	Save            int    // 是否保存
	ChatPwdOn       int    //是否开启聊天密码
	RevokeRemind    int    //撤回提醒
	JoinGroupRemind int    // 进群提醒
	Screenshot      int    //截屏通知
	Receipt         int    //消息是否回执
	Flame           int    // 是否开启阅后即焚
	FlameSecond     int    // 阅后即焚秒数
	Remark          string // 群备注
}

DetailModel 群详情

type Group

type Group struct {
	log.Log
	// contains filtered or unexported fields
}

Group 群组相关API

func New

func New(ctx *config.Context) *Group

New New

func (*Group) CheckForbiddenLoop

func (g *Group) CheckForbiddenLoop()

func (*Group) GetGroupByGroupNo

func (g *Group) GetGroupByGroupNo(groupNo string) (*source.GroupModel, error)

GetGroupByGroupNo 查询群详情

func (*Group) GetGroupMemberByUID

func (g *Group) GetGroupMemberByUID(uid string, groupNo string) (*source.GroupMember, error)

func (*Group) GetGroupMemberByVercode

func (g *Group) GetGroupMemberByVercode(vercode string) (*source.GroupMember, error)

GetGroupMemberByVercode 通过vercode获取群成员

func (*Group) GetGroupMemberByVercodes

func (g *Group) GetGroupMemberByVercodes(vercodes []string) ([]*source.GroupMember, error)

func (*Group) Route

func (g *Group) Route(r *wkhttp.WKHttp)

Route 路由配置

type GroupResp

type GroupResp struct {
	GroupNo             string    `json:"group_no"`               // 群编号
	GroupType           GroupType `json:"group_type"`             // 群类型
	Name                string    `json:"name"`                   // 群名称
	Remark              string    `json:"remark"`                 // 群备注
	Notice              string    `json:"notice"`                 // 群公告
	Mute                int       `json:"mute"`                   // 免打扰
	Top                 int       `json:"top"`                    // 置顶
	ShowNick            int       `json:"show_nick"`              // 显示昵称
	Save                int       `json:"save"`                   // 是否保存
	Forbidden           int       `json:"forbidden"`              // 是否全员禁言
	Invite              int       `json:"invite"`                 // 群聊邀请确认
	ChatPwdOn           int       `json:"chat_pwd_on"`            //是否开启聊天密码
	Screenshot          int       `json:"screenshot"`             //截屏通知
	RevokeRemind        int       `json:"revoke_remind"`          //撤回提醒
	JoinGroupRemind     int       `json:"join_group_remind"`      //进群提醒
	ForbiddenAddFriend  int       `json:"forbidden_add_friend"`   //群内禁止加好友
	Status              int       `json:"status"`                 //群状态
	Receipt             int       `json:"receipt"`                //消息是否回执
	Flame               int       `json:"flame"`                  // 阅后即焚
	FlameSecond         int       `json:"flame_second"`           // 阅后即焚秒数
	AllowViewHistoryMsg int       `json:"allow_view_history_msg"` // 是否允许新成员查看历史消息
	MemberCount         int       `json:"member_count"`           // 成员数量
	OnlineCount         int       `json:"online_count"`           // 在线数量
	Quit                int       `json:"quit"`                   // 我是否已退出群聊
	Role                int       `json:"role"`                   // 我在群聊里的角色
	ForbiddenExpirTime  int64     `json:"forbidden_expir_time"`   // 我在此群的禁言过期时间
	CreatedAt           string    `json:"created_at"`
	UpdatedAt           string    `json:"updated_at"`
	Version             int64     `json:"version"` // 群数据版本
}

type GroupType

type GroupType int

群类型

const (
	GroupTypeCommon GroupType = iota // 普通群
	GroupTypeSuper                   // 超大群
)

type IService

type IService interface {
	// 获取群总数
	GetAllGroupCount() (int64, error)
	// 查询某天的新建群数量
	GetCreatedCountWithDate(date string) (int64, error)
	// 添加一个群
	AddGroup(model *AddGroupReq) error
	// 某个时间段的建群数据
	GetGroupWithDateSpace(startDate, endDate string) (map[string]int64, error)
	// 查询某个群信息
	GetGroupWithGroupNo(groupNo string) (*InfoResp, error)
	// GetGroups 获取群集合
	GetGroups(groupNos []string) ([]*InfoResp, error)
	// 获取某一批群与指定用户的详情(包括用户对群的设置等等)
	GetGroupDetails(groupNos []string, uid string) ([]*GroupResp, error)
	// 获取群详情
	GetGroupDetail(groupNo string, uid string) (*GroupResp, error)

	// -------------------- 群设置 --------------------
	// GetSettings 获取群的设置
	GetSettings(groupNos []string, uid string) ([]*SettingResp, error)
	// GetSettingsWithUids 获取一批用户对某个群的设置
	GetSettingsWithUIDs(groupNo string, uids []string) ([]*SettingResp, error)

	// -------------------- 群成员 --------------------
	// 获取指定群的群成员列表
	GetMembers(groupNo string) ([]*MemberResp, error)
	// 获取黑明单成员uid集合
	GetBlacklistMemberUIDs(groupNo string) ([]string, error)
	// 查询管理员成员uid列表(包括创建者)
	GetMemberUIDsOfManager(groupNo string) ([]string, error)
	// 是否是创建者或管理者
	IsCreatorOrManager(groupNo string, uid string) (bool, error)
	// 获取成员总数量和在线数量
	// 第一个返回参数为成员总数量
	// 第二个返回参数为在线数量
	GetMemberTotalAndOnlineCount(groupNo string) (int, int, error)
	// 是否存在群成员
	ExistMember(groupNo string, uid string) (bool, error)
	// 成员是否在某群里存在 返回对应在群里的群编号
	ExistMembers(groupNos []string, uid string) ([]string, error)
	// GetGroupsWithMemberUID 获取某个用户的所有群
	GetGroupsWithMemberUID(uid string) ([]*InfoResp, error)
	// 获取指定群的群成员的最大数据版本
	GetGroupMemberMaxVersion(groupNo string) (int64, error)
	// 获取用户所有超级群信息
	GetUserSupers(uid string) ([]*InfoResp, error)
}

IService 群相关

func NewService

func NewService(ctx *config.Context) IService

NewService NewService

type InfoResp

type InfoResp struct {
	GroupNo             string    `json:"group_no"`               // 群编号
	GroupType           GroupType `json:"group_type"`             // 群类型
	Name                string    `json:"name"`                   // 群名称
	Notice              string    `json:"notice"`                 // 群公告
	Creator             string    `json:"creator"`                // 创建者uid
	Status              int       `json:"status"`                 // 群状态
	Forbidden           int       `json:"forbidden"`              // 是否全员禁言
	Invite              int       `json:"invite"`                 // 是否开启邀请确认 0.否 1.是
	ForbiddenAddFriend  int       `json:"forbidden_add_friend"`   //群内禁止加好友
	AllowViewHistoryMsg int       `json:"allow_view_history_msg"` // 是否允许新成员查看历史记录
	CreatedAt           string    `json:"created_at"`
	UpdatedAt           string    `json:"updated_at"`
	Version             int64     `json:"version"` // 群数据版本
}

InfoResp 群信息

type InviteDetailModel

type InviteDetailModel struct {
	InviteModel
	InviterName string `json:"inviter_name"` // 邀请者名称

}

InviteDetailModel 邀请者详情

type InviteDetailResp

type InviteDetailResp struct {
	InviteNo    string                 `json:"invite_no"`    // 邀请唯一编号
	GroupNo     string                 `json:"group_no"`     // 群唯一编号
	Inviter     string                 `json:"inviter"`      // 邀请者
	Remark      string                 `json:"remark"`       // 邀请备注
	InviterName string                 `json:"inviter_name"` // 邀请者名称
	Status      int                    `json:"status"`       // 状态 0.未确认 1.已确认
	Items       []InviteItemDetailResp `json:"items"`        // 邀请项详情
}

InviteDetailResp 邀请详情返回

func (InviteDetailResp) From

From From

type InviteItemDetailModel

type InviteItemDetailModel struct {
	InviteItemModel
	Name string // 被邀请者名称
}

InviteItemDetailModel item详情

type InviteItemDetailResp

type InviteItemDetailResp struct {
	UID  string `json:"uid"`  // 被邀请uid
	Name string `json:"name"` // 被邀请者名称
}

InviteItemDetailResp 邀请item

type InviteItemModel

type InviteItemModel struct {
	InviteNo string `json:"invite_no"` // 邀请唯一编号
	GroupNo  string `json:"group_no"`  // 群唯一编号
	Inviter  string `json:"inviter"`   // 邀请者
	UID      string `json:"uid"`       // 被邀请uid
	Status   int    `json:"status"`    // 状态 0.未确认 1.已确认
	db.BaseModel
}

InviteItemModel InviteItemModel

type InviteModel

type InviteModel struct {
	InviteNo string `json:"invite_no"` // 邀请唯一编号
	GroupNo  string `json:"group_no"`  // 群唯一编号
	Inviter  string `json:"inviter"`   // 邀请者
	Remark   string `json:"remark"`    // 邀请备注
	Status   int    `json:"status"`    // 状态 0.未确认 1.已确认
	Allower  string `json:"allower"`   // 确认者
	db.BaseModel
}

InviteModel InviteModel

type InviteReq

type InviteReq struct {
	UIDS   []string `json:"uids"`
	Remark string   `json:"remark"`
}

InviteReq 群邀请

func (InviteReq) Check

func (i InviteReq) Check() error

Check Check

type Manager

type Manager struct {
	log.Log
	// contains filtered or unexported fields
}

Manager 群后台管理api

func NewManager

func NewManager(ctx *config.Context) *Manager

NewManager NewManager

func (*Manager) Route

func (m *Manager) Route(r *wkhttp.WKHttp)

Route 配置路由规则

type MemberDetailModel

type MemberDetailModel struct {
	UID                string // 成员uid
	GroupNo            string // 群编号
	Name               string // 群成员名称
	Remark             string // 成员备注
	Role               int    // 成员角色
	Version            int64
	Vercode            string //验证码
	InviteUID          string // 邀请人
	IsDeleted          int    // 是否删除
	Status             int    // 1.正常 2.黑名单
	Username           string
	Robot              int   // 机器人标识0.否1.是
	ForbiddenExpirTime int64 // 禁言时长
	db.BaseModel
}

MemberDetailModel 成员详情model

type MemberGroupDetailModel

type MemberGroupDetailModel struct {
	GroupName string // 群名称
	MemberModel
}

type MemberModel

type MemberModel struct {
	GroupNo            string // 群编号
	UID                string // 成员uid
	Remark             string // 成员备注
	Role               int    // 成员角色 1. 创建者	 2.管理员
	Version            int64
	Status             int    // 1.正常 2.黑名单
	Vercode            string //验证码
	IsDeleted          int    // 是否删除
	InviteUID          string // 邀请者
	Robot              int    // 机器人
	ForbiddenExpirTime int64  // 禁言时长
	db.BaseModel
}

MemberModel 成员model

type MemberResp

type MemberResp struct {
	GroupNo string // 群编号
	UID     string // 成员uid
	Name    string // 群成员名称
	Remark  string // 成员备注
	Role    int    // 成员角色
	Version int64
	Vercode string //验证码
}

type Model

type Model struct {
	GroupNo             string // 群编号
	GroupType           int    // 群类型 0.普通群 1.超大群
	Name                string // 群名称
	Avatar              string // 群头像
	Notice              string // 群公告
	Creator             string // 创建者uid
	Status              int    // 群状态
	Version             int64  // 版本号
	Forbidden           int    // 是否全员禁言
	Invite              int    // 是否开启邀请确认 0.否 1.是
	ForbiddenAddFriend  int    //群内禁止加好友
	AllowViewHistoryMsg int    // 是否允许新成员查看历史消息
	db.BaseModel
}

Model 群db model

type Service

type Service struct {
	log.Log
	// contains filtered or unexported fields
}

Service Service

func (*Service) AddGroup

func (s *Service) AddGroup(model *AddGroupReq) error

AddGroup 添加一个群

func (*Service) ExistMember

func (s *Service) ExistMember(groupNo string, uid string) (bool, error)

func (*Service) ExistMembers

func (s *Service) ExistMembers(groupNos []string, uid string) ([]string, error)

func (*Service) GetAllGroupCount

func (s *Service) GetAllGroupCount() (int64, error)

GetAllGroupCount 获取群总数

func (*Service) GetBlacklistMemberUIDs

func (s *Service) GetBlacklistMemberUIDs(groupNo string) ([]string, error)

func (*Service) GetCreatedCountWithDate

func (s *Service) GetCreatedCountWithDate(date string) (int64, error)

GetCreatedCountWithDate 获取某天的新建群数量

func (*Service) GetGroupDetail

func (s *Service) GetGroupDetail(groupNo string, uid string) (*GroupResp, error)

func (*Service) GetGroupDetails

func (s *Service) GetGroupDetails(groupNos []string, uid string) ([]*GroupResp, error)

func (*Service) GetGroupMemberMaxVersion

func (s *Service) GetGroupMemberMaxVersion(groupNo string) (int64, error)

func (*Service) GetGroupWithDateSpace

func (s *Service) GetGroupWithDateSpace(startDate, endDate string) (map[string]int64, error)

GetGroupWithDateSpace 某个时间段的建群数据

func (*Service) GetGroupWithGroupNo

func (s *Service) GetGroupWithGroupNo(groupNo string) (*InfoResp, error)

GetGroupWithGroupNo 查询一个群信息

func (*Service) GetGroups

func (s *Service) GetGroups(groupNos []string) ([]*InfoResp, error)

func (*Service) GetGroupsWithMemberUID

func (s *Service) GetGroupsWithMemberUID(uid string) ([]*InfoResp, error)

func (*Service) GetMemberTotalAndOnlineCount

func (s *Service) GetMemberTotalAndOnlineCount(groupNo string) (int, int, error)

func (*Service) GetMemberUIDsOfManager

func (s *Service) GetMemberUIDsOfManager(groupNo string) ([]string, error)

func (*Service) GetMembers

func (s *Service) GetMembers(groupNo string) ([]*MemberResp, error)

func (*Service) GetSettings

func (s *Service) GetSettings(groupNos []string, uid string) ([]*SettingResp, error)

func (*Service) GetSettingsWithUIDs

func (s *Service) GetSettingsWithUIDs(groupNo string, uids []string) ([]*SettingResp, error)

GetSettingsWithUIDs 查询一批用户对某个群的设置

func (*Service) GetUserSupers

func (s *Service) GetUserSupers(uid string) ([]*InfoResp, error)

func (*Service) IsCreatorOrManager

func (s *Service) IsCreatorOrManager(groupNo string, uid string) (bool, error)

type Setting

type Setting struct {
	UID             string // 用户uid
	GroupNo         string // 群编号
	Mute            int    // 免打扰
	Top             int    // 置顶
	ShowNick        int    // 显示昵称
	Save            int    // 是否保存
	ChatPwdOn       int    //是否开启聊天密码
	Screenshot      int    //截屏通知
	RevokeRemind    int    //撤回通知
	JoinGroupRemind int    //进群提醒
	Receipt         int    //消息是否回执
	Flame           int    // 是否开启阅后即焚
	FlameSecond     int    // 阅后即焚秒数
	Remark          string // 群备注
	Version         int64  // 版本
	db.BaseModel
}

Setting 群设置

type SettingResp

type SettingResp struct {
	UID             string
	GroupNo         string // 群编号
	Mute            int    // 免打扰
	Top             int    // 置顶
	ShowNick        int    // 显示昵称
	Save            int    // 是否保存
	ChatPwdOn       int    //是否开启聊天密码
	Screenshot      int    //截屏通知
	RevokeRemind    int    //撤回通知
	JoinGroupRemind int    //进群提醒
	Receipt         int    //消息是否回执
	Remark          string // 群备注
	Version         int64  // 版本
}

SettingResp 群设置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL