dao

package
v0.0.0-...-8ed7984 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationStatusCreated = iota + 1
	ApplicationStatusFailed
	ApplicationStatusSendEmailFailed
	ApplicationStatusFinished
)
View Source
const (
	FullNodeInfoKeyExpiration = 0
	FullNodeInfoKey           = "TITAN::FULL_NODE_INFO"
)

Variables

View Source
var (
	// DB reference to database
	DB *sqlx.DB
	// RedisCache  redis caching instance
	RedisCache *redis.Client
)
View Source
var ErrNoRow = fmt.Errorf("no matching row found")

Functions

func AddAppVersion

func AddAppVersion(ctx context.Context, appVer *model.AppVersion) error

func AddApplication

func AddApplication(ctx context.Context, application *model.Application) error

func AddApplicationResult

func AddApplicationResult(ctx context.Context, result []*model.ApplicationResult) error

func AddAssets

func AddAssets(ctx context.Context, assets []*model.Asset) error

func AddFilStorages

func AddFilStorages(ctx context.Context, storages []*model.FilStorage) error

func AddLoginLog

func AddLoginLog(ctx context.Context, log *model.LoginLog) error

func AddOperationLog

func AddOperationLog(ctx context.Context, log *model.OperationLog) error

func AddSignature

func AddSignature(ctx context.Context, signature *model.Signature) error

func AddStorageProvider

func AddStorageProvider(ctx context.Context, sp *model.StorageProvider) error

func AddStorageStats

func AddStorageStats(ctx context.Context, stats []*model.StorageStats) error

func AddSubscription

func AddSubscription(ctx context.Context, subscription *model.Subscription) error

func AddUserSecret

func AddUserSecret(ctx context.Context, userSecret *model.UserSecret) error

func AddWithdrawRequest

func AddWithdrawRequest(ctx context.Context, withdraw *model.Withdraw) error

func BulkAddDeviceInfo

func BulkAddDeviceInfo(ctx context.Context, deviceInfos []*model.DeviceInfo) error

func BulkInsertOrUpdateDeviceStatus

func BulkInsertOrUpdateDeviceStatus(ctx context.Context, deviceInfos []*model.DeviceInfo) error

func BulkUpdateDeviceInfo

func BulkUpdateDeviceInfo(ctx context.Context, deviceInfos []*model.DeviceInfo) error

func BulkUpdateUserReward

func BulkUpdateUserReward(ctx context.Context, users []*model.User) error

func BulkUpsertDeviceInfo

func BulkUpsertDeviceInfo(ctx context.Context, deviceInfos []*model.DeviceInfo) error

func BulkUpsertDeviceInfoDaily

func BulkUpsertDeviceInfoDaily(ctx context.Context, dailyInfos []*model.DeviceInfoDaily) error

func BulkUpsertDeviceInfoHours

func BulkUpsertDeviceInfoHours(ctx context.Context, hourInfos []*model.DeviceInfoHour) error

func BulkUpsertStorageHours

func BulkUpsertStorageHours(ctx context.Context, userInfos []*model.UserInfo) error

func CacheFullNodeInfo

func CacheFullNodeInfo(ctx context.Context, fullNodeInfo *model.FullNodeInfo) error

func CacheMapInfo

func CacheMapInfo(ctx context.Context, mapInfo []*MapInfo, lang model.Language) error

func ContactIPLocation

func ContactIPLocation(loc model.Location, lang model.Language) string

func CountAssets

func CountAssets(ctx context.Context) ([]*model.StorageStats, error)

func CountFilStorage

func CountFilStorage(ctx context.Context, cid string) (int64, error)

func CountRetrievalEvent

func CountRetrievalEvent(ctx context.Context, nodeId string) error

func CountStorageStats

func CountStorageStats(ctx context.Context) (*model.StorageSummary, error)

func CountUploadTraffic

func CountUploadTraffic(ctx context.Context, nodeId string) error
func CreateLink(ctx context.Context, link *model.Link) error

func CreateRetrievalEvents

func CreateRetrievalEvents(ctx context.Context, events []*model.RetrievalEvent) error

func CreateUser

func CreateUser(ctx context.Context, user *model.User) error

func DeleteDeviceInfoHourHistory

func DeleteDeviceInfoHourHistory(ctx context.Context, before time.Time) error

func GetAllDeviceUserIdFromCache

func GetAllDeviceUserIdFromCache(ctx context.Context, areaId string) (map[string]string, error)

func GetAllSignInfo

func GetAllSignInfo() ([]model.SignInfo, error)

func GetAppVersion

func GetAppVersion(ctx context.Context, version string, platform string, lang model.Language) (*model.AppVersion, error)

func GetApplicationAmount

func GetApplicationAmount(ctx context.Context, option QueryOption) (int64, error)

func GetApplicationList

func GetApplicationList(ctx context.Context, status []int) ([]*model.Application, error)

func GetApplicationResults

func GetApplicationResults(ctx context.Context, applicationID int64) ([]*model.ApplicationResult, error)

func GetApplicationsByPage

func GetApplicationsByPage(ctx context.Context, option QueryOption) ([]*model.Application, int64, error)

func GetAreaCount

func GetAreaCount(ctx context.Context, deviceIds []string) (int64, error)

func GetAssetByCID

func GetAssetByCID(ctx context.Context, cid string) (*model.Asset, error)

func GetAssetList

func GetAssetList(ctx context.Context, deviceIds []string, lang model.Language, option QueryOption) ([]*model.DeviceInfo, error)

func GetAssetsByEmptyPath

func GetAssetsByEmptyPath(ctx context.Context) ([]*model.Asset, int64, error)

func GetCacheFullNodeInfo

func GetCacheFullNodeInfo(ctx context.Context) (*model.FullNodeInfo, error)

func GetDeviceDistribution

func GetDeviceDistribution(ctx context.Context, lang model.Language) ([]*model.DeviceDistribution, error)

func GetDeviceInfo

func GetDeviceInfo(ctx context.Context, deviceId string) (*model.DeviceInfo, error)

func GetDeviceInfoByDeviceId

func GetDeviceInfoByDeviceId(ctx context.Context, cond *model.DeviceInfoDaily, option QueryOption) ([]*model.DeviceInfoDaily, int64, error)

func GetDeviceInfoByID

func GetDeviceInfoByID(ctx context.Context, deviceID string) (*model.DeviceInfo, error)

func GetDeviceInfoById

func GetDeviceInfoById(ctx context.Context, deviceId string) model.DeviceInfo

func GetDeviceInfoDailyByPage

func GetDeviceInfoDailyByPage(ctx context.Context, cond *model.DeviceInfoDaily, option QueryOption) ([]*model.DeviceInfoDaily, int64, error)

func GetDeviceInfoList

func GetDeviceInfoList(ctx context.Context, cond *model.DeviceInfo, option QueryOption) ([]*model.DeviceInfo, int64, error)

func GetDeviceInfoListByKey

func GetDeviceInfoListByKey(ctx context.Context, cond *model.DeviceInfo, option QueryOption) ([]*model.DeviceInfo, int64, error)

func GetDeviceProfileFromCache

func GetDeviceProfileFromCache(ctx context.Context, deviceId string) (map[string]string, error)

func GetDeviceUserIdFromCache

func GetDeviceUserIdFromCache(ctx context.Context, deviceId, areaId string) (string, error)

func GetFullNodeInfoList

func GetFullNodeInfoList(ctx context.Context, cond *model.FullNodeInfo, option QueryOption) ([]*model.FullNodeInfo, int64, error)

func GetIdIfExist

func GetIdIfExist(ctx context.Context, nodeId string) bool

func GetInfoByMinerID

func GetInfoByMinerID(minerID string) (model.SignInfo, error)

func GetLastStorageStats

func GetLastStorageStats(ctx context.Context) (*model.StorageStats, error)

func GetLatestAppVersion

func GetLatestAppVersion(ctx context.Context, platform string, lang model.Language) (model.AppVersion, error)

func GetLatestAsset

func GetLatestAsset(ctx context.Context) (*model.Asset, error)

func GetLocationInfoByIp

func GetLocationInfoByIp(ctx context.Context, ip string, out *model.Location, lang model.Language) error

func GetLoginLocation

func GetLoginLocation(ctx context.Context, userId string) string
func GetLongLink(ctx context.Context, cid string) string

func GetNodesInfo

func GetNodesInfo(ctx context.Context, option QueryOption) (int64, []model.NodesInfo, error)

func GetOnlineIPCountsFromCache

func GetOnlineIPCountsFromCache(ctx context.Context, ip string) (int64, error)

func GetPeakBandwidth

func GetPeakBandwidth(ctx context.Context, userId string) (int64, error)

func GetQueryDataList

func GetQueryDataList(sqlClause string, args ...interface{}) ([]map[string]string, error)

func GetReferralList

func GetReferralList(ctx context.Context, username string, option QueryOption) (int64, []*model.InviteFrensRecord, error)

func GetRetrievalEventsFromDeviceByPage

func GetRetrievalEventsFromDeviceByPage(ctx context.Context, cond *model.DeviceInfoHour, option QueryOption) ([]*model.DeviceInfoHour, int64, error)

func GetRewardStatementByDeviceID

func GetRewardStatementByDeviceID(ctx context.Context, deviceId string) (*model.RewardStatement, error)

func GetSecretKey

func GetSecretKey(ctx context.Context, key string) (*model.UserSecret, error)
func GetShortLink(ctx context.Context, link string) string

func GetSignatureByHash

func GetSignatureByHash(ctx context.Context, hash string) (*model.Signature, error)

func GetSignatureByNodeId

func GetSignatureByNodeId(ctx context.Context, nodeId string) (*model.Signature, error)

func GetStorageProvider

func GetStorageProvider(ctx context.Context, providerID string) (*model.StorageProvider, error)

func GetSumUserDeviceReward

func GetSumUserDeviceReward(ctx context.Context) ([]*model.User, error)

func GetUnfinishedEvent

func GetUnfinishedEvent(ctx context.Context) ([]string, error)

func GetUserByRefCode

func GetUserByRefCode(ctx context.Context, refCode string) (*model.User, error)

func GetUserByUsername

func GetUserByUsername(ctx context.Context, username string) (*model.User, error)

func GetUserIds

func GetUserIds(ctx context.Context) ([]string, error)

func GetUserIncome

func GetUserIncome(cond *model.DeviceInfo, option QueryOption) (map[string]map[string]interface{}, error)

func GetUsersReferrer

func GetUsersReferrer(ctx context.Context, username string) (*model.User, error)

func GetWithdrawRecordList

func GetWithdrawRecordList(ctx context.Context, username string, option QueryOption) (int64, []*model.Withdraw, error)

func HandleMapInfo

func HandleMapInfo(infos []*model.DeviceInfo, lang model.Language) []map[string]interface{}

func Init

func Init(cfg *config.Config) error

func ListFilStorages

func ListFilStorages(ctx context.Context, path string, option QueryOption) ([]*model.FilStorage, int64, error)

func ListLoginLog

func ListLoginLog(ctx context.Context, option QueryOption) ([]*model.LoginLog, int64, error)

func ListOperationLog

func ListOperationLog(ctx context.Context, option QueryOption) ([]*model.OperationLog, int64, error)

func ListStorageStats

func ListStorageStats(ctx context.Context, projectId int64, opts QueryOption) ([]*model.StorageStats, int64, error)

func OnlineIPCounts

func OnlineIPCounts(ctx context.Context) (map[string]interface{}, error)

func QueryMaxDeviceDailyInfo

func QueryMaxDeviceDailyInfo(ctx context.Context, deviceIds []string, start, end string) (map[string]*model.DeviceInfoDaily, error)

func ReplaceSignInfo

func ReplaceSignInfo(info *model.SignInfo) error

func ResetPassword

func ResetPassword(ctx context.Context, passHash, username string) error

func SetDeviceProfileFromCache

func SetDeviceProfileFromCache(ctx context.Context, deviceId string, data map[string]string) error

func SetDeviceUserIdToCache

func SetDeviceUserIdToCache(ctx context.Context, deviceId, userId, areaId string) error

func SetMultipleDeviceUserIdToCache

func SetMultipleDeviceUserIdToCache(ctx context.Context, areaId string, keyVal map[string]string) error

func SetOnlineIPCountsToCache

func SetOnlineIPCountsToCache(ctx context.Context, data map[string]interface{}) error

func SumDeviceDailyBeforeDate

func SumDeviceDailyBeforeDate(ctx context.Context, deviceIds []string, end string) (map[string]*model.DeviceInfoDaily, error)

func SumFilStorage

func SumFilStorage(ctx context.Context) (int64, error)

func SumFullNodeInfoFromDeviceInfo

func SumFullNodeInfoFromDeviceInfo(ctx context.Context) (*model.FullNodeInfo, error)

func SumSystemInfo

func SumSystemInfo(ctx context.Context) (*model.SystemInfo, error)

func SumUserDeviceReward

func SumUserDeviceReward(ctx context.Context) (map[string]int64, error)

func SumUserReferralReward

func SumUserReferralReward(ctx context.Context) ([]*model.User, error)

func SumUserReferralReward2

func SumUserReferralReward2(ctx context.Context) (map[string]float64, error)

func SumUserReferralReward3

func SumUserReferralReward3(ctx context.Context) (map[string]float64, error)

func TranslateIPLocation

func TranslateIPLocation(ctx context.Context, info *model.DeviceInfo, lang model.Language)

func UpdateAppVersion

func UpdateAppVersion(ctx context.Context, appVer *model.AppVersion) error

func UpdateApplicationStatus

func UpdateApplicationStatus(ctx context.Context, id int64, status int) error

func UpdateAssetEvent

func UpdateAssetEvent(ctx context.Context, cid string, event int) error

func UpdateAssetPath

func UpdateAssetPath(ctx context.Context, cid string, path string) error

func UpdateDeviceInfoDailyUser

func UpdateDeviceInfoDailyUser(ctx context.Context, deviceId, userId string) error

func UpdateDeviceName

func UpdateDeviceName(ctx context.Context, deviceInfo *model.DeviceInfo) error

func UpdateDownloadCount

func UpdateDownloadCount(ctx context.Context, deviceInfo *model.DeviceInfo) error

func UpdateSignature

func UpdateSignature(ctx context.Context, signature, nodeId, areaId, hash string) error

func UpdateTotalDownload

func UpdateTotalDownload(ctx context.Context, deviceInfo *model.DeviceInfo) error

func UpdateUserDeviceInfo

func UpdateUserDeviceInfo(ctx context.Context, deviceInfo *model.DeviceInfo) error

func UpdateUserWalletAddress

func UpdateUserWalletAddress(ctx context.Context, username, address string) error

func UpsertFullNodeInfo

func UpsertFullNodeInfo(ctx context.Context, fullNodeInfo *model.FullNodeInfo) error

func UpsertLocationInfo

func UpsertLocationInfo(ctx context.Context, out *model.Location, lang model.Language) error

func UpsertSystemInfo

func UpsertSystemInfo(ctx context.Context, systemInfo *model.SystemInfo) error

Types

type ActiveInfoOut

type ActiveInfoOut struct {
	DeviceId     string `db:"device_id" json:"device_id"`
	ActiveStatus string `db:"active_status" json:"active_status"`
	Secret       string `db:"secret" json:"secret"`
}

func GetDeviceActiveInfoList

func GetDeviceActiveInfoList(ctx context.Context, cond *model.DeviceInfo, option QueryOption) ([]*ActiveInfoOut, int64, error)

type CacheStatistics

type CacheStatistics struct {
	Date       string  `json:"date" db:"date"`
	BlockCount float64 `json:"block_count" db:"block_count"`
}

func GetCacheInfoDaysList

func GetCacheInfoDaysList(ctx context.Context, where string, option QueryOption) ([]*CacheStatistics, error)

func GetCacheInfoHourList

func GetCacheInfoHourList(ctx context.Context, where string, option QueryOption) ([]*CacheStatistics, error)

func QueryCacheDaily

func QueryCacheDaily(deviceID, startTime, endTime string) []*CacheStatistics

func QueryCacheHour

func QueryCacheHour(deviceID, startTime, endTime string) []*CacheStatistics

type DeviceStatistics

type DeviceStatistics struct {
	Date              string  `json:"date" db:"date"`
	NatRatio          float64 `json:"nat_ratio" db:"nat_ratio"`
	DiskUsage         float64 `json:"disk_usage" db:"disk_usage"`
	DiskSpace         float64 `json:"disk_space" db:"disk_space"`
	Latency           float64 `json:"latency" db:"latency"`
	PkgLossRatio      float64 `json:"pkg_loss_ratio" db:"pkg_loss_ratio"`
	Income            float64 `json:"income" db:"income"`
	OnlineTime        float64 `json:"online_time" db:"online_time"`
	BandwidthUp       float64 `db:"bandwidth_up" json:"bandwidth_up"`
	BandwidthDown     float64 `db:"bandwidth_down" json:"bandwidth_down"`
	UpstreamTraffic   float64 `json:"upstream_traffic" db:"upstream_traffic"`
	DownstreamTraffic float64 `json:"downstream_traffic" db:"downstream_traffic"`
	RetrievalCount    float64 `json:"retrieval_count" db:"retrieval_count"`
	BlockCount        float64 `json:"block_count" db:"block_count"`
	NodeCount         float64 `json:"node_count" db:"node_count"`
}

func GetDeviceHourlyIncome

func GetDeviceHourlyIncome(ctx context.Context, nodeId string, option QueryOption) ([]*DeviceStatistics, error)

func GetDeviceInfoDailyList

func GetDeviceInfoDailyList(ctx context.Context, cond *model.DeviceInfoDaily, option QueryOption) ([]*DeviceStatistics, error)

func GetDeviceInfoDailyListAppendDays

func GetDeviceInfoDailyListAppendDays(ctx context.Context, cond *model.DeviceInfoDaily, option QueryOption) ([]*DeviceStatistics, error)

func GetDeviceInfoHourList

func GetDeviceInfoHourList(ctx context.Context, cond *model.DeviceInfoHour, option QueryOption) ([]*DeviceStatistics, error)

func GetLatestDeviceStat

func GetLatestDeviceStat(ctx context.Context, deviceId string, start string) (DeviceStatistics, error)

func GetNodesInfoDailyList

func GetNodesInfoDailyList(ctx context.Context, cond *model.DeviceInfoDaily, option QueryOption) ([]*DeviceStatistics, error)

type FullNodeDaysInfo

type FullNodeDaysInfo struct {
	Date                     string  `json:"date" db:"date"`
	TotalNodeCount           int64   `db:"total_node_count" json:"total_node_count"`
	OnlineNodeCount          int64   `db:"online_node_count" json:"online_node_count"`
	SPNodeCount              int64   `db:"sp_node_count" json:"sp_node_count"`
	L1NodeCount              int64   `db:"l1_count" json:"l1_count"`
	OnlineL1NodeCount        int64   `db:"online_l1_count" json:"online_l1_count"`
	L2NodeCount              int64   `db:"l2_count" json:"l2_count"`
	OnlineL2NodeCount        int64   `db:"online_l2_count" json:"online_l2_count"`
	TUpstreamFileCount       int64   `db:"t_upstream_file_count" json:"t_upstream_file_count"`
	TotalStorage             float64 `db:"total_storage" json:"total_storage"`
	StorageUsed              float64 `db:"storage_used" json:"storage_used"`
	TotalUpstreamBandwidth   float64 `db:"total_upstream_bandwidth" json:"total_upstream_bandwidth"`
	TotalDownstreamBandwidth float64 `db:"total_downstream_bandwidth" json:"total_downstream_bandwidth"`
}

func GetNodesDaysList

func GetNodesDaysList(ctx context.Context, option QueryOption) ([]*FullNodeDaysInfo, error)

func QueryNodesDailyInfo

func QueryNodesDailyInfo(startTime, endTime string) []*FullNodeDaysInfo

type MapInfo

type MapInfo struct {
	Name     string    `json:"name"`
	NodeType string    `json:"nodeType"`
	Ip       string    `json:"ip"`
	Value    []float64 `json:"value"`
}

func GetDeviceMapInfo

func GetDeviceMapInfo(ctx context.Context, lang model.Language, deviceId string) ([]*MapInfo, error)

func GetMapInfoFromCache

func GetMapInfoFromCache(ctx context.Context, lang model.Language) ([]*MapInfo, error)

type QueryOption

type QueryOption struct {
	Page       int            `json:"page"`
	PageSize   int            `json:"page_size"`
	Order      string         `json:"order"`
	OrderField string         `json:"order_field"`
	StartTime  string         `json:"start_time"`
	EndTime    string         `json:"end_time" `
	UserID     string         `json:"user_id"`
	NotBound   string         `json:"not_bound"`
	Lang       model.Language `json:"-"`
}

func OptionHandle

func OptionHandle(startTime, endTime string) QueryOption

type UserDeviceProfile

type UserDeviceProfile struct {
	CumulativeProfit float64 `json:"cumulative_profit" db:"cumulative_profit"`
	YesterdayProfit  float64 `json:"yesterday_profit" db:"yesterday_profit"`
	TodayProfit      float64 `json:"today_profit" db:"today_profit"`
	SevenDaysProfit  float64 `json:"seven_days_profit" db:"seven_days_profit"`
	MonthProfit      float64 `json:"month_profit" db:"month_profit"`
	NodeType         *int    `json:"node_type" db:"node_type"`
	TotalNum         int64   `json:"total_num" db:"total_num"`
	OnlineNum        int64   `json:"online_num" db:"online_num"`
	OfflineNum       int64   `json:"offline_num" db:"offline_num"`
	AbnormalNum      int64   `json:"abnormal_num" db:"abnormal_num"`
	TotalBandwidth   float64 `json:"total_bandwidth" db:"total_bandwidth"`
}

func CountUserDeviceInfo

func CountUserDeviceInfo(ctx context.Context, userID string) (*UserDeviceProfile, error)

type UserInfoRes

type UserInfoRes struct {
	Date           string `json:"date" db:"date"`
	TotalBandwidth int64  `db:"total_bandwidth"`
	PeakBandwidth  int64  `db:"peak_bandwidth"`
	DownloadCount  int64  `db:"download_count"`
}

func GetStorageInfoDaysList

func GetStorageInfoDaysList(ctx context.Context, userId string, option QueryOption) ([]*UserInfoRes, error)

func GetStorageInfoHourList

func GetStorageInfoHourList(ctx context.Context, userId string, option QueryOption) ([]*UserInfoRes, error)

Jump to

Keyboard shortcuts

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