repo

package
v0.0.0-...-2886eff Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var ErrInvalidGroup = errors.New("invalid group")

Functions

func CloseDB

func CloseDB()

CloseDB 关闭数据库连接

func CloseRedis

func CloseRedis()

CloseRedis 关闭 Redis 客户端连接

func InitDB

func InitDB(host string) (*gorm.DB, error)

InitDB 初始化数据库连接,接收动态 host 参数

func InitRedis

func InitRedis(host string) (*redis.Client, error)

InitRedis 初始化 Redis 客户端,接收动态 host 参数

func NewGroupService

func NewGroupService(userAddr string) (*groupService, error)

Types

type GroupAvatarSet

type GroupAvatarSet struct {
	GroupId  uuid.UUID
	UserInfo []*UserInfo
}

type GroupInfo

type GroupInfo struct {
	GroupID   uuid.UUID `gorm:"column:id"`
	GroupName string    `gorm:"column:name"`
	Avatar    string    `gorm:"column:avatar"`
}

type GroupMember

type GroupMember struct {
	UserID   int64
	Role     model.GroupRole
	Nickname string
	JoinTime time.Time
}

type GroupRedis

type GroupRedis interface {
}

func NewGroupRedis

func NewGroupRedis(r *redis.Client) GroupRedis

type GroupRepo

type GroupRepo interface {
	CreateGroup(ctx context.Context, ownerID int64, userIDs []int64, groupName string) (groupID uuid.UUID, err error)
	AddGroupMember(ctx context.Context, groupID uuid.UUID, userIDs []int64) error // 可进一步拓展
	KickOutGroupMember(ctx context.Context, groupID uuid.UUID, executorID int64, userIDs []int64) error
	PromoteToAdmin(ctx context.Context, groupID uuid.UUID, executorID int64, userID int64) error
	TransferGroupOwner(ctx context.Context, groupID uuid.UUID, executorID int64, userID int64) error
	DemotedToMember(ctx context.Context, groupID uuid.UUID, executorID int64, userID int64) error
	UpdateNotice(ctx context.Context, groupID uuid.UUID, executorID int64, newNoticeText string) error
	GetNotice(ctx context.Context, groupID uuid.UUID) (string, error)
	UpdateGroupName(ctx context.Context, groupID uuid.UUID, executorID int64, newGroupName string) error
	GetGroupName(ctx context.Context, groupID uuid.UUID) (string, error)
	GetGroupAvatar(ctx context.Context, groupID uuid.UUID) (*GroupAvatarSet, error)
	GetGroupInfos(ctx context.Context, groupID uuid.UUIDs) ([]*GroupInfo, error)
	UpdateSelfName(ctx context.Context, groupID uuid.UUID, userID int64, newName string) error
	GetGroupMembers(ctx context.Context, groupID uuid.UUID) ([]GroupMember, error)
}

func NewGroupRepo

func NewGroupRepo(db *gorm.DB, m *groupService) GroupRepo

type GroupServiceServer

type GroupServiceServer struct {
	grouppb.UnimplementedGroupServiceServer
	// contains filtered or unexported fields
}

func NewGroupServiceServer

func NewGroupServiceServer(r GroupRepo) *GroupServiceServer

func (GroupServiceServer) ListGroupInfos

func (*GroupServiceServer) ListGroupMembers

for grpc

type UserInfo

type UserInfo struct {
	UserID   int64  `json:"user_id"`
	Nickname string `json:"nickname"`
	Avatar   string `json:"avatar"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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