models

package
v0.0.0-...-7da98de Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserHexPassword = false
)

Functions

func OnUserHexPassword

func OnUserHexPassword()

Types

type Auditor

type Auditor struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`
	Content   string    `orm:"type(text)"  valid:"Required;MaxSize(300)" form:""`

	Tenant *Tenant `orm:"null;rel(fk);on_delete(do_nothing)" valid:""`
	User   *User   `orm:"null;rel(fk);on_delete(do_nothing)"`

	Session *db.Session `orm:"-" inject:""`
}

func NewAuditor

func NewAuditor(session *db.Session) *Auditor

func NewAuditorWithTenant

func NewAuditorWithTenant(tenant *Tenant) *Auditor

func NewAuditorWithTenantAndContent

func NewAuditorWithTenantAndContent(tenant *Tenant, content string) *Auditor

func (*Auditor) IsPersisted

func (this *Auditor) IsPersisted() bool

func (*Auditor) List

func (this *Auditor) List() (*[]*Auditor, error)

func (*Auditor) ListByTenant

func (this *Auditor) ListByTenant(tenant *Tenant) (*[]*Auditor, error)

func (*Auditor) LoadRelated

func (this *Auditor) LoadRelated(entity *Auditor)

func (*Auditor) TableName

func (this *Auditor) TableName() string

type Cidade

type Cidade struct {
	Id     int64   `form:"-" json:",string,omitempty"`
	Nome   string  `orm:"size(100)"  valid:"Required;MaxSize(100)" form:""`
	Estado *Estado `orm:"rel(fk);on_delete(do_nothing)" valid:"Required;" form:""`

	Session *db.Session `orm:"-" json:"-" inject:""`
}

func NewCidade

func NewCidade(session *db.Session) *Cidade

func (*Cidade) FindByNameAndEstado

func (this *Cidade) FindByNameAndEstado(nome string, estado *Estado) (*Cidade, error)

func (*Cidade) FindByNameAndEstadoUf

func (this *Cidade) FindByNameAndEstadoUf(nome string, uf string) (*Cidade, error)

func (*Cidade) IsPersisted

func (this *Cidade) IsPersisted() bool

func (*Cidade) ListByEstado

func (this *Cidade) ListByEstado(estado *Estado) (*[]*Cidade, error)

func (*Cidade) LoadRelated

func (this *Cidade) LoadRelated(entity *Cidade)

func (*Cidade) TableName

func (this *Cidade) TableName() string

type Email

type Email struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	To      string `orm:"type(text)"  valid:"Required;MaxSize(500)"`
	Cco     string `orm:"type(text)"  valid:"Required;MaxSize(500)"`
	Subject string `orm:"type(text)"  valid:"Required;MaxSize(200)"`
	Body    string `orm:"type(text)"  valid:"Required;"`
	Enabled bool   `orm:""  valid:"" `

	Tenant *Tenant `orm:"rel(fk);on_delete(do_nothing)" form:"" goutils:"tenant"`

	Session *db.Session `orm:"-"`
}

func NewEmail

func NewEmail(session *db.Session) *Email

func (*Email) Create

func (this *Email) Create(to string, subject string, body string) (*Email, error)

func (*Email) CreateOnly

func (this *Email) CreateOnly(to string, subject string, body string) *Email

func (*Email) CreateWithCco

func (this *Email) CreateWithCco(to string, cco string, subject string, body string) (*Email, error)

func (*Email) CreateWithCcoOnly

func (this *Email) CreateWithCcoOnly(to string, cco string, subject string, body string) *Email

func (*Email) IsPersisted

func (this *Email) IsPersisted() bool

func (*Email) List

func (this *Email) List() (*[]*Email, error)

func (*Email) TableName

func (this *Email) TableName() string

type Estado

type Estado struct {
	Id   int64  `form:"-" json:",string,omitempty"`
	Nome string `orm:"size(100)"  valid:"Required;MaxSize(100)" form:""`
	Uf   string `orm:"size(2)" valid:"Required;MaxSize(2)" form:""`

	Session *db.Session `orm:"-" json:"-" inject:""`
}

func NewEstado

func NewEstado(session *db.Session) *Estado

func (*Estado) FindByUf

func (this *Estado) FindByUf(uf string) (*Estado, error)

func (*Estado) IsPersisted

func (this *Estado) IsPersisted() bool

func (*Estado) List

func (this *Estado) List() (*[]*Estado, error)

func (*Estado) TableName

func (this *Estado) TableName() string

type Role

type Role struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	Authority   string `orm:"size(50)"`
	Description string `orm:"size(100)"`

	Session *db.Session `orm:"-" inject:""`
}

func NewRole

func NewRole(session *db.Session) *Role

func (*Role) Exists

func (this *Role) Exists(authority string) bool

func (*Role) FindByAuthority

func (this *Role) FindByAuthority(authority string) (role *Role, err error)

func (*Role) IsPersisted

func (this *Role) IsPersisted() bool

func (*Role) List

func (this *Role) List() (*[]*Role, error)

func (*Role) TableName

func (this *Role) TableName() string

type Tenant

type Tenant struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	Name      string `orm:"size(100)"  valid:"Required;MaxSize(100)" form:""`
	Documento string `orm:"size(20)"  valid:"Required;MaxSize(14);MinSize(11)" form:""`

	Enabled bool   `orm:""  form:"" json:",string"`
	Uuid    string `orm:"size(100);unique"  valid:"MaxSize(100)" form:"-" json:""`

	Cidade *Cidade `orm:"rel(fk);on_delete(do_nothing)" valid:"RequiredRel" form:""`

	Session *db.Session `orm:"-" json:"-" inject:""`
}

func NewTenant

func NewTenant(session *db.Session) *Tenant

func NewTenantWithId

func NewTenantWithId(id int64) *Tenant

func (*Tenant) FindByDocumento

func (this *Tenant) FindByDocumento(documento string) (*Tenant, error)

func (*Tenant) First

func (this *Tenant) First() *Tenant

func (*Tenant) GenereteUuid

func (this *Tenant) GenereteUuid() string

func (*Tenant) GetByUuid

func (this *Tenant) GetByUuid(uuid string) (*Tenant, error)

func (*Tenant) GetByUuidAndEnabled

func (this *Tenant) GetByUuidAndEnabled(uuid string) (*Tenant, error)

func (*Tenant) GetId

func (this *Tenant) GetId() int64

func (*Tenant) IsPersisted

func (this *Tenant) IsPersisted() bool

func (*Tenant) List

func (this *Tenant) List() (*[]*Tenant, error)

func (*Tenant) LoadRelated

func (this *Tenant) LoadRelated(entity *Tenant)

func (*Tenant) Page

func (this *Tenant) Page(page *db.Page) (*[]*Tenant, error)

func (*Tenant) TableName

func (this *Tenant) TableName() string

type TenantUser

type TenantUser struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	Enabled bool    `orm:"" valid:"Required;" form:"" json:",string,omitempty"`
	Tenant  *Tenant `orm:"rel(fk);on_delete(do_nothing)" valid:"Required" form:"" goutils:"no_set_tenant;no_filter_tenant"`
	User    *User   `orm:"rel(fk);on_delete(do_nothing)" valid:"Required" form:",select"`

	Admin bool `orm:"" valid:"Required;" form:"" json:",string,omitempty"`

	Session *db.Session `orm:"-" inject:""`
}

func NewTenantUser

func NewTenantUser(session *db.Session) *TenantUser

func (*TenantUser) Create

func (this *TenantUser) Create(user *User, tenant *Tenant) error

func (*TenantUser) FindByAdminUserAndTenant

func (this *TenantUser) FindByAdminUserAndTenant(user *User, tenant *Tenant) (*TenantUser, error)

func (*TenantUser) FindByUserAndTenant

func (this *TenantUser) FindByUserAndTenant(user *User, tenant *Tenant) (*TenantUser, error)

func (*TenantUser) GetFirstTenant

func (this *TenantUser) GetFirstTenant(user *User) (*Tenant, error)

func (*TenantUser) HasActiveTenant

func (this *TenantUser) HasActiveTenant(user *User) (bool, error)

func (*TenantUser) IsPersisted

func (this *TenantUser) IsPersisted() bool

func (*TenantUser) List

func (this *TenantUser) List() (*[]*TenantUser, error)

func (*TenantUser) ListActivesByTenant

func (this *TenantUser) ListActivesByTenant(tenant *Tenant) (*[]*TenantUser, error)

func (*TenantUser) ListActivesByUser

func (this *TenantUser) ListActivesByUser(user *User) (*[]*TenantUser, error)

func (*TenantUser) ListByTenant

func (this *TenantUser) ListByTenant(tenant *Tenant) (*[]*TenantUser, error)

func (*TenantUser) ListByUser

func (this *TenantUser) ListByUser(user *User) (*[]*TenantUser, error)

func (*TenantUser) ListByUserAdmin

func (this *TenantUser) ListByUserAdmin(user *User) (*[]*TenantUser, error)

func (*TenantUser) ListTenantsActivesByUser

func (this *TenantUser) ListTenantsActivesByUser(user *User) ([]*Tenant, error)

func (*TenantUser) ListTenantsByUser

func (this *TenantUser) ListTenantsByUser(user *User) ([]*Tenant, error)

func (*TenantUser) ListUsersActivesByTenant

func (this *TenantUser) ListUsersActivesByTenant(tenant *Tenant) ([]*User, error)

func (*TenantUser) ListUsersByTenant

func (this *TenantUser) ListUsersByTenant(tenant *Tenant) ([]*User, error)

func (*TenantUser) LoadRelated

func (this *TenantUser) LoadRelated(entity *TenantUser)

func (*TenantUser) Remove

func (this *TenantUser) Remove(user *User, tenant *Tenant) error

func (*TenantUser) RemoveAllByTenant

func (this *TenantUser) RemoveAllByTenant(tenant *Tenant) error

func (*TenantUser) RemoveAllByUser

func (this *TenantUser) RemoveAllByUser(user *User) error

func (*TenantUser) TableName

func (this *TenantUser) TableName() string

func (*TenantUser) ToTenants

func (this *TenantUser) ToTenants(results []*TenantUser) []*Tenant

func (*TenantUser) ToUsers

func (this *TenantUser) ToUsers(results []*TenantUser) []*User

type User

type User struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	Name      string    `orm:"size(100)"  valid:"Required;MaxSize(100)" form:""`
	UserName  string    `orm:"size(100);unique" valid:"Required;MaxSize(100);Email" form:""`
	Password  string    `orm:"size(100)" valid:"MaxSize(100)" form:"" json:"-"`
	Enabled   bool      `orm:"" valid:"Required;" form:"" json:""`
	LastLogin time.Time `orm:"null;type(datetime)"`

	ExpirationDate time.Time `orm:"type(datetime);null" form:"-" json:"-"`
	Token          string    `orm:"type(text);null"  valid:"" form:"-" json:"-"`

	Uuid string `orm:"size(100);unique"  valid:"MaxSize(100)" form:"-" json:"-"`

	ChangePwdExpirationDate time.Time `orm:"type(datetime);null" form:"-" json:"-"`
	ChangePwdToken          string    `orm:"type(text);null"  valid:"MaxSize(256)" form:"-" json:"-"`

	Tenant *Tenant `orm:"rel(fk);on_delete(do_nothing)" valid:"" form:"" goutils:"no_set_tenant;no_filter_tenant"`

	Role  *Role    `orm:"-"`
	Roles *[]*Role `orm:"-"`

	Session *db.Session `orm:"-" json:"-" inject:""`
}

func NewUser

func NewUser(session *db.Session) *User

func (*User) ChangePassword

func (this *User) ChangePassword(newPassword string)

func (*User) EncodePassword

func (this *User) EncodePassword()

func (*User) GenerateToken

func (this *User) GenerateToken(password string)

func (*User) GenereteUuid

func (this *User) GenereteUuid() string

func (*User) GetAuthorities

func (this *User) GetAuthorities() string

func (*User) GetByChangePwdToken

func (this *User) GetByChangePwdToken(token string) (*User, error)

func (*User) GetByToken

func (this *User) GetByToken(token string) (*User, error)

func (*User) GetByUserName

func (this *User) GetByUserName(username string) (*User, error)

func (*User) GetByUuid

func (this *User) GetByUuid(uuid string) (*User, error)

func (*User) GetByUuidAndEnabled

func (this *User) GetByUuidAndEnabled(uuid string) (*User, error)

func (*User) IsPersisted

func (this *User) IsPersisted() bool

func (*User) IsSamePassword

func (this *User) IsSamePassword(newPassword string) bool

func (*User) List

func (this *User) List() (*[]*User, error)

func (*User) ListByTenant

func (this *User) ListByTenant(tenant *Tenant) (*[]*User, error)

func (*User) LoadIfExists

func (this *User) LoadIfExists() (bool, error)

func (*User) LoadRelated

func (this *User) LoadRelated(entity *User)

func (*User) Page

func (this *User) Page(page *db.Page) (*[]*User, error)

func (*User) PageByTenant

func (this *User) PageByTenant(tenant Tenant, page *db.Page) (*[]*User, error)

func (*User) TableName

func (this *User) TableName() string

func (*User) UpdateLastLogin

func (this *User) UpdateLastLogin(userId int64)

type UserRole

type UserRole struct {
	Id        int64     `form:"-" json:",string,omitempty"`
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"-"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`

	User *User `orm:"rel(fk)"`
	Role *Role `orm:"rel(fk)"`

	Session *db.Session `orm:"-" inject:""`
}

func NewUserRole

func NewUserRole(session *db.Session) *UserRole

func NewUserRoleWithRole

func NewUserRoleWithRole(user *User, role *Role) *UserRole

func (*UserRole) Create

func (this *UserRole) Create(user *User, autority string) error

func (*UserRole) FindAllByRole

func (this *UserRole) FindAllByRole(role *Role) (*[]*UserRole, error)

func (*UserRole) FindAllByUser

func (this *UserRole) FindAllByUser(user *User) (*[]*UserRole, error)

func (*UserRole) FindAllRolesByUser

func (this *UserRole) FindAllRolesByUser(user *User) *[]*Role

func (*UserRole) FindByUser

func (this *UserRole) FindByUser(user *User) (*UserRole, error)

func (*UserRole) FindByUserAndAuthority

func (this *UserRole) FindByUserAndAuthority(user *User, autority string) (*UserRole, error)

func (*UserRole) FindByUserAndRole

func (this *UserRole) FindByUserAndRole(user *User, role *Role) (*UserRole, error)

func (*UserRole) FindRoleByUser

func (this *UserRole) FindRoleByUser(user *User) *Role

func (*UserRole) HasRoles

func (this *UserRole) HasRoles(user *User, roles ...string) bool

func (*UserRole) IsPersisted

func (this *UserRole) IsPersisted() bool

func (*UserRole) TableName

func (this *UserRole) TableName() string

Jump to

Keyboard shortcuts

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