Documentation
¶
Index ¶
- func CreateSignMessage(address common.Address, t SignType) string
- func Module(sb *server.ServerBuiler)
- func VerifySignMessage(address common.Address, sign string, signType SignType, t WalletType) bool
- type Contact
- type ContactDto
- type LinkPlatformInput
- type Platform
- type SignNonce
- type SignType
- type UnlinkPlatformInput
- type User
- type UserInfo
- type UserManager
- func (m *UserManager) Find(ctx context.Context, addr string) *User
- func (m *UserManager) Link(ctx context.Context, link *UserPlatform)
- func (m *UserManager) Login(ctx context.Context, address common.Address, signHex string, t WalletType, ...) *User
- func (m *UserManager) ManyIncludePlatforms(ctx context.Context, users []User)
- func (m *UserManager) Unlink(ctx context.Context, userId primitive.ObjectID, platform UserPlatformType, ...)
- func (m *UserManager) Update(ctx context.Context, info *User)
- type UserPlatform
- type UserPlatformType
- type UserRepository
- type UserUpdateInput
- type WalletType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Module ¶
func Module(sb *server.ServerBuiler)
func VerifySignMessage ¶
Types ¶
type ContactDto ¶
type ContactDto struct { Type string `json:"contactType" binding:"required"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Icon string `json:"icon,omitempty"` Url string `json:"url,omitempty"` }
func NewContractDto ¶
func NewContractDto(c *Contact) *ContactDto
func (*ContactDto) ToEntity ¶
func (cc *ContactDto) ToEntity() *Contact
type LinkPlatformInput ¶
type LinkPlatformInput struct { Handle string `json:"handle"` // 对应平台的用户标识 Platform UserPlatformType `json:"platform" binding:"required"` // 平台唯一标识,如 lens, cc(CyberConnect), deschool DisplayName string `json:"displayName"` // 平台上的用户名 Address string `json:"address" binding:"required"` // 平台地址 WalletType WalletType `json:"walletType"` // 当前签名的钱包类型 SignHex string `json:"signHex"` Avatar string `json:"avatar"` Data map[string]string `json:"data"` // 附加数据 }
func (*LinkPlatformInput) ToEntity ¶
func (l *LinkPlatformInput) ToEntity() *UserPlatform
type Platform ¶
type Platform struct { Platform UserPlatformType `json:"platform"` Address string `json:"address"` Handle string `json:"handle"` Data map[string]string `json:"data,omitempty"` }
func NewPlatform ¶
func NewPlatform(p *UserPlatform, isSelf bool) *Platform
type SignNonce ¶
type SignNonce struct { ddd.AuditEntityBase `bson:",inline"` Address string `bson:"address"` Nonce string `bson:"Nonce"` }
type UnlinkPlatformInput ¶
type UnlinkPlatformInput struct { Handle string `json:"handle"` // 对应平台的用户标识 Address string `json:"address" binding:"required"` // 平台地址 Platform UserPlatformType `json:"platform" binding:"required"` // 平台唯一标识,如 lens, cc(CyberConnect), deschool }
type User ¶
type User struct { ddd.FullAuditEntityBase `bson:",inline"` ddd.WithExtraEntity `bson:",inline"` Address string `bson:"address"` UserName string `bson:"userName"` DisplayName string `bson:"displayName"` Avatar string `bson:"avatar"` Bio string `bson:"bio"` Contacts []*Contact `bson:"contacts"` Platforms []*UserPlatform `bson:"-"` }
func (*User) SetContract ¶
type UserInfo ¶
type UserInfo struct { Id string `json:"id"` Address string `json:"address"` DisplayName string `json:"displayName"` Avatar string `json:"avatar"` Bio string `json:"bio"` Platforms []*Platform `json:"platforms"` Contacts []*ContactDto `json:"contacts,omitempty"` }
func NewUserInfo ¶
type UserManager ¶
type UserManager struct {
Repo UserRepository
}
func NewUserManager ¶
func NewUserManager(d *di.Container) *UserManager
func (*UserManager) Link ¶
func (m *UserManager) Link(ctx context.Context, link *UserPlatform)
func (*UserManager) Login ¶
func (m *UserManager) Login(ctx context.Context, address common.Address, signHex string, t WalletType, platform *UserPlatform) *User
func (*UserManager) ManyIncludePlatforms ¶
func (m *UserManager) ManyIncludePlatforms(ctx context.Context, users []User)
func (*UserManager) Unlink ¶
func (m *UserManager) Unlink(ctx context.Context, userId primitive.ObjectID, platform UserPlatformType, address string, handle string)
type UserPlatform ¶
type UserPlatform struct { ddd.AuditEntityBase `bson:",inline"` ddd.WithExtraEntity `bson:",inline"` UserId primitive.ObjectID `bson:"userId"` // 对应用户的唯一标识 Platform UserPlatformType `bson:"platform"` // 平台唯一标识,如 lens, cc(CyberConnect), deschool Handle string `bson:"handle"` // 对应平台的用户标识 Address string `bson:"address"` // 使用平台的地址 DisplayName string `bson:"displayName"` Avatar string `bson:"avatar"` VerifiedAt time.Time `bson:"verifiedAt"` }
type UserPlatformType ¶
type UserPlatformType int
const ( PlatformDeSchool UserPlatformType = 1 PlatformLens UserPlatformType = 2 PlatformCyberConnect UserPlatformType = 3 )
type UserRepository ¶
type UserRepository interface { ddd.Repository[User] Insert(ctx context.Context, u *User) primitive.ObjectID Update(ctx context.Context, Id primitive.ObjectID, u *User) int InsertMany(ctx context.Context, us []User, ignoreErr bool) []primitive.ObjectID LinkPlatform(ctx context.Context, p *UserPlatform) UnlinkPlatform(ctx context.Context, userId primitive.ObjectID, address common.Address, handle string, platform UserPlatformType) int Find(ctx context.Context, address common.Address) *User GetManyByAddr(ctx context.Context, userIds []common.Address) []User GetPlatforms(ctx context.Context, userId primitive.ObjectID) []UserPlatform GetManyPlatforms(ctx context.Context, userIds []primitive.ObjectID) []UserPlatform GetUsers(ctx context.Context, q *string, platform *UserPlatformType, p *x.PageAndSort) []User }
type UserUpdateInput ¶
type UserUpdateInput struct { DisplayName *string `json:"displayName"` Avatar *string `json:"avatar"` Bio *string `json:"bio"` Contacts []*ContactDto `json:"contacts"` }
func (*UserUpdateInput) ToEntity ¶
func (input *UserUpdateInput) ToEntity(u *User)
type WalletType ¶
type WalletType string
const ( MetaMask WalletType = "MetaMask" UniPass WalletType = "UniPass" )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.