models

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code struct {
	gorm.Model
	Id        int       `json:"-" gorm:"primaryKey;unique;autoIncrement"`
	Code      string    `json:"code"`
	UserId    int       `json:"-"`
	User      User      `json:"-" gorm:"foreignKey:UserId"`
	Action    KindCode  `json:"-"`
	Data      string    `json:"-"`
	IsUsed    bool      `json:"-"`
	ExpireAt  time.Time `json:"-"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

type CodeRepository

type CodeRepository interface {
	GetById(Id int) (*Code, error)
	GetByCode(value string) (*Code, error)
	GetLastIsActiveCode(UserId int, Action string) (*Code, error)
	Create(code *Code) error
	Update(code *Code) error
	UpdateWithAssociations(code *Code) error
	ExtendExpiration(code *Code) error
	Delete(code *Code) error
}

type KindCode added in v1.0.8

type KindCode string
const (
	Registration  KindCode = "registration"
	ResetPassword KindCode = "resetPassword"
)

func (KindCode) String added in v1.0.8

func (k KindCode) String() string

type KindRole added in v1.0.8

type KindRole string
const (
	CustomerRole KindRole = "customer"
	StaffRole    KindRole = "staff"
)

func (KindRole) String added in v1.0.8

func (k KindRole) String() string

type User

type User struct {
	Id           int       `json:"-" gorm:"primaryKey;unique;autoIncrement"`
	Uuid         uuid.UUID `json:"uuid" gorm:"unique"`
	Email        string    `json:"email" gorm:"unique"`
	PasswordHash string    `json:"-"`
	Role         KindRole  `json:"role"`
	IsActive     bool      `json:"-"`
	GoogleId     string    `json:"-"`
	CreatedAt    time.Time `json:"-"`
	UpdatedAt    time.Time `json:"-"`
}

type UserRepository

type UserRepository interface {
	GetById(Id int) (*User, error)
	GetByUserId(UserId int) (*User, error)
	GetByUuid(Uuid uuid.UUID) (*User, error)
	GetByEmail(Email string) (*User, error)
	GetByGoogleId(GoogleId string) (*User, error)
	Create(user *User) error
	Update(user *User) error
	Delete(user *User) error
}

Jump to

Keyboard shortcuts

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