types

package
v0.0.0-...-3ba1b7b Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Index

Constants

View Source
const (
	CVMBillingStatePending = "Pending"
	CVMBillingStateDone    = "Done"

	CVMCloudProviderTencent = "tencent"
)
View Source
const (
	OauthProviderTypePhone    OauthProviderType = "PHONE"
	OauthProviderTypeEmail    OauthProviderType = "EMAIL"
	OauthProviderTypePassword OauthProviderType = "PASSWORD"

	RoleOwner Role = "OWNER"

	JoinStatusInWorkspace JoinStatus = "IN_WORKSPACE"
)
View Source
const (
	PendingInvoiceStatus   = "PENDING"
	CompletedInvoiceStatus = "COMPLETED"
	RejectedInvoiceStatus  = "REJECTED"
)

Variables

This section is empty.

Functions

func RegionDescriptionJSON

func RegionDescriptionJSON(data RegionDescription) string

func SetUserPhaseGiveAmount

func SetUserPhaseGiveAmount(annotations map[string]string, activityType string, phase string, giveAmount int64) map[string]string

Types

type Account

type Account struct {
	UserUID       uuid.UUID `gorm:"column:userUid;type:uuid;default:gen_random_uuid();primary_key"`
	ActivityBonus int64     `gorm:"column:activityBonus;type:bigint;not null"`
	// Discard EncryptBalance and EncryptDeductionBalance
	EncryptBalance          string    `gorm:"column:encryptBalance;type:text;not null"`
	EncryptDeductionBalance string    `gorm:"column:encryptDeductionBalance;type:text;not null"`
	CreatedAt               time.Time `gorm:"type:timestamp(3) with time zone;default:current_timestamp()"`
	CreateRegionID          string    `gorm:"type:text;not null"`
	Balance                 int64
	DeductionBalance        int64
}

func (Account) TableName

func (Account) TableName() string

type AccountConfig

type AccountConfig struct {
	TaskProcessRegion          string            `json:"taskProcessRegion"`
	FirstRechargeDiscountSteps map[int64]float64 `json:"firstRechargeDiscountSteps"`
	DefaultDiscountSteps       map[int64]float64 `json:"defaultDiscountSteps"`
}

type AccountTransaction

type AccountTransaction struct {
	ID               uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid();primary_key"`
	Type             string    `gorm:"column:type;type:text"`
	UserUID          uuid.UUID `gorm:"column:userUid;type:uuid"`
	DeductionBalance int64     `gorm:"column:deduction_balance;type:bigint"`
	Balance          int64     `gorm:"column:balance;type:bigint"`
	Message          *string   `gorm:"column:message;type:text"`
	CreatedAt        time.Time `gorm:"column:created_at;type:timestamp(3) with time zone;default:current_timestamp()"`
	UpdatedAt        time.Time `gorm:"column:updated_at;type:timestamp(3) with time zone;default:current_timestamp()"`
	BillingID        uuid.UUID `gorm:"column:billing_id;type:uuid"`
}

func (AccountTransaction) TableName

func (AccountTransaction) TableName() string

type Activities

type Activities map[string]*Activity

type Activity

type Activity struct {
	gorm.Model
	ActivityType string `gorm:"uniqueIndex"`
	PhaseOrder   string
	Phases       []Phase
}

TODO the following structures will be deleted

type ActivityType

type ActivityType string
const (
	ActivityTypeFirstRecharge ActivityType = "FIRST_RECHARGE"
)

type CVMBilling

type CVMBilling struct {
	ID           primitive.ObjectID `json:"_id" bson:"_id"`
	InstanceName string             `json:"instanceName"`
	//Namespace    string             `json:"namespace"`
	//VirtualMachinePackageId string           `json:"virtualMachinePackageId"`
	StartAt time.Time `json:"startAt"`
	EndAt   time.Time `json:"endAt"`
	//CloudProvider           CvmCloudProvider `json:"cloudProvider"`
	//SealosUserID       string  `json:"sealosUserId"`
	SealosUserUID      string  `json:"sealosUserUid"`
	SealosRegionUID    string  `json:"sealosRegionUid"`
	SealosRegionDomain string  `json:"sealosRegionDomain"`
	Amount             float64 `json:"amount"`
	Detail             struct {
		Instance float64 `json:"instance"`
		Network  float64 `json:"network"`
		Disk     float64 `json:"disk"`
	}
	State CvmBillingStatus `json:"state"`
}

CVMBilling represents the billing information of a CloudVirtualMachine instance

type ConfigType

type ConfigType string
const AccountConfigType ConfigType = "account"

type Configs

type Configs struct {
	Type ConfigType `json:"type" gorm:"type:varchar(255);not null,primaryKey"`
	Data string     `json:"data" gorm:"type:jsonb"`
}

func (Configs) TableName

func (c Configs) TableName() string

type CvmBillingStatus

type CvmBillingStatus string

type CvmCloudProvider

type CvmCloudProvider string

type GetTransfersReq

type GetTransfersReq struct {
	*UserQueryOpts
	// can be empty to get all transfers
	TransferID string `json:"transferID"`

	// 0: all, 1: in, 2: out
	Type     TransferType `json:"type"`
	LimitReq `json:",inline"`
}

type GetTransfersResp

type GetTransfersResp struct {
	Transfers []Transfer `json:"transfers"`
	LimitResp `json:",inline"`
}

type GiftCode

type GiftCode struct {
	ID           uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid();primary_key"`
	Code         string    `gorm:"column:code;type:text;not null;unique"`
	CreditAmount int64     `gorm:"column:creditAmount;type:bigint;default:0;not null"`
	Used         bool      `gorm:"column:used;type:boolean;default:false;not null"`
	UsedBy       uuid.UUID `gorm:"column:usedBy;type:uuid"`
	UsedAt       time.Time `gorm:"column:usedAt;type:timestamp(3) with time zone"`
	CreatedAt    time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	ExpiredAt    time.Time `gorm:"column:expiredAt;type:timestamp(3) with time zone"`
	Comment      string    `gorm:"column:comment;type:text"`
}

func (GiftCode) TableName

func (GiftCode) TableName() string

type Invoice

type Invoice struct {
	ID          string    `gorm:"type:text;primary_key" json:"id" bson:"id"`
	UserID      string    `gorm:"type:text;not null" json:"userID" bson:"userID"`
	CreatedAt   time.Time `gorm:"type:timestamp(3) with time zone;default:current_timestamp()" bson:"createdAt" json:"createdAt"`
	UpdatedAt   time.Time `gorm:"type:timestamp(3) with time zone;default:current_timestamp()" bson:"updatedAt" json:"updatedAt"`
	Detail      string    `gorm:"type:text;not null" json:"detail" bson:"detail"`
	Remark      string    `gorm:"type:text" json:"remark" bson:"remark"`
	TotalAmount int64     `gorm:"type:bigint;not null" json:"totalAmount" bson:"totalAmount"`
	// Pending, Completed, Rejected
	Status InvoiceStatus `gorm:"type:text;not null" json:"status" bson:"status"`
}

func (Invoice) TableName

func (Invoice) TableName() string

type InvoicePayment

type InvoicePayment struct {
	InvoiceID string `gorm:"type:text"`
	PaymentID string `gorm:"type:text;primary_key"`
	Amount    int64  `gorm:"type:bigint;not null"`
}

func (InvoicePayment) TableName

func (InvoicePayment) TableName() string

type InvoiceStatus

type InvoiceStatus string

type JoinStatus

type JoinStatus string

type LimitReq

type LimitReq struct {
	Page      int `json:"page"`
	PageSize  int `json:"pageSize"`
	TimeRange `json:",inline"`
}

type LimitResp

type LimitResp struct {
	Total     int64 `json:"total"`
	TotalPage int64 `json:"totalPage"`
}

type OauthProvider

type OauthProvider struct {
	UID          uuid.UUID         `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	UserUID      uuid.UUID         `gorm:"column:userUid;type:uuid;not null"`
	ProviderType OauthProviderType `gorm:"column:providerType;type:text;not null"`
	ProviderID   string            `gorm:"column:providerId;type:text;not null"`
	CreatedAt    time.Time         `gorm:"column:createdAt;type:timestamp(3);default:current_timestamp()"`
	UpdatedAt    time.Time         `gorm:"column:updatedAt;type:timestamp(3);default:current_timestamp()"`
	Password     string            `gorm:"type:text"`
}

func (OauthProvider) TableName

func (OauthProvider) TableName() string

type OauthProviderType

type OauthProviderType string

type ObjectStorageTraffic

type ObjectStorageTraffic struct {
	Time   time.Time `json:"time" bson:"time"`
	User   string    `json:"user" bson:"user"`
	Bucket string    `json:"bucket" bson:"bucket"`
	//bytes
	TotalSent int64 `json:"totalSent" bson:"totalSent"`

	//The sent traffic since the last time
	Sent int64 `json:"sent" bson:"sent"`
}

type Payment

type Payment struct {
	ID string `gorm:"type:text;primary_key"`
	PaymentRaw
}

func (Payment) TableName

func (Payment) TableName() string

type PaymentRaw

type PaymentRaw struct {
	UserUID         uuid.UUID `gorm:"column:userUid;type:uuid;not null"`
	RegionUID       uuid.UUID `gorm:"column:regionUid;type:uuid;not null"`
	CreatedAt       time.Time `gorm:"type:timestamp(3) with time zone;default:current_timestamp()"`
	RegionUserOwner string    `gorm:"column:regionUserOwner;type:text;not null"`
	Method          string    `gorm:"type:text;not null"`
	Amount          int64     `gorm:"type:bigint;not null"`
	Gift            int64     `gorm:"type:bigint"`
	TradeNO         string    `gorm:"type:text;unique;not null"`
	// CodeURL is the codeURL of wechatpay
	CodeURL      string       `gorm:"type:text"`
	InvoicedAt   bool         `gorm:"type:boolean;default:false"`
	Remark       string       `gorm:"type:text"`
	ActivityType ActivityType `gorm:"type:text;column:activityType"`
	Message      string       `gorm:"type:text;not null"`
}

type Phase

type Phase struct {
	gorm.Model
	ActivityID       uint `gorm:"index"`
	Name             string
	GiveAmount       int64
	RechargeDiscount RechargeDiscountInfo `gorm:"embedded"`
}

type RechargeDiscount

type RechargeDiscount struct {
	DiscountRates   []float64       `json:"discountRates"`
	DiscountSteps   []int64         `json:"discountSteps"`
	SpecialDiscount map[int64]int64 `json:"specialDiscount" gorm:"type:jsonb"`
}

type RechargeDiscountInfo

type RechargeDiscountInfo struct {
	LimitTimes    int64 `gorm:"default:0"`
	LimitDuration string
	RechargeDiscount
}

type Region

type Region struct {
	UID         uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	DisplayName string    `gorm:"column:displayName;type:text"`
	Location    string    `gorm:"column:location;type:text"`
	Domain      string    `gorm:"column:domain;type:text;not null;unique"`
	Description string    `gorm:"column:description;type:text"`
}

func (Region) TableName

func (Region) TableName() string

type RegionDescription

type RegionDescription struct {
	Provider    string            `json:"provider"`
	Serial      string            `json:"serial"`
	Description map[string]string `json:"description"`
}

type RegionUserCr

type RegionUserCr struct {
	UID       uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	CrName    string    `gorm:"type:text;column:crName;not null;unique"`
	UserUID   uuid.UUID `gorm:"column:userUid;type:uuid;not null"`
	CreatedAt time.Time `gorm:"column:createdAt;type:timestamp(3);default:current_timestamp()"`
	UpdatedAt time.Time `gorm:"column:updatedAt;type:timestamp(3);default:current_timestamp()"`
}

RegionUserCr is located in the region

func (RegionUserCr) TableName

func (RegionUserCr) TableName() string

type Role

type Role string

type Task

type Task struct {
	ID            uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid();primary_key" json:"id"`
	Title         string    `gorm:"column:title;type:text;not null" json:"title"`
	Description   string    `gorm:"column:description;type:text;not null" json:"description"`
	Reward        int64     `gorm:"column:reward;type:bigint;not null" json:"reward"`
	Order         int       `gorm:"column:order;type:integer;not null" json:"order"`
	IsActive      bool      `gorm:"column:isActive;type:boolean;default:true;not null" json:"isActive"`
	IsNewUserTask bool      `gorm:"column:isNewUserTask;type:boolean;default:false;not null" json:"isNewUserTask"`
	TaskType      TaskType  `gorm:"column:taskType;type:TaskType;not null" json:"taskType"`
	CreatedAt     time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp();not null" json:"createdAt"`
	UpdatedAt     time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;not null" json:"updatedAt"`
}

Task represents the Task model in Go with GORM annotations.

func (Task) TableName

func (Task) TableName() string

TableName specifies the table name for GORM

type TaskStatus

type TaskStatus string

TaskStatus represents the TaskStatus enum in Go.

const (
	TaskStatusNotCompleted TaskStatus = "NOT_COMPLETED"
	TaskStatusCompleted    TaskStatus = "COMPLETED"
)

type TaskType

type TaskType string

TaskType represents the TaskType enum in Go.

type TimeRange

type TimeRange struct {
	StartTime time.Time `json:"startTime" bson:"startTime" example:"2021-01-01T00:00:00Z"`
	EndTime   time.Time `json:"endTime" bson:"endTime" example:"2021-12-01T00:00:00Z"`
}

type Transfer

type Transfer struct {
	ID          string    `gorm:"type:text;primary_key"`
	UID         uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	FromUserUID uuid.UUID `gorm:"column:fromUserUid;type:uuid;not null"`
	FromUserID  string    `gorm:"column:fromUserId;type:text;not null"`
	ToUserUID   uuid.UUID `gorm:"column:toUserUid;type:uuid;not null"`
	ToUserID    string    `gorm:"column:toUserId;type:text;not null"`
	Amount      int64     `gorm:"type:bigint;not null"`
	Remark      string    `gorm:"type:text;not null"`
	CreatedAt   time.Time `gorm:"type:timestamp(3) with time zone;default:current_timestamp()"`
}

func (Transfer) TableName

func (Transfer) TableName() string

type TransferType

type TransferType int
const (
	TypeTransferAll TransferType = iota
	TypeTransferIn
	TypeTransferOut
)

type User

type User struct {
	UID       uuid.UUID  `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	CreatedAt time.Time  `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	UpdatedAt time.Time  `gorm:"column:updatedAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	AvatarURI string     `gorm:"column:avatarUri;type:text"`
	Nickname  string     `gorm:"type:text"`
	ID        string     `gorm:"type:text;not null;unique"`
	Name      string     `gorm:"type:text;not null"`
	Status    UserStatus `gorm:"column:status;type:UserStatus;default:'NORMAL_USER'::defaultdb.public.'UserStatus';not null"`
}

func (User) TableName

func (User) TableName() string

type UserActivities

type UserActivities map[string]*UserActivity

type UserActivity

type UserActivity struct {
	gorm.Model
	Name         string
	UserID       uuid.UUID `gorm:"index"`
	CurrentPhase string
	ActivityID   uint `gorm:"index"`
	Phases       []UserPhase
}

type UserPhase

type UserPhase struct {
	gorm.Model
	UserActivityID uuid.UUID `gorm:"index"`
	Name           string
	StartTime      time.Time
	EndTime        time.Time
	RechargeNums   int64
	GiveAmount     int64
}

type UserQueryOpts

type UserQueryOpts struct {
	UID         uuid.UUID
	ID          string
	Namespace   string
	Owner       string
	IgnoreEmpty bool
}

type UserRealNameInfo

type UserRealNameInfo struct {
	ID                  uuid.UUID       `gorm:"column:id;type:uuid;default:gen_random_uuid();primary_key"`
	UserUID             uuid.UUID       `gorm:"column:userUid;type:uuid;unique"`
	RealName            *string         `gorm:"column:realName;type:text"`
	IDCard              *string         `gorm:"column:idCard;type:text"`
	Phone               *string         `gorm:"column:phone;type:text"`
	IsVerified          bool            `gorm:"column:isVerified;type:boolean;default:false"`
	IDVerifyFailedTimes int             `gorm:"column:idVerifyFailedTimes;type:integer;default:0"`
	CreatedAt           time.Time       `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	UpdatedAt           time.Time       `gorm:"column:updatedAt;type:timestamp(3) with time zone;autoUpdateTime"`
	AdditionalInfo      json.RawMessage `gorm:"column:additionalInfo;type:jsonb"`
}

func (UserRealNameInfo) TableName

func (UserRealNameInfo) TableName() string

type UserRechargeDiscount

type UserRechargeDiscount struct {
	DefaultSteps       map[int64]float64 `json:"defaultSteps,omitempty" bson:"defaultSteps,omitempty"`
	FirstRechargeSteps map[int64]float64 `json:"firstRechargeDiscount,omitempty" bson:"firstRechargeDiscount,omitempty"`
}

type UserStatus

type UserStatus string
const (
	UserStatusNormal UserStatus = "NORMAL_USER"
	UserStatusLock   UserStatus = "LOCK_USER"
)

type UserTask

type UserTask struct {
	ID           uuid.UUID  `gorm:"column:id;type:uuid;default:gen_random_uuid();primary_key" json:"id"`
	UserUID      uuid.UUID  `gorm:"column:userUid;type:uuid;not null" json:"userUid"`
	TaskID       uuid.UUID  `gorm:"column:taskId;type:uuid;not null" json:"taskId"`
	Status       TaskStatus `gorm:"column:status;type:TaskStatus;not null" json:"status"`
	RewardStatus TaskStatus `gorm:"column:rewardStatus;type:TaskStatus;not null" json:"rewardStatus"`
	CompletedAt  time.Time  `gorm:"column:completedAt;type:timestamp(3);not null" json:"completedAt"`
	CreatedAt    time.Time  `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp();not null" json:"createdAt"`
	UpdatedAt    time.Time  `gorm:"column:updatedAt;type:timestamp(3) with time zone;not null" json:"updatedAt"`
}

UserTask represents the UserTask model in Go with GORM annotations.

func (UserTask) TableName

func (UserTask) TableName() string

TableName specifies the table name for GORM

type UserWorkspace

type UserWorkspace struct {
	UID          uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	CreatedAt    time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	UpdatedAt    time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	WorkspaceUID uuid.UUID `gorm:"column:workspaceUid;type:uuid;not null"`
	UserCrUID    uuid.UUID `gorm:"column:userCrUid;type:uuid;not null"`
	HandlerUID   uuid.UUID `gorm:"column:handlerUid;type:uuid"`
	Role         Role      `gorm:"type:Role;default:'DEVELOPER'::defaultdb.public.'Role';not null"`
	Status       JoinStatus
	IsPrivate    bool      `gorm:"column:isPrivate;type:boolean;not null"`
	JoinAt       time.Time `gorm:"column:joinAt;type:timestamp(3) with time zone"`
}

func (UserWorkspace) TableName

func (UserWorkspace) TableName() string

type Workspace

type Workspace struct {
	UID         uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
	ID          string    `gorm:"type:text;not null;unique"`
	DisplayName string    `gorm:"column:displayName;type:text;not null"`
	CreatedAt   time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
	UpdatedAt   time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;default:current_timestamp()"`
}

func (Workspace) TableName

func (Workspace) TableName() string

Jump to

Keyboard shortcuts

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