domain

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ProductTableName string = "products"
View Source
const ProfileTableName string = "profiles"
View Source
const UserTableName string = "users"

Variables

View Source
var I18Messages map[string]*I18nMessages = map[string]*I18nMessages{}

Functions

This section is empty.

Types

type AuthRepository

type AuthRepository interface {
	Login(context.Context, *User) (*AuthResponse, error)
	Me(context.Context, string, string) (*User, error)
	Refresh(context.Context, *User) (*AuthResponse, error)
}

type AuthResponse

type AuthResponse struct {
	User         *User  `json:"user"`
	AccessToken  string `json:"accesstoken" validate:"jwt"`
	RefreshToken string `json:"refreshtoken" validate:"jwt"`
}

func (*AuthResponse) Validate added in v0.0.4

func (s *AuthResponse) Validate() error

type AuthService

type AuthService interface {
	Login(context.Context, *User) (*AuthResponse, error)
	Me(context.Context, string, string) (*User, error)
	Refresh(context.Context, *User) (*AuthResponse, error)
}

type Base

type Base struct {
	Id        uint      `json:"id" gorm:"primarykey"`
	CreatedAt time.Time `json:"-" gorm:"autoCreateTime"`
	UpdatedAt time.Time `json:"-" gorm:"autoUpdateTime"`
}

type I18nMessages

type I18nMessages struct {
	ErrGeneric            error
	ErrPassUnmatch        error
	ErrUnauthorized       error
	ErrInvalidId          error
	ErrExpiredToken       error
	ErrInvalidToken       error
	ErrManyRequest        error
	ErrMissingToken       error
	ErrUserHasPass        error
	ErrIncorrectPassword  error
	ErrDisabledUser       error
	ErrorNonexistentRoute error
	ErrUndefinedColumn    error

	ErrProfileUsed       error
	ErrProfileNotFound   error
	ErrProfileRegistered error

	ErrProductUsed       error
	ErrProductNotFound   error
	ErrProductRegistered error

	ErrUserUsed       error
	ErrUserNotFound   error
	ErrUserRegistered error
}

type Permissions

type Permissions struct {
	Id            uint `json:"-" gorm:"primarykey"`
	ProfileID     uint `json:"-" gorm:"column:profile_id;unique;"`
	UserModule    bool `json:"user_module" gorm:"column:user;type:bool;not null;"`
	ProfileModule bool `json:"profile_module" gorm:"column:profile;type:bool;not null;"`
	ProductModule bool `json:"product_module" gorm:"column:product;type:bool;not null;"`
}

func (*Permissions) ToMap

func (s *Permissions) ToMap() *map[string]interface{}

type Product added in v0.0.2

type Product struct {
	Base
	Name string `json:"name" gorm:"column:name;type:varchar(100);unique;index;not null;" validate:"required,min=2"`
}

func (*Product) Bind added in v0.0.2

func (s *Product) Bind(p *dto.ProductInputDTO) error

func (Product) TableName added in v0.0.8

func (Product) TableName() string

func (Product) ToMap added in v0.0.7

func (s Product) ToMap() map[string]interface{}

type ProductRepository added in v0.0.2

type ProductRepository interface {
	GetProducts(context.Context, *gormhelper.GORMFilter, *gormhelper.GORMLoad) (*[]Product, error)
	CountProducts(context.Context, *gormhelper.GORMFilter) (int64, error)
	GetProduct(context.Context, uint, *gormhelper.GORMLoad) (*Product, error)
	GetProductWhere(context.Context, string, *gormhelper.GORMLoad) (*Product, error)
	CreateProduct(context.Context, *dto.ProductInputDTO) (uint, error)
	UpdateProduct(context.Context, *Product, *dto.ProductInputDTO) error
	DeleteProduct(context.Context, *Product) error
}

type ProductService added in v0.0.2

type ProductService interface {
	GetProducts(context.Context, *gormhelper.GORMFilter, *gormhelper.GORMLoad) (*[]Product, error)
	CountProducts(context.Context, *gormhelper.GORMFilter) (int64, error)
	GetProduct(context.Context, uint, *gormhelper.GORMLoad) (*Product, error)
	GetProductWhere(context.Context, string, *gormhelper.GORMLoad) (*Product, error)
	CreateProduct(context.Context, *dto.ProductInputDTO) (uint, error)
	UpdateProduct(context.Context, *Product, *dto.ProductInputDTO) error
	DeleteProduct(context.Context, *Product) error
}

type Profile

type Profile struct {
	Base
	Name        string      `json:"name" gorm:"column:name;type:varchar(100);unique;not null;" validate:"required,min=4"`
	Permissions Permissions `json:"permissions" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func (*Profile) Bind

func (s *Profile) Bind(p *dto.ProfileInputDTO) error

func (Profile) TableName added in v0.0.8

func (Profile) TableName() string

type ProfileRepository

type ProfileRepository interface {
	GetProfiles(context.Context, *gormhelper.GORMFilter, *gormhelper.GORMLoad) (*[]Profile, error)
	CountProfiles(context.Context, *gormhelper.GORMFilter) (int64, error)
	GetProfile(context.Context, uint, *gormhelper.GORMLoad) (*Profile, error)
	GetProfileWhere(context.Context, string, *gormhelper.GORMLoad) (*Profile, error)
	CreateProfile(context.Context, *dto.ProfileInputDTO) (uint, error)
	UpdateProfile(context.Context, *Profile, *dto.ProfileInputDTO) error
	DeleteProfile(context.Context, *Profile) error
}

type ProfileService

type ProfileService interface {
	GetProfiles(context.Context, *gormhelper.GORMFilter, *gormhelper.GORMLoad) (*[]Profile, error)
	CountProfiles(context.Context, *gormhelper.GORMFilter) (int64, error)
	GetProfile(context.Context, uint, *gormhelper.GORMLoad) (*Profile, error)
	GetProfileWhere(context.Context, string, *gormhelper.GORMLoad) (*Profile, error)
	CreateProfile(context.Context, *dto.ProfileInputDTO) (uint, error)
	UpdateProfile(context.Context, *Profile, *dto.ProfileInputDTO) error
	DeleteProfile(context.Context, *Profile) error
}

type User

type User struct {
	Base
	Name      string   `json:"name" gorm:"column:name;type:varchar(200);not null;" validate:"required,min=5"`
	Email     string   `json:"email" gorm:"column:email;type:varchar(320);unique;index;not null;" validate:"required,email"`
	Status    bool     `json:"status" gorm:"column:status;type:bool;not null;"`
	New       bool     `json:"new" gorm:"column:new;type:bool;not null;"`
	ProfileID uint     `json:"-" gorm:"column:profile_id;type:bigint;not null;" validate:"required,min=1"`
	Token     *string  `json:"-" gorm:"column:token;type:varchar(255);unique;index"`
	Password  *string  `json:"-" gorm:"column:password;type:varchar(255);"`
	Profile   *Profile `json:"profile"`
}

func (*User) Bind

func (s *User) Bind(u *dto.UserInputDTO) error

func (*User) GenerateToken

func (u *User) GenerateToken(expire string, originalKey string) (string, error)

func (User) TableName added in v0.0.8

func (User) TableName() string

func (*User) ToMap

func (u *User) ToMap() *map[string]interface{}

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) bool

Jump to

Keyboard shortcuts

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