types

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: LGPL-2.1 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	AccessToken  string `json:"access_token,omitempty"`
	TokenType    string `json:"token_type,omitempty"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

AuthToken holds authentication token details with refresh token swagger:model

type AuthUser

type AuthUser struct {
	ID    string
	Name  string
	Email string
	Role  string
}

AuthUser represents data stored in JWT token for authenticated user

type Base

type Base struct {
	// ID of the record
	ID string `json:"id" gorm:"primaryKey"`
	// The time that record is created
	CreatedAt time.Time `json:"created_at"`
	// The latest time that record is updated
	UpdatedAt time.Time `json:"updated_at"`
}

Base contains common fields for all models

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate hook executed by gorm

type Memo

type Memo struct {
	Base
	UserID  string `json:"-"  gorm:"not null"`
	Content string `json:"memo" gorm:"type:text"`
}

Memo represents the memo model swagger:model

type Session

type Session struct {
	ID        string    `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	UserID    string    `json:"user_id"`
	IsBlocked bool      `json:"is_blocked" gorm:"default:false"`
	ExpiresAt time.Time `json:"expires_at" gorm:"type:datetime(3)"`
	IPAddress string    `json:"ip_address"`
	UserAgent string    `json:"user_agent"`

	RefreshToken sql.NullString `json:"-" gorm:"uniqueIndex:uix_users_refresh_token"`

	User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
}

Session represents the session model swagger:model

type Status

type Status int

Status represents the status of user

const (
	UserStatusUnknown Status = iota
	UserStatusActive
	UserStatusBlocked
	UserStatausDeleted
)

cosnt

func (Status) String

func (s Status) String() string

type User

type User struct {
	Base
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Role      string `json:"role"`

	Password  string     `json:"-" gorm:"not null"`
	LastLogin *time.Time `json:"last_login,omitempty" gorm:"type:datetime(3)"`

	Phone           string     `json:"phone" gorm:"uniqueIndex:uix_users_phone"`
	PhoneVerifiedAt *time.Time `json:"phone_verified_at,omitempty" gorm:"type:datetime(3)"`
	OTP             *string    `json:"-" gorm:"varchar(10)"`
	OTPSentAt       *time.Time `json:"-" gorm:"type:datetime(3)"`
	Email           string     `json:"email" gorm:"uniqueIndex:uix_users_email"`
	EmailVerifiedAt *time.Time `json:"email_verified_at,omitempty" gorm:"type:datetime(3)"`

	Status string `json:"status" gorm:"type:varchar(20);default:active"` // active || blocked || deleted
}

User represents the user model swagger:model

Jump to

Keyboard shortcuts

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