data

package module
v0.0.0-...-028d84e Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB)

Types

type Account

type Account struct {
	gorm.Model
	Name     string
	UUID     string `gorm:"type:varchar(100);primaryKey;"`
	Projects []Project
}

func (*Account) BeforeCreate

func (a *Account) BeforeCreate(tx *gorm.DB) error

type AccountUser

type AccountUser struct {
	AccountID   uint   `gorm:"not null;"`
	UserID      uint   `gorm:"not null;"`
	AccountUUID string `gorm:"not null;"`
	UserUUID    string `gorm:"not null;"`

	Account Account
	User    User
}

type Duration

type Duration struct {
	DType    DurationType
	Duration uint
}

func (*Duration) InMinutes

func (d *Duration) InMinutes() (uint, error)

type DurationType

type DurationType string
const (
	DT_Minutes DurationType = "minutes"
	DT_Hours   DurationType = "hours"
	DT_Days    DurationType = "days"
)

type GormTCPConnectionConfig

type GormTCPConnectionConfig struct {
	// dsn := "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
	UserName string
	Password string
	DBName   string
	Host     string
	Charset  string
	Port     string
}

func (*GormTCPConnectionConfig) OpenMySql

func (c *GormTCPConnectionConfig) OpenMySql() (*gorm.DB, error)

type HP_STATUS

type HP_STATUS string
const (
	HP_STATUS_OK   HP_STATUS = "ok"
	HP_STATUS_DOWN HP_STATUS = "down"
	HP_STATUS_LATE HP_STATUS = "late"
	HP_STATUS_NONE HP_STATUS = "none"
)

type HitEvent

type HitEvent struct {
	gorm.Model
	Body       string    `gorm:"type:text;nullable"`
	StatusRaw  string    `gorm:"type:varchar(25);nullable"`
	Status     HP_STATUS `gorm:"type:varchar(25)"`
	Query      string    `gorm:"type:varchar(200);nullable;"`
	FromIp     string    `gorm:"type:varchar(15)"`
	UserAgent  string    `gorm:"type:varchar(200)"`
	HttpMethod string    `gorm:"type:varchar(10)"`
	HitPointID uint      `gorm:"not null;"`
	HitPoint   HitPoint
}

type HitPoint

type HitPoint struct {
	gorm.Model
	UUID           string `gorm:"type:varchar(100);primaryKey;<-:create"`
	Name           string `gorm:"not null"` // add composite constraint
	Description    string `gorm:"type:text"`
	ProjectID      uint
	Project        Project
	AccountID      uint `gorm:"not null;"`
	Account        Account
	Status         HP_STATUS              `gorm:"type:varchar(20)"`
	Schedule       map[string]interface{} `gorm:"type:json;serializer:json"`
	LastHitEventID uint
	LastHitEventAt *time.Time
}

func (*HitPoint) BeforeCreate

func (h *HitPoint) BeforeCreate(db *gorm.DB) error

func (*HitPoint) Create

func (h *HitPoint) Create(db *gorm.DB) error

func (*HitPoint) GetSchedule

func (h *HitPoint) GetSchedule() (*HitpointSchedule, error)

func (*HitPoint) GetStatus

func (h *HitPoint) GetStatus() (HP_STATUS, error)

type HitpointSchedule

type HitpointSchedule struct {
	GracePeriodInMinute uint
	IntervalInMinute    *uint
	CronSchedule        *string
}

func CreatePeriodicSchedule

func CreatePeriodicSchedule(period Duration, grace Duration) (*HitpointSchedule, error)

func (*HitpointSchedule) Json

func (s *HitpointSchedule) Json() (map[string]interface{}, error)

func (*HitpointSchedule) JsonString

func (s *HitpointSchedule) JsonString() (*string, error)

type Order

type Order struct {
	gorm.Model

	AccountId uint
	Account

	PlanId uint
	Plan   Plan

	Amount      float64
	CurrencyISO string
}

type Plan

type Plan struct {
	gorm.Model
	Name         string `gorm:"not null;"`
	UUID         string `gorm:"type:varchar(100);primaryKey;"`
	DurationType PlanDuration
}

func (*Plan) BeforeCreate

func (p *Plan) BeforeCreate(tx *gorm.DB) error

type PlanDuration

type PlanDuration uint8
const (
	Lifetime PlanDuration = 1
	Monthly  PlanDuration = 2
)

type Project

type Project struct {
	gorm.Model
	Name      string `gorm:"not null;unique;"`
	UUID      string `gorm:"type:varchar(100);primaryKey;"`
	AccountID uint   `gorm:"not null;"`
	Account   Account
}

func (*Project) BeforeCreate

func (proj *Project) BeforeCreate(tx *gorm.DB) error

func (*Project) CreateProject

func (p *Project) CreateProject(user User, db *gorm.DB) error

type Subscription

type Subscription struct {
	gorm.Model
	UUID      string `gorm:"type:varchar(100);primaryKey;"`
	PlanID    uint   `gorm:"not null;"`
	Plan      Plan
	AccountID uint `gorm:"not null;"`
	Account   Account
}

func (*Subscription) BeforeCreate

func (s *Subscription) BeforeCreate(tx *gorm.DB) error

type User

type User struct {
	gorm.Model
	UUID         string `gorm:"type:varchar(100);primaryKey;"`
	Name         string `gorm:"type:varchar(255);not null"`
	Email        string `gorm:"type:varchar(500);not null;unique"`
	PasswordHash string `gorm:"type:varchar(255);not null"`
	IsVerified   bool   `gorm:"not null;"`
}

func AuthenticateUserByEmailPassword

func AuthenticateUserByEmailPassword(db *gorm.DB, email string, password string) (*User, error)

func UserByEmail

func UserByEmail(db *gorm.DB, email string) (*User, error)

func UserById

func UserById(db *gorm.DB, id int) (*User, error)

func (*User) Create

func (user *User) Create(db *gorm.DB, password string) error

func (*User) SetPassword

func (user *User) SetPassword(password string) (err error)

func (*User) VerifyPasswordMatch

func (user *User) VerifyPasswordMatch(password string) error

Jump to

Keyboard shortcuts

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