domain

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AuthTableName string = "users_auth"
View Source
const DepartmentTableName string = "department"
View Source
const ProfileTableName string = "users_profile"
View Source
const UserTableName string = "users"

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Base
	Status    bool `gorm:"column:status;type:bool;not null;"`
	ProfileID uint `gorm:"column:profile_id;type:bigint;not null;index;" validate:"required,min=1"`
	Profile   *Profile
	Token     *string `gorm:"column:token;type:varchar(255);unique;index"`
	Password  *string `gorm:"column:password;type:varchar(255);"`
}

func (*Auth) TableName

func (s *Auth) TableName() string

func (*Auth) ToMap added in v0.0.2

func (s *Auth) ToMap() *map[string]any

type AuthService

type AuthService interface {
	Login(context.Context, *dto.AuthInputDTO, string) (*dto.AuthOutputDTO, error)
	Refresh(*User, string) *dto.AuthOutputDTO
	Me(*User) *dto.UserOutputDTO
}

type Base

type Base struct {
	ID        uint      `gorm:"primarykey"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type Department

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

func (*Department) Bind

func (s *Department) Bind(p *dto.DepartmentInputDTO) error

func (*Department) TableName

func (s *Department) TableName() string

func (*Department) ToMap

func (s *Department) ToMap() map[string]any

type DepartmentRepository

type DepartmentRepository interface {
	CountDepartments(context.Context, *filter.Filter) (int64, error)
	GetDepartmentByID(context.Context, uint) (*Department, error)
	GetDepartments(context.Context, *filter.Filter) (*[]Department, error)
	CreateDepartment(context.Context, *Department) error
	UpdateDepartment(context.Context, *Department) error
	DeleteDepartments(context.Context, []uint) error
}

type DepartmentService

type DepartmentService interface {
	GenerateDepartmentOutputDTO(*Department) *dto.DepartmentOutputDTO
	GetDepartmentByID(context.Context, uint) (*dto.DepartmentOutputDTO, error)
	GetDepartments(context.Context, *filter.Filter) (*dto.ItemsOutputDTO[dto.DepartmentOutputDTO], error)
	CreateDepartment(context.Context, *dto.DepartmentInputDTO) (*dto.DepartmentOutputDTO, error)
	UpdateDepartment(context.Context, uint, *dto.DepartmentInputDTO) (*dto.DepartmentOutputDTO, error)
	DeleteDepartments(context.Context, []uint) error
}

type File

type File struct {
	Name      string
	Extension string
	File      io.Reader
}

type Profile

type Profile struct {
	Base
	Name        string        `gorm:"column:name;type:varchar(100);unique;not null;" validate:"required,min=4"`
	Permissions pgutils.JSONB `gorm:"column:permissions;type:jsonb;not null;" validate:"required"`
}

func (*Profile) Bind

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

func (*Profile) TableName

func (s *Profile) TableName() string

func (*Profile) ToMap

func (s *Profile) ToMap() *map[string]any

type ProfileRepository

type ProfileRepository interface {
	CountProfiles(context.Context, *filter.Filter) (int64, error)
	GetProfileByID(context.Context, uint) (*Profile, error)
	GetProfiles(context.Context, *filter.Filter) (*[]Profile, error)
	CreateProfile(context.Context, *Profile) error
	UpdateProfile(context.Context, *Profile) error
	DeleteProfiles(context.Context, []uint) error
}

type ProfileService

type ProfileService interface {
	GenerateProfileOutputDTO(*Profile) *dto.ProfileOutputDTO
	GetProfileByID(context.Context, uint) (*dto.ProfileOutputDTO, error)
	GetProfiles(context.Context, *filter.Filter) (*dto.ItemsOutputDTO[dto.ProfileOutputDTO], error)
	CreateProfile(context.Context, *dto.ProfileInputDTO) (*dto.ProfileOutputDTO, error)
	UpdateProfile(context.Context, uint, *dto.ProfileInputDTO) (*dto.ProfileOutputDTO, error)
	DeleteProfiles(context.Context, []uint) error
}

type User

type User struct {
	Base
	Name      string  `gorm:"column:name;type:varchar(90);not null;" validate:"required,min=5"`
	Email     string  `gorm:"column:mail;type:varchar(50);not null;unique;index;" validate:"required,email"`
	PhotoPath *string `gorm:"column:photo;type:varchar(150);null;default:null;"`
	AuthID    uint    `gorm:"column:auth_id;type:bigint;not null;index;"`
	Auth      *Auth   `gorm:"constraint:OnDelete:CASCADE"`
}

func (*User) Bind

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

func (*User) GenerateToken

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

func (*User) TableName

func (u *User) TableName() string

func (*User) ToMap

func (u *User) ToMap() *map[string]any

func (*User) ValidatePassword

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

type UserRepository

type UserRepository interface {
	CountUsers(context.Context, *filters.UserFilter) (int64, error)
	GetUsers(context.Context, *filters.UserFilter) (*[]User, error)
	GetUserByID(context.Context, uint) (*User, error)
	GetUserByMail(context.Context, string) (*User, error)
	GetUserByToken(context.Context, string) (*User, error)
	CreateUser(context.Context, *User) error
	UpdateUser(context.Context, *User) error
	DeleteUsers(context.Context, []uint) error
	ResetUserPassword(context.Context, *User) error
	SetUserPassword(context.Context, *User, *dto.PasswordInputDTO) error
	SetUserPhoto(context.Context, *User, *File) error
	GenerateUserPhotoURL(context.Context, *User) (string, error)
}

type UserService

type UserService interface {
	GenerateUserOutputDTO(*User) *dto.UserOutputDTO
	GetUserByID(context.Context, uint) (*dto.UserOutputDTO, error)
	GetUsers(context.Context, *filters.UserFilter) (*dto.ItemsOutputDTO[dto.UserOutputDTO], error)
	CreateUser(context.Context, *dto.UserInputDTO) (*dto.UserOutputDTO, error)
	UpdateUser(context.Context, uint, *dto.UserInputDTO) (*dto.UserOutputDTO, error)
	DeleteUsers(context.Context, []uint) error
	ResetUserPassword(context.Context, string) error
	SetUserPassword(context.Context, string, *dto.PasswordInputDTO) error
	SetUserPhoto(context.Context, uint, *File) error
	GenerateUserPhotoURL(context.Context, uint) (string, error)
}

Jump to

Keyboard shortcuts

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