repo

package
v0.0.0-...-d0a0e58 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DevVcode = "123456"

the vcode used for the development

View Source
const VcodeDuration = 30 * time.Minute

Verification code validity period

Variables

This section is empty.

Functions

func DeleteEmailVcodeToForgetPwd

func DeleteEmailVcodeToForgetPwd(email string)

func IsExpireVcode

func IsExpireVcode(vcode *Vcode) bool

func IsFrequentEmailVcodeToForgetPwd

func IsFrequentEmailVcodeToForgetPwd(email string) bool

Check whether a verification code has been generated within one minute

Types

type AccessesDaily

type AccessesDaily struct {
	Date  string `json:"date"`
	Value int64  `json:"value"`
}

type Client

type Client struct {
	ClientInfo
	Name          string `json:"name"`
	Location      string `json:"location"`
	AddressRobust string `json:"address_robust"`
}

type ClientAddress

type ClientAddress struct {
	Uid       uuid.UUID `json:"uid"`
	AddressId string    `json:"address_id"`
}

type ClientHistoryDealStatsItem

type ClientHistoryDealStatsItem struct {
	Provider        string          `json:"provider"`
	Region          string          `json:"region"`
	IsoCode         string          `json:"iso_code"`
	RawPower        decimal.Decimal `json:"raw_power"`
	QualityAdjPower decimal.Decimal `json:"quality_adj_power"`

	MinPieceSize *decimal.Decimal `json:"min_piece_size"`
	MaxPieceSize *decimal.Decimal `json:"max_piece_size"`

	RetrievalSuccessRate float64 `json:"retrieval_success_rate"`

	Owner string `json:"owner"`

	StorageSuccessRate float64 `json:"storage_success_rate" gorm:"column:deal_success_rate"`
	ReputationScore    int     `json:"reputation_score" gorm:"column:score"`
	ReviewScore        float64 `json:"review_score"`
	Reviews            int     `json:"reviews"`

	Name string `json:"name"`

	// relevant client deal
	StorageDeals     uint64           `json:"storage_deals"`
	StorageCapacity  decimal.Decimal  `json:"storage_capacity"`
	DataCap          decimal.Decimal  `json:"data_cap"`
	AvgPrice         *decimal.Decimal `json:"avg_price"`
	AvgVerifiedPrice *decimal.Decimal `json:"avg_verified_price"`
	FirstDealTime    uint64           `json:"first_deal_time" gorm:"column:client_first_deal_time"`
}

type ClientInfo

type ClientInfo struct {
	AddressId          string          `json:"address_id"`
	StorageCapacity    decimal.Decimal `json:"storage_capacity"`
	StorageDeals       int64           `json:"storage_deals"`
	DataCap            decimal.Decimal `json:"data_cap"`
	UsedDataCap        decimal.Decimal `json:"used_data_cap"`
	TotalDataCap       decimal.Decimal `json:"total_data_cap"`
	VerifiedDeals      int64           `json:"verified_deals"`
	Bandwidth          string          `json:"bandwidth"`
	MonthlyStorage     string          `json:"monthly_storage"`
	UseCase            string          `json:"use_case"`
	ServiceRequirement string          `json:"service_requirement"`
}

type ClientOrderParam

type ClientOrderParam struct {
	SortBy string `` /* 148-byte string literal not displayed */
	Order  string `json:"order" form:"order" binding:"oneof=asc desc" example:"desc"`
}

type ClientProfile

type ClientProfile struct {
	Profile
}

type ClientStats

type ClientStats struct {
	Client          string
	UsedDataCap     decimal.Decimal
	VerifiedDeals   int64
	StorageCapacity decimal.Decimal
	StorageDeals    int64
}

type ContactsMonthly

type ContactsMonthly struct {
	Month string `json:"month"`
	Value int64  `json:"value"`
}

type FilterParam

type FilterParam struct {
	SpsStatus string `json:"sps_status" form:"sps_status" binding:"omitempty,oneof=all registered autofilled"`
	Region    string `json:"region" form:"region" binding:"omitempty,max=32"`

	RawPowerRange           *RangeParam `json:"raw_power_range" form:"raw_power_range" binding:"omitempty"`
	StorageSuccessRateRange *RangeParam `json:"storage_success_rate_range" form:"storage_success_rate_range" binding:"omitempty"`
	ReputationScoreRange    *RangeParam `json:"reputation_score_range" form:"reputation_score_range" binding:"omitempty"`
	ReviewScoreRange        *RangeParam `json:"review_score_range" form:"review_score_range" binding:"omitempty"`
}

type LoginUser

type LoginUser struct {
	ClientId     string    `json:"client_id"`
	RefreshToken string    `json:"refresh_token"`
	AccessToken  string    `json:"access_token"`
	Uid          uuid.UUID `json:"uid"`
	Type         string    `json:"type"`
	Address      string    `json:"address"`
	AddressId    string    `json:"address_id"`
	Email        string    `json:"email"`
	Name         string    `json:"name"`
	Avatar       string    `json:"avatar"`
	Location     string    `json:"location"`
}

type Manager

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

func NewManage

func NewManage(conf *settings.AppConfig, logWriter io.Writer) *Manager

func (*Manager) AccessesDaily

func (m *Manager) AccessesDaily() (list []*AccessesDaily, err error)

func (*Manager) AccessesLastDay

func (m *Manager) AccessesLastDay() (count int64, err error)

func (*Manager) ClientInfo

func (m *Manager) ClientInfo(addrId string) (info *ClientInfo, err error)

func (*Manager) ClientList

func (m *Manager) ClientList(pagination types.PaginationParams, order ClientOrderParam, search string) (total int, list []*Client, err error)

func (*Manager) ClientProfile

func (m *Manager) ClientProfile(addrId string) (profile *ClientProfile, err error)

func (*Manager) ClientUserList

func (m *Manager) ClientUserList() (list []*ClientAddress, err error)

func (*Manager) ClientsToDealSpByRange

func (m *Manager) ClientsToDealSpByRange(startEpoch, endEpoch int64) (count int64, err error)

func (*Manager) ClientsToDealSpLastMonth

func (m *Manager) ClientsToDealSpLastMonth() (count int64, err error)

func (*Manager) ContactsClientSpLastMonth

func (m *Manager) ContactsClientSpLastMonth() (count int64, err error)

func (*Manager) ContactsClientSpMonthly

func (m *Manager) ContactsClientSpMonthly() (list []*AccessesDaily, err error)

func (*Manager) CountDeal

func (m *Manager) CountDeal(lastDealId uint64) (count int64, err error)

deal id range [0, lastDealId]

func (*Manager) CountDealRange

func (m *Manager) CountDealRange(firstDealId, lastDealId uint64) (count int64, err error)

deal id range [firstDealId, lastDealId)

func (*Manager) CreateAccessLog

func (m *Manager) CreateAccessLog(logs []*models.AccessLog) error

func (*Manager) CreateAdminUser

func (m *Manager) CreateAdminUser(u *models.AdminUser) error

func (*Manager) CreateLoginInfo

func (m *Manager) CreateLoginInfo(info *models.LoginInfo) error

func (*Manager) CreateMessage

func (m *Manager) CreateMessage(msg *models.Message) error

func (*Manager) CreateRelationship

func (m *Manager) CreateRelationship(oneUid, otherUid string) error

func (*Manager) CreateUser

func (m *Manager) CreateUser(u *models.User) error

func (*Manager) ExistAdminUserByName

func (m *Manager) ExistAdminUserByName(name string) (bool, error)

func (*Manager) ExistAdminUserByUid

func (m *Manager) ExistAdminUserByUid(uid string) (bool, error)

func (*Manager) ExistUser

func (m *Manager) ExistUser(userType string, address string) (bool, error)

func (*Manager) ExistUserByEmail

func (m *Manager) ExistUserByEmail(eamil string) (bool, error)

func (*Manager) ExistUserByUid

func (m *Manager) ExistUserByUid(uid string) (bool, error)

func (*Manager) FirstDeal

func (m *Manager) FirstDeal() (deal *models.Deal, err error)

func (*Manager) FirstValidDeal

func (m *Manager) FirstValidDeal() (deal *models.Deal, err error)

func (*Manager) GenerateLoginToken

func (m *Manager) GenerateLoginToken(user *models.User) *LoginUser

func (*Manager) GenerateRefreshToken

func (m *Manager) GenerateRefreshToken(uid string, clientId string, extend interface{}) string

func (*Manager) GetClientStatsSum

func (m *Manager) GetClientStatsSum() (list []*ClientStats, err error)

func (*Manager) GetDeal

func (m *Manager) GetDeal(dealId uint64) (deal *models.Deal, err error)

func (*Manager) GetDealIdByRange

func (m *Manager) GetDealIdByRange(firstDealId, lastDealId uint64) (dealIds []uint64, err error)

deal id range [firstDealId, lastDealId)

func (*Manager) GetProviderAddress

func (m *Manager) GetProviderAddress(limit, offset int) (addresses []string, err error)

func (*Manager) GetTokenVerify

func (m *Manager) GetTokenVerify() token.Verify

func (*Manager) HasDeal

func (m *Manager) HasDeal(client, provider string) (has bool, err error)

func (*Manager) HasProvider

func (m *Manager) HasProvider(uid, provider string) (own bool, err error)

func (*Manager) HasRelationByUser

func (m *Manager) HasRelationByUser(userUid, partnerUid string) (has bool, err error)

func (*Manager) IncrMetricsOverviewLast24h

func (m *Manager) IncrMetricsOverviewLast24h() (*MetricsOverview, error)

func (*Manager) InsertReview

func (m *Manager) InsertReview(review *models.Review) error

func (*Manager) LastClientStats

func (m *Manager) LastClientStats() (stats *models.ClientStats, err error)

func (*Manager) LastDeal

func (m *Manager) LastDeal() (deal *models.Deal, err error)

func (*Manager) LastProviderStatsMonthly

func (m *Manager) LastProviderStatsMonthly() (stats *models.ProviderStatsMonthly, err error)

func (*Manager) MessagesByUser

func (m *Manager) MessagesByUser(oneUid, anotherUid string, before *types.UnixTime, limit int) (list []*models.Message, err error)

func (*Manager) MetricsClientOverview

func (m *Manager) MetricsClientOverview() (*MetricsClientOverview, error)

func (*Manager) MetricsClientToDealSpDetail

func (m *Manager) MetricsClientToDealSpDetail(pagination types.PaginationParams) (int, []*MetricsClientDetailItem, error)

func (*Manager) MetricsOverview

func (m *Manager) MetricsOverview() (*MetricsOverview, error)

func (*Manager) MetricsSpOverview

func (m *Manager) MetricsSpOverview() (*MetricsSpOverview, error)

func (*Manager) MetricsSpToDealNewClientDetail

func (m *Manager) MetricsSpToDealNewClientDetail(pagination types.PaginationParams) (int, []*MetricsSpDetailItem, error)

func (*Manager) PartnersByUid

func (m *Manager) PartnersByUid(uid string) (list []*Partner, err error)

func (*Manager) PartnersStatusByUid

func (m *Manager) PartnersStatusByUid(uid string) (list []*PartnerStatus, err error)

func (*Manager) ProviderClientsByRange

func (m *Manager) ProviderClientsByRange(startEpoch, endEpoch int64) (list []*ProviderClient, err error)

func (*Manager) ProviderList

func (m *Manager) ProviderList(pagination types.PaginationParams, order OrderParam, search string, filter FilterParam) (total int, list []*Provider, err error)

func (*Manager) ProviderListByOwner

func (m *Manager) ProviderListByOwner(owner string) (list []*Provider, err error)

func (*Manager) QueryAdminUserByName

func (m *Manager) QueryAdminUserByName(name string) (u *models.AdminUser, err error)

func (*Manager) QueryAdminUserByUid

func (m *Manager) QueryAdminUserByUid(uid string) (u *models.AdminUser, err error)

func (*Manager) QueryUserByEmail

func (m *Manager) QueryUserByEmail(email string) (u *models.User, err error)

func (*Manager) QueryUserByUid

func (m *Manager) QueryUserByUid(uid string) (u *models.User, err error)

func (*Manager) RegisteredSpRatio

func (m *Manager) RegisteredSpRatio() (ratio float64, err error)

func (*Manager) ReviewsByClient

func (m *Manager) ReviewsByClient(pagination types.PaginationParams, clientId string) (total int, list []*Review, err error)

func (*Manager) ReviewsBySpOwner

func (m *Manager) ReviewsBySpOwner(pagination types.PaginationParams, ownerId string) (total int, list []*Review, err error)

func (*Manager) SPOwnerProfile

func (m *Manager) SPOwnerProfile(addrId string) (profile *SPOwnerProfile, err error)

func (*Manager) SpsToDealNewClientByRange

func (m *Manager) SpsToDealNewClientByRange(startMonth, endMonth time.Time) (count int64, err error)

func (*Manager) SpsToDealNewClientLastMonth

func (m *Manager) SpsToDealNewClientLastMonth() (count int64, err error)

func (*Manager) StatsClientDeal

func (m *Manager) StatsClientDeal(startDealId, endDealId int64) (list []*models.ClientStats, err error)

deal id range [startDealId,endDealId)

func (*Manager) StatsClientHistoryDeal

func (m *Manager) StatsClientHistoryDeal(pagination types.PaginationParams, clientId string) (total int, list []*ClientHistoryDealStatsItem, err error)

func (*Manager) StatsProviderFirstDealTime

func (m *Manager) StatsProviderFirstDealTime() (data []*ProviderDealFirstTime, err error)

func (*Manager) StatsReviews

func (m *Manager) StatsReviews() (list []*ReviewStatsItem, err error)

func (*Manager) UncheckedMessageGroupListByRecipient

func (m *Manager) UncheckedMessageGroupListByRecipient(recipient string) (list []*UncheckedMessageItem, err error)

func (*Manager) UncheckedMessagesByPair

func (m *Manager) UncheckedMessagesByPair(recipient, sender string) (list []*UncheckedMessageItem, err error)

func (*Manager) UncheckedMessagesByRecipient

func (m *Manager) UncheckedMessagesByRecipient(recipient string) (total int64, err error)

func (*Manager) UpdateAdminUserPassword

func (m *Manager) UpdateAdminUserPassword(u *models.AdminUser) (err error)

func (*Manager) UpdateMessagesChecked

func (m *Manager) UpdateMessagesChecked(sender, recipient string) error

func (*Manager) UpdateProfile

func (m *Manager) UpdateProfile(u *models.User) error

func (*Manager) UpdateProviderFirstDealTime

func (m *Manager) UpdateProviderFirstDealTime(list []*models.Provider) error

func (*Manager) UpdateProviderOwner

func (m *Manager) UpdateProviderOwner(list []*models.Provider) error

func (*Manager) UpdateProviderReviewsStats

func (m *Manager) UpdateProviderReviewsStats(list []*models.Provider) error

func (*Manager) UpdateProviderSuccessRate

func (m *Manager) UpdateProviderSuccessRate(list []*models.Provider) error

func (*Manager) UpdateUserPassword

func (m *Manager) UpdateUserPassword(u *models.User) (err error)

func (*Manager) UpsertClientInfo

func (m *Manager) UpsertClientInfo(info *models.ClientInfo) error

func (*Manager) UpsertClientInfoDataCap

func (m *Manager) UpsertClientInfoDataCap(list []*models.ClientInfo) error

func (*Manager) UpsertClientInfoDeals

func (m *Manager) UpsertClientInfoDeals(list []*models.ClientInfo) error

func (*Manager) UpsertClientStats

func (m *Manager) UpsertClientStats(list []*models.ClientStats) error

func (*Manager) UpsertDeal

func (m *Manager) UpsertDeal(deals []*models.Deal) error

func (*Manager) UpsertProvider

func (m *Manager) UpsertProvider(list []*models.Provider) error

func (*Manager) UpsertProviderInfo

func (m *Manager) UpsertProviderInfo(info *models.ProviderInfo) error

func (*Manager) UpsertProviderStatsMonthly

func (m *Manager) UpsertProviderStatsMonthly(list []*models.ProviderStatsMonthly) error

func (*Manager) UpsertUserOnline

func (m *Manager) UpsertUserOnline(uo *models.UserStatus) error

func (*Manager) UpsertUserRelation

func (m *Manager) UpsertUserRelation(urs []*models.UserRelation) error

type MetricsClientDetailItem

type MetricsClientDetailItem struct {
	Client       string          `json:"client"`
	Owners       string          `json:"owners"`
	Providers    string          `json:"providers"`
	ProviderNum  int64           `json:"provider_num"`
	RegisterTime *types.UnixTime `json:"register_time"`
}

type MetricsClientOverview

type MetricsClientOverview struct {
	Clients         int64 `json:"clients"`
	TargetClients   int64 `json:"target_clients"`
	ClientsToDealSp int64 `json:"clients_to_deal_sp"`

	IncrClients              int64 `json:"incr_clients"`
	IncrTargetClients        int64 `json:"incr_target_clients"`
	IncrClientsToDealSpMonth int64 `json:"incr_clients_to_deal_sp_month"`
}

type MetricsOverview

type MetricsOverview struct {
	RegisteredProviders int64           `json:"registered_providers"`
	AutoFilledProviders int64           `json:"auto_filled_providers"`
	RegisteredSpRatio   decimal.Decimal `json:"registered_sp_ratio"`

	InternalContacts     int64           `json:"internal_contacts"`
	AverageAccessesDaily decimal.Decimal `json:"average_accesses_daily"`
	TotalAccesses        int64           `json:"total_accesses"`
}

type MetricsSpDetailItem

type MetricsSpDetailItem struct {
	Owner        string          `json:"owner"`
	Providers    string          `json:"providers"`
	NewClients   string          `json:"new_clients"`
	NewClientNum int64           `json:"new_client_num"`
	RegisterTime *types.UnixTime `json:"register_time"`
}

type MetricsSpOverview

type MetricsSpOverview struct {
	AverageRetrievalSuccessRatio decimal.Decimal `json:"average_retrieval_success_ratio"`
	SpsToDealNewClient           int64           `json:"sps_to_deal_new_client"`

	IncrAverageRetrievalSuccessRatio decimal.Decimal `json:"incr_average_retrieval_success_ratio"`
	IncrSpsToDealNewClientMonth      int64           `json:"incr_sps_to_deal_new_client_month"`
}

type OrderParam

type OrderParam struct {
	SortBy string `` /* 208-byte string literal not displayed */
	Order  string `json:"order" form:"order" binding:"oneof=asc desc" example:"desc"`
}

type Partner

type Partner struct {
	Uid          string `json:"uid"`
	Type         string `json:"type"`
	Name         string `json:"name"`
	AddressId    string `json:"address_id"`
	Avatar       string `json:"avatar"`
	Location     string `json:"location"`
	ContactEmail string `json:"contact_email"`
	Slack        string `json:"slack"`
	Github       string `json:"github"`
	Twitter      string `json:"twitter"`
	Description  string `json:"description"`
}

type PartnerStatus

type PartnerStatus struct {
	Uid    string `json:"uid"`
	Online bool   `json:"online"`
}

type Profile

type Profile struct {
	Uid           string `json:"uid"`
	Type          string `json:"type"`
	AddressRobust string `json:"address_robust"`
	AddressId     string `json:"address_id"`
	Name          string `json:"name"`
	Avatar        string `json:"avatar"`
	Location      string `json:"location"`
	ContactEmail  string `json:"contact_email"`
	Slack         string `json:"slack"`
	Github        string `json:"github"`
	Twitter       string `json:"twitter"`
	Description   string `json:"description"`
}

type Provider

type Provider struct {
	Address         string          `json:"address"`
	Region          string          `json:"region"`
	IsoCode         string          `json:"iso_code"`
	RawPower        decimal.Decimal `json:"raw_power"`
	QualityAdjPower decimal.Decimal `json:"quality_adj_power"`

	Price         *string          `json:"price"`
	VerifiedPrice *string          `json:"verified_price"`
	MinPieceSize  *decimal.Decimal `json:"min_piece_size"`
	MaxPieceSize  *decimal.Decimal `json:"max_piece_size"`

	StorageDeals         uint64  `json:"storage_deals" gorm:"column:deal_total"`
	StorageSuccessRate   float64 `json:"storage_success_rate" gorm:"column:deal_success_rate"`
	RetrievalSuccessRate float64 `json:"retrieval_success_rate"`

	FirstDealTime uint64 `json:"first_deal_time"`
	Owner         string `json:"owner"`

	Name            string  `json:"name"`
	ReputationScore int     `json:"reputation_score" gorm:"column:score"`
	ReviewScore     float64 `json:"review_score"`
	Reviews         int     `json:"reviews"`
	AvailableDeals  string  `json:"available_deals"`
	Bandwidth       string  `json:"bandwidth"`
	SealingSpeed    string  `json:"sealing_speed"`
	ParallelDeals   string  `json:"parallel_deals"`
	RenewableEnergy string  `json:"renewable_energy"`
	Certification   string  `json:"certification"`
	IsMember        string  `json:"is_member"`
	Experience      string  `json:"experience"`
}

type ProviderClient

type ProviderClient struct {
	Provider string `json:"provider"`
	Client   string `json:"client"`
}

type ProviderDealFirstTime

type ProviderDealFirstTime struct {
	Provider   string
	StartEpoch abi.ChainEpoch
}

type RangeParam

type RangeParam struct {
	Min *decimal.Decimal `json:"min" form:"min" binding:"omitempty"`
	Max *decimal.Decimal `json:"max" form:"max" binding:"omitempty"`
}

type Review

type Review struct {
	CreatedAt types.UnixTime `json:"created_at"`
	Client    string         `json:"client"`
	Provider  string         `json:"provider"`
	Score     int            `json:"score"`
	Content   string         `json:"content"`
	Title     string         `json:"title"`
}

type ReviewStatsItem

type ReviewStatsItem struct {
	Provider string  `json:"provider"`
	AvgScore float64 `json:"avg_score"`
	Reviews  uint64  `json:"reviews"`
}

type SPOwnerProfile

type SPOwnerProfile struct {
	Profile
	ReputationScore float64 `json:"reputation_score"`
	ReviewScore     float64 `json:"review_score"`
	Reviews         uint64  `json:"reviews"`
}

type UncheckedMessageItem

type UncheckedMessageItem struct {
	Partner string `json:"partner"`
	Number  int64  `json:"number"`
}

type Vcode

type Vcode struct {
	Code       string `json:"code"`        // verification code
	ExpireTime int64  `json:"expire_time"` // expire time
}

func GenerateEmailVcodeToForgetPwd

func GenerateEmailVcodeToForgetPwd(email string, debug bool) (vcode *Vcode)

func GetEmailVcodeToForgetPwd

func GetEmailVcodeToForgetPwd(email string) (vcode *Vcode, exist bool)

Jump to

Keyboard shortcuts

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