hackathon

package
v0.0.0-...-9a83fbb Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoothPlatform        = 0
	DeSchoolPlatform     = 1
	LensPlatform         = 2
	CyberConnectPlatform = 3
)
View Source
const TargetTypeLink3Event = "link3_event" // link3 event

Variables

View Source
var MBTI_MATCHING_MAP = [16][16]int{
	{8, 8, 8, 10, 8, 10, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2},
	{8, 8, 10, 8, 10, 8, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2},
	{8, 10, 8, 8, 8, 8, 8, 10, 2, 2, 2, 2, 2, 2, 2, 2},
	{10, 8, 8, 8, 8, 8, 8, 8, 10, 2, 2, 2, 2, 2, 2, 2},
	{8, 10, 8, 8, 8, 8, 8, 10, 6, 6, 6, 6, 4, 4, 4, 4},
	{10, 8, 8, 8, 8, 8, 10, 8, 6, 6, 6, 6, 6, 6, 6, 6},
	{8, 8, 8, 8, 8, 10, 8, 8, 6, 6, 6, 6, 4, 4, 4, 10},
	{8, 8, 10, 8, 10, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4},

	{2, 2, 2, 10, 6, 6, 6, 6, 4, 4, 4, 4, 6, 10, 6, 10},
	{2, 2, 2, 2, 6, 6, 6, 6, 4, 4, 4, 4, 10, 6, 10, 6},
	{2, 2, 2, 2, 6, 6, 6, 6, 4, 4, 4, 4, 6, 10, 6, 10},
	{2, 2, 2, 2, 6, 6, 6, 6, 4, 4, 4, 4, 10, 6, 10, 6},

	{2, 2, 2, 2, 4, 6, 4, 4, 6, 10, 6, 10, 8, 8, 8, 8},
	{2, 2, 2, 2, 4, 6, 4, 4, 10, 6, 10, 6, 8, 8, 8, 8},
	{2, 2, 2, 2, 4, 6, 4, 4, 6, 10, 6, 10, 8, 8, 8, 8},
	{2, 2, 2, 2, 4, 6, 10, 4, 10, 6, 10, 6, 8, 8, 8, 8},
}

Functions

func GetOwners

func GetOwners(address string, tokenId int) []string

Types

type CourseDetail

type CourseDetail struct {
	Id          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	SeriesId    string    `json:"seriesId"`
	CoverImage  string    `json:"coverImage"`
	CreatorId   string    `json:"creatorId"`
	CreatedAt   time.Time `json:"createdAt"`
}

func RecommendCourses

func RecommendCourses(ctx context.Context, labels []string) []*CourseDetail

type EventInput

type EventInput struct {
	UserId string       `json:"userId"`
	Events []*EventItem `json:"events"`
	Users  []string     `json:"users"`
}

type EventItem

type EventItem struct {
	Id     string   `json:"id"`
	Labels []string `json:"labels"`
}

type EventMatchedItem

type EventMatchedItem struct {
	Id            string          `json:"id"`
	IsEnabled     bool            `json:"isEnabled"`
	Interested    []string        `json:"interested"`
	Matched       *UserEventItem  `json:"matchedUsers"`
	Following     *UserEventItem  `json:"followingUsers"`
	Courses       []*CourseDetail `json:"courses"`
	Registrants   *UserEventItem  `json:"registrants"`
	HasInterested bool            `json:"hasInterested"`
}

func MatchEvents

func MatchEvents(ctx context.Context, input EventInput) []*EventMatchedItem

func NewItem

func NewItem() *EventMatchedItem

func (*EventMatchedItem) IsMatched

func (e *EventMatchedItem) IsMatched() bool

type Follow

type Follow struct {
	FromAddr            string `bson:"fromAddr" json:"fromAddr"`
	ToAddr              string `bson:"toAddr" json:"toAddr"`
	ddd.AuditEntityBase `bson:",inline"`
	FromUser            primitive.ObjectID `bson:"fromUser"`
	ToUser              primitive.ObjectID `bson:"toUser"`
}

type FollowRepository

type FollowRepository interface {
	ddd.Repository[Follow]
	CheckExistsByToAndFromAddr(ctx context.Context, fromUser primitive.ObjectID, toUser primitive.ObjectID) bool
	GetListByFilter(ctx context.Context, userId primitive.ObjectID, key string) []Follow
	DeleteByToAndFrom(ctx context.Context, fromUser primitive.ObjectID, toUser primitive.ObjectID) bool

	GetFollowingUsers(ctx context.Context, userId primitive.ObjectID) []primitive.ObjectID

	GetFollowingCount(ctx context.Context, userIds []primitive.ObjectID) map[primitive.ObjectID]int
	GetFollowerCount(ctx context.Context, userIds []primitive.ObjectID) map[primitive.ObjectID]int
	CheckIsFollowing(ctx context.Context, userId primitive.ObjectID, ids []primitive.ObjectID) map[primitive.ObjectID]bool
}

type FollowerList

type FollowerList struct {
	VistorFollowedPerson bool      `json:"vistorFollowedPerson"`
	PersonFollowedVistor bool      `json:"personFollowedVistor"`
	Follower             *UserItem `json:"follower"`
}

type FollowingList

type FollowingList struct {
	VistorFollowedPerson bool      `json:"vistorFollowedPerson"`
	PersonFollowedVistor bool      `json:"personFollowedVistor"`
	Following            *UserItem `json:"following"`
}

type HackathonManager

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

func NewHackathonManager

func NewHackathonManager(c *di.Container) *HackathonManager

func (*HackathonManager) AutoSendEnsoulSbt

func (hm *HackathonManager) AutoSendEnsoulSbt(ctx context.Context, toAddressStr string, tokenIdStr string) bool

自动发放一枚 Ensoul SBT

func (*HackathonManager) CheckFollowExists

func (hm *HackathonManager) CheckFollowExists(ctx context.Context, fromUser primitive.ObjectID, toUser primitive.ObjectID) bool

查询双人关系

func (*HackathonManager) DeleteFollow

func (hm *HackathonManager) DeleteFollow(ctx context.Context, fromUser primitive.ObjectID, toUser primitive.ObjectID) bool

删除

func (*HackathonManager) GetFollower

func (hm *HackathonManager) GetFollower(ctx context.Context, userId primitive.ObjectID, vistorUserId primitive.ObjectID) []FollowerList

查询粉丝列表

func (*HackathonManager) GetFollowing

func (hm *HackathonManager) GetFollowing(ctx context.Context, userId primitive.ObjectID, vistorUserId primitive.ObjectID) []FollowingList

查询偶像列表

func (*HackathonManager) GetIdListByAddr

func (hm *HackathonManager) GetIdListByAddr(ctx context.Context, address string) []Id

获取所有链接过的身份列表

func (*HackathonManager) GetIdSbtDetail

func (hm *HackathonManager) GetIdSbtDetail(ctx context.Context, address string) *IdSbtDetail

获取一个 ID 的 SBT 信息

func (*HackathonManager) GetNewIdList

func (hm *HackathonManager) GetNewIdList(ctx context.Context) []Id

获取新用户

func (*HackathonManager) GetQ11e

func (hm *HackathonManager) GetQ11e(ctx context.Context, userId primitive.ObjectID) *Q11e

func (*HackathonManager) GetResumeByAddr

func (hm *HackathonManager) GetResumeByAddr(ctx context.Context, userId primitive.ObjectID, address string, nonAutoGen bool) *Resume

查询用户简历

func (*HackathonManager) GetSbtDetail

func (hm *HackathonManager) GetSbtDetail(ctx context.Context, address string, tokenId int) *SbtDetail

获取 SBT 的详情信息

func (*HackathonManager) Insert

func (hm *HackathonManager) Insert(ctx context.Context, userId primitive.ObjectID, address string, data string) primitive.ObjectID

更新用户简历

func (*HackathonManager) InsertFollow

func (hm *HackathonManager) InsertFollow(ctx context.Context, fromUser primitive.ObjectID, toUser primitive.ObjectID) bool

添加关系

func (*HackathonManager) PutQ11e

func (hm *HackathonManager) PutQ11e(ctx context.Context, input *Q11e) primitive.ObjectID

func (*HackathonManager) RunRecommendations

func (hm *HackathonManager) RunRecommendations(ctx context.Context, userId primitive.ObjectID) *UserRecommendation

func (*HackathonManager) SayHello

func (hm *HackathonManager) SayHello(ctx context.Context) string

Ping 专用

func (*HackathonManager) ValidateDeSchoolId

func (hm *HackathonManager) ValidateDeSchoolId(ctx context.Context, address string, baseAddress string, lensHandle string, platform int) bool

链接验证 DeSchool ID

type HackathonOptions

type HackathonOptions struct {
	PrivKey        string
	ContractAddr   string
	PolygonNetwork string
	InfuraApiKey   string
	MoralisKey     string
	DeschoolUrl    string
}

type Id

type Id struct {
	Platform            PlatformType `bson:"platform" json:"platform"`
	Address             string       `bson:"address" json:"address"`
	BaseAddress         string       `bson:"baseAddress" json:"baseAddress"`
	LensHandle          string       `bson:"lensHandle" json:"lensHandle"`
	ddd.AuditEntityBase `bson:",inline"`
}

type IdRepository

type IdRepository interface {
	ddd.Repository[Id]
	GetListByAddress(ctx context.Context, address string) []Id
	CheckExistsByAddrBaseAddrAndPltfm(ctx context.Context, address string, baseAddr string, platform PlatformType) bool
	GetListByBaseAddr(ctx context.Context, baseAddr string) []Id
	GetTen(ctx context.Context) []Id

	CheckAddrs(ctx context.Context, addrs []string) []string
}

type IdSbtDetail

type IdSbtDetail struct {
	Abilities [6]int        `json:"ability"`
	Sbts      []SbtInWallet `json:"sbts"`
}

type MbtiType

type MbtiType int
const (
	INFP MbtiType = 0
	ENFP MbtiType = 1
	INFJ MbtiType = 2
	ENFJ MbtiType = 3

	INTJ MbtiType = 4
	ENTJ MbtiType = 5
	INTP MbtiType = 6
	ENTP MbtiType = 7

	ISFP MbtiType = 8
	ESFP MbtiType = 9
	ISTP MbtiType = 10
	ESTP MbtiType = 11

	ISFJ MbtiType = 12
	ESFJ MbtiType = 13
	ISTJ MbtiType = 14
	ESTJ MbtiType = 15

	UnKnown MbtiType = -1
)

type NMetadata

type NMetadata struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Image       string `json:"image"`
}

type NftByWalletOutput

type NftByWalletOutput struct {
	Total  int           `json:"total"`
	Result []SbtInWallet `json:"result"`
}

func GetNftByWallet

func GetNftByWallet(address string) *NftByWalletOutput

type NftMetaData

type NftMetaData struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Image       string `json:"image"`
}

type NftMetaDataOutput

type NftMetaDataOutput struct {
	Address            string      `json:"token_address"`
	TokenId            string      `json:"token_id"`
	ContractType       string      `json:"contract_type"`
	NormalizedMetadata NftMetaData `json:"normalized_metadata"`
}

func GetNftMetadata

func GetNftMetadata(address string, tokenId int) *NftMetaDataOutput

type NftOwnerOutput

type NftOwnerOutput struct {
	Result []NftOwnerResult `json:"result"`
}

type NftOwnerResult

type NftOwnerResult struct {
	OwnerOf string `json:"owner_of"`
}

type PlatformType

type PlatformType int

type Q11e

type Q11e struct {
	ddd.EntityBase `bson:",inline"`
	UserId         primitive.ObjectID `bson:"userId"`
	Goals          []string           `bson:"goals"`
	Interests      []string           `bson:"interests"`
	Pref1          string             `bson:"pref1"`
	Pref2          string             `bson:"pref2"`
	Pref3          string             `bson:"pref3"`
	Mbti           int                `bson:"mbti"`

	Address string `json:"address"`
}

type Q11eRepository

type Q11eRepository interface {
	ddd.Repository[Q11e]
	GetByUserId(ctx context.Context, userId primitive.ObjectID) *Q11e
	CheckAndGetExistsByUser(ctx context.Context, userId primitive.ObjectID) (bool, *Q11e)

	GetManyByUsers(ctx context.Context, userIds []primitive.ObjectID) []Q11e
}

type Resume

type Resume struct {
	ddd.FullAuditEntityBase `bson:",inline"`
	UserId                  primitive.ObjectID `bson:"userId" json:"userId"`
	Data                    string             `bson:"data" json:"data"`
	Address                 string             `bson:"address" json:"address"`
}

type ResumeContent

type ResumeContent struct {
	Career []struct {
		Title   string `json:"title"`
		Project struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"project,omitempty"`
		Role        string `json:"role,omitempty"`
		Description string `json:"description"`
	} `json:"career"`
}

type ResumeRepository

type ResumeRepository interface {
	ddd.Repository[Resume]
	GetByUserId(ctx context.Context, address primitive.ObjectID) *Resume
	CheckExists(ctx context.Context, userId primitive.ObjectID) bool
}

type SbtDetail

type SbtDetail struct {
	Metadata *NftMetaDataOutput
	Owners   []string
}

type SbtInWallet

type SbtInWallet struct {
	Address  string    `json:"token_address"`
	TokenId  string    `json:"token_id"`
	Uri      string    `json:"token_uri"`
	Metadata NMetadata `json:"normalized_metadata"`
}

type UserEventItem

type UserEventItem struct {
	Users []UserItem `json:"users"`
	Count int        `json:"count"`
}

type UserItem

type UserItem struct {
	Id          string `json:"id"`
	DisplayName string `json:"displayName"`
	Avatar      string `json:"avatar"`
	Address     string `json:"address"`
}

type UserRecommendation

type UserRecommendation struct {
	ddd.EntityBase `bson:",inline" json:"ddd.EntityBase"`
	UserId         primitive.ObjectID `bson:"userId"`
	TargetId       primitive.ObjectID `bson:"targetId"`
	Reasons        []string           `bson:"reasons"`
	CreatedAt      time.Time          `bson:"used"`
	Score          int                `bson:"score"`

	FromAddr string `bson:"fromAddr"`
	ToAddr   string `bson:"toAddr"`
}

type UserRecommendationRepository

type UserRecommendationRepository interface {
	ddd.Repository[UserRecommendation]

	GetUsers(ctx context.Context, userId primitive.ObjectID) []primitive.ObjectID
}

Jump to

Keyboard shortcuts

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