models

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRUE  = "true"
	FALSE = "false"

	// Default ...
	DefaultPage                 = 1
	DefaultLimit                = 10
	DefaultLimitIsTotalDataTrue = 20

	// OrderBy ...
	OrderByASC  = "ASC"
	OrderByDESC = "DESC"
)
View Source
const (
	SubjectEmailVerify   = "Verify Your Email Address"
	SubjectPasswordReset = "Reset Your Password"
)
View Source
const (
	Updated = `Updated`
	Deleted = `Deleted`
	Created = `Created`
	Read    = `Read`
)
View Source
const (
	ROOT  = `ROOT`
	ADMIN = `ADMIN`
	USER  = `USER`
)
View Source
const (
	ALL = `ALL`
)
View Source
const (
	QueueInsertLog = "insert_log"
)
View Source
const (
	TimeDurationZero = time.Duration(0) * time.Second
)

Variables

View Source
var (
	IsUserRoleValid = map[string]bool{
		ADMIN: true,
		USER:  true,
	}
)
View Source
var (
	IsValidOrderBy = map[string]bool{
		OrderByASC:  true,
		OrderByDESC: true,
	}
)
View Source
var (
	QueueList = []string{
		QueueInsertLog,
	}
)

Functions

func GenerateKeyCacheForgotPassword

func GenerateKeyCacheForgotPassword(userID uint64, requestID string) string

func GenerateKeyCacheOtp

func GenerateKeyCacheOtp(userID uint64, requestID string) string

func GenerateKeyCacheUserDetail

func GenerateKeyCacheUserDetail(userID uint64) string

func GenerateMessageEmailVerify

func GenerateMessageEmailVerify(userName, otp string, expired time.Duration) string

GenerateMessageEmailVerify generates the message for email verification

func GenerateMessagePasswordReset

func GenerateMessagePasswordReset(userName, otp string, expired time.Duration) string

Types

type BasedFilter

type BasedFilter struct {
	Limit             int    `json:"limit" form:"limit"`
	Offset            int    `json:"offset" form:"offset"`
	Page              int    `json:"page" form:"page"`
	OrderBy           string `json:"order_by" form:"order_by"`
	SortBy            string `json:"sort_by" form:"sort_by"`
	IsNoLimit         bool   `json:"is_no_limit" form:"is_no_limit"`
	IsNotDefaultQuery bool   `json:"is_not_default_query" form:"is_not_default_query"`
	CustomColumns     string `json:"custom_columns" form:"custom_columns"`
}

func (*BasedFilter) DefaultQuery

func (c *BasedFilter) DefaultQuery() BasedFilter

type DefaultModel

type DefaultModel struct {
	CreatedBy uint64    `json:"created_by"`
	CreatedAt time.Time `json:"created_at,omitempty" gorm:"autoCreateTime"`
	UpdatedBy uint64    `json:"updated_by"`
	UpdatedAt time.Time `json:"updated_at,omitempty" gorm:"autoUpdateTime"`
}

type Log

type Log struct {
	ID          uint64       `json:"id" gorm:"primaryKey"`
	Name        string       `json:"name" gorm:"not null"`
	Action      string       `json:"action" gorm:"not null"`
	TableNameID uint64       `json:"table_name_id"`
	TableName   string       `json:"table_name"`
	UserID      uint64       `json:"user_id"`
	LogDateTime time.Time    `json:"log_date_time"`
	User        UserRelation `json:"user" gorm:"ForeignKey:UserID"`
	DefaultModel
}

Log represents the model for an log

func (*Log) BeforeCreate

func (m *Log) BeforeCreate(tx *gorm.DB) (err error)

func (*Log) ToString

func (m *Log) ToString() string

type User

type User struct {
	ID              uint64     `json:"id" gorm:"primaryKey"`
	Name            string     `json:"name" gorm:"not null"`
	Role            string     `json:"role" gorm:"not null;default:'USER'"`
	Username        string     `json:"username" gorm:"not null;uniqueIndex"`
	Email           string     `json:"email" gorm:"not null;uniqueIndex"`
	EmailVerifiedAt *time.Time `json:"email_verified_at"  gorm:"null; default:null"`
	Password        string     `json:"password,omitempty" gorm:"not null"`
	Salt            string     `json:"salt,omitempty" gorm:"not null"`
	DefaultModel
}

User represents the model for an user

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

func (*User) ConvertToResponse

func (u *User) ConvertToResponse()

type UserRelation

type UserRelation struct {
	ID    uint64 `json:"id"`
	Name  string `json:"name"`
	Role  string `json:"role"`
	Email string `json:"email"`
}

func (UserRelation) TableName

func (UserRelation) TableName() string

Jump to

Keyboard shortcuts

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