domain

package
v0.0.0-...-e98d214 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountTableName      string = "account"
	AccountMailsTableName string = "account_mail_history"
)
View Source
const (
	PhoneTableName    string = "phone"
	OperatorTableName string = "operator"
)
View Source
const ProfileTableName string = "profiles"
View Source
const SiteTableName string = "site"
View Source
const UserTableName string = "users"

Variables

View Source
var ErrInvalidIpAssociation error = errors.New("invalid ip source")

Functions

This section is empty.

Types

type Account

type Account struct {
	Base
	Username string   `json:"username" gorm:"column:username;type:varchar(100);index;not null;" validate:"required,min=2"`
	Password string   `json:"-" gorm:"column:password;type:varchar(100);index;not null;" validate:"required,min=2"`
	SiteID   uint     `json:"-" gorm:"column:site_id;type:bigint;not null;index;" validate:"required,min=1"`
	Site     *Site    `json:"site,omitempty"`
	PhoneID  uint     `json:"-" gorm:"column:phone_id;type:bigint;not null;index;" validate:"required,min=1"`
	Phone    *Phone   `json:"phone,omitempty"`
	MailID   uint     `json:"-" gorm:"column:mail_id;type:bigint;index;default:null;"`
	Mail     *Account `json:"mail,omitempty"`
	UserID   uint     `json:"-" gorm:"column:user_id;type:bigint;not null;index;" validate:"required,min=1"`
	User     *User    `json:"-"`
}

func (*Account) Bind

func (s *Account) Bind(p *dto.AccountInputDTO) error

func (*Account) DecodePass

func (s *Account) DecodePass() string

func (*Account) EncodePass

func (s *Account) EncodePass()

func (Account) TableName

func (Account) TableName() string

func (Account) ToMap

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

type AccountMailHistory

type AccountMailHistory struct {
	Base
	AccountID uint     `json:"-" gorm:"column:account_id;type:bigint;not null;index;" validate:"required,min=1"`
	Account   *Account `json:"account,omitempty"`
	MailID    uint     `json:"-" gorm:"column:mail_id;type:bigint;not null;index;" validate:"required,min=1"`
	Mail      *Account `json:"mail,omitempty"`
}

func (AccountMailHistory) TableName

func (AccountMailHistory) TableName() string

type AccountRepository

type AccountRepository interface {
	GetAccountByID(context.Context, uint, uint) (*Account, error)
	GetAccountsOutputDTO(context.Context, *filter.Filter, uint) (*dto.ItemsOutputDTO, error)
	CreateAccount(context.Context, *dto.AccountInputDTO, uint) (*Account, error)
	UpdateAccount(context.Context, *Account, *dto.AccountInputDTO, uint) (*Account, error)
	DeleteAccount(context.Context, *Account, uint) error
}

type AccountService

type AccountService interface {
	GetAccountByID(context.Context, uint, uint) (*Account, error)
	GetAccountsOutputDTO(context.Context, *filter.Filter, uint) (*dto.ItemsOutputDTO, error)
	CreateAccount(context.Context, *dto.AccountInputDTO, uint) (*Account, error)
	UpdateAccount(context.Context, *Account, *dto.AccountInputDTO, uint) (*Account, error)
	DeleteAccount(context.Context, *Account, uint) error
}

type AuthRepository

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

type AuthResponse

type AuthResponse struct {
	User *User `json:"user"`
	TokensResponse
}

type AuthService

type AuthService interface {
	Login(context.Context, *User, string) (*AuthResponse, error)
	Me(context.Context, string, string, string) (*User, error)
	Refresh(context.Context, *User, string) (*TokensResponse, error)
	GetUserByMail(context.Context, string) (*User, 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 Operator

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

func (*Operator) Bind

func (s *Operator) Bind(p *dto.OperatorInputDTO) error

func (Operator) TableName

func (Operator) TableName() string

func (Operator) ToMap

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

type OperatorRepository

type OperatorRepository interface {
	GetOperatorByID(context.Context, uint) (*Operator, error)
	GetOperatorsOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateOperator(context.Context, *dto.OperatorInputDTO) (*Operator, error)
	UpdateOperator(context.Context, *Operator, *dto.OperatorInputDTO) error
	DeleteOperator(context.Context, *Operator) error
}

type OperatorService

type OperatorService interface {
	GetOperatorByID(context.Context, uint) (*Operator, error)
	GetOperatorsOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateOperator(context.Context, *dto.OperatorInputDTO) (*Operator, error)
	UpdateOperator(context.Context, *Operator, *dto.OperatorInputDTO) error
	DeleteOperator(context.Context, *Operator) 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;"`
}

func (*Permissions) ToMap

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

type Phone

type Phone struct {
	Base
	Number     string    `json:"number" gorm:"column:number;type:varchar(100);unique;index;not null;" validate:"required,min=2"`
	OperatorID uint      `json:"-" gorm:"column:operator_id;type:bigint;not null;index;" validate:"required,min=1"`
	Operator   *Operator `json:"operator,omitempty"`
}

func (*Phone) Bind

func (s *Phone) Bind(p *dto.PhoneInputDTO) error

func (Phone) TableName

func (Phone) TableName() string

func (Phone) ToMap

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

type PhoneRepository

type PhoneRepository interface {
	GetPhoneByID(context.Context, uint) (*Phone, error)
	GetPhonesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreatePhone(context.Context, *dto.PhoneInputDTO) (*Phone, error)
	UpdatePhone(context.Context, *Phone, *dto.PhoneInputDTO) error
	DeletePhone(context.Context, *Phone) error
}

type PhoneService

type PhoneService interface {
	GetPhoneByID(context.Context, uint) (*Phone, error)
	GetPhonesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreatePhone(context.Context, *dto.PhoneInputDTO) (*Phone, error)
	UpdatePhone(context.Context, *Phone, *dto.PhoneInputDTO) error
	DeletePhone(context.Context, *Phone) 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

func (Profile) TableName() string

type ProfileRepository

type ProfileRepository interface {
	GetProfileByID(context.Context, uint) (*Profile, error)
	GetProfilesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateProfile(context.Context, *dto.ProfileInputDTO) (*Profile, error)
	UpdateProfile(context.Context, *Profile, *dto.ProfileInputDTO) error
	DeleteProfile(context.Context, *Profile) error
}

type ProfileService

type ProfileService interface {
	GetProfileByID(context.Context, uint) (*Profile, error)
	GetProfilesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateProfile(context.Context, *dto.ProfileInputDTO) (*Profile, error)
	UpdateProfile(context.Context, *Profile, *dto.ProfileInputDTO) error
	DeleteProfile(context.Context, *Profile) error
}

type Site

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

func (*Site) Bind

func (s *Site) Bind(p *dto.SiteInputDTO) error

func (Site) TableName

func (Site) TableName() string

func (Site) ToMap

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

type SiteRepository

type SiteRepository interface {
	GetSiteByID(context.Context, uint) (*Site, error)
	GetSitesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateSite(context.Context, *dto.SiteInputDTO) (*Site, error)
	UpdateSite(context.Context, *Site, *dto.SiteInputDTO) error
	DeleteSite(context.Context, *Site) error
}

type SiteService

type SiteService interface {
	GetSiteByID(context.Context, uint) (*Site, error)
	GetSitesOutputDTO(context.Context, *filter.Filter) (*dto.ItemsOutputDTO, error)
	CreateSite(context.Context, *dto.SiteInputDTO) (*Site, error)
	UpdateSite(context.Context, *Site, *dto.SiteInputDTO) error
	DeleteSite(context.Context, *Site) error
}

type TokensResponse

type TokensResponse struct {
	AccessToken  string `json:"accesstoken" validate:"jwt"`
	RefreshToken string `json:"refreshtoken" validate:"jwt"`
}

func (*TokensResponse) Validate

func (s *TokensResponse) Validate() error

type User

type User struct {
	Base
	Name      string   `json:"name" gorm:"column:name;type:varchar(90);not null;" validate:"required,min=5"`
	Email     string   `json:"mail" gorm:"column:mail;type:varchar(50);not null;unique;index;" 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;index;" 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,omitempty"`
	Expire    bool     `json:"-" gorm:"-"`
}

func (*User) Bind

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

func (*User) GenerateToken

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

func (User) TableName

func (User) TableName() string

func (*User) ToMap

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

func (*User) ValidatePassword

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

type UserRepository

type UserRepository interface {
	GetUserByID(context.Context, uint) (*User, error)
	GetUsersOutputDTO(context.Context, *filter.UserFilter) (*dto.ItemsOutputDTO, error)
	GetUserByMail(context.Context, string) (*User, error)
	GetUserByToken(context.Context, string) (*User, error)
	CreateUser(context.Context, *dto.UserInputDTO) (*User, error)
	UpdateUser(context.Context, *User, *dto.UserInputDTO) error
	DeleteUser(context.Context, *User) error
	ResetUser(context.Context, *User) error
	PasswordUser(context.Context, *User, *dto.PasswordInputDTO) error
}

type UserService

type UserService interface {
	GetUserByID(context.Context, uint) (*User, error)
	GetUsersOutputDTO(context.Context, *filter.UserFilter) (*dto.ItemsOutputDTO, error)
	GetUserByMail(context.Context, string) (*User, error)
	GetUserByToken(context.Context, string) (*User, error)
	CreateUser(context.Context, *dto.UserInputDTO) (*User, error)
	UpdateUser(context.Context, *User, *dto.UserInputDTO) error
	DeleteUser(context.Context, *User) error
	ResetUser(context.Context, *User) error
	PasswordUser(context.Context, *User, *dto.PasswordInputDTO) error
}

Jump to

Keyboard shortcuts

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