domain

package
v0.0.0-...-76f2794 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("internal Server Error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("your requested item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict     = errors.New("already exist")
	ErrUsenameTaken = errors.New("username already taken")
	ErrEmailTaken   = errors.New("email already taken")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("given Param is not valid")
	ErrInvalidInput  = errors.New("invalid input data")
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	UsernameOrEmail string `json:"username_or_email" form:"username_or_email" validate:"required"`
	Password        string `json:"password" form:"password" validate:"required"`
}

type AuthRegister

type AuthRegister struct {
	Username string `json:"username"`
	Password string `json:"password" form:"password"`
	Name     string `json:"name" form:"name"`
	Email    string `json:"email"`
	Gender   string `json:"gender,omitempty"`
}

type AuthResponse

type AuthResponse struct {
	Username     string `json:"username,omitempty"`
	Email        string `json:"email,omitempty"`
	Gender       string `json:"gender,omitempty"`
	Status       string `json:"status,omitempty"`
	Token        string `json:"token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

type AuthUsecase

type AuthUsecase interface {
	Login(ctx context.Context, auth Auth, isOauth bool) (AuthResponse, error)
	Register(context.Context, *User, *UserRole, bool) (AuthResponse, error)
	ForgotPassword(ctx context.Context, email string) error
}

type Author

type Author struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

Author ...

type AuthorRepository

type AuthorRepository interface {
	GetByID(ctx context.Context, id int64) (Author, error)
}

AuthorRepository represent the author's repository contract

type Base

type Base struct {
	ID        uuid.UUID      `gorm:"type:uuid;primaryKey" json:"id,omitempty" param:"id"`
	UpdatedAt *time.Time     `json:"updated_at,omitempty"`
	CreatedAt *time.Time     `json:"created_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(scope *gorm.DB) (err error)

type CasbinRBAC

type CasbinRBAC struct {
	Sub string
	Obj string
	Act string
}

type CasbinRBACRepository

type CasbinRBACRepository interface {
	Store(c *CasbinRBAC) (bool, error)
}

type Employee

type Employee struct {
	Base

	NIP         string `json:"NIP" form:"NIP"`
	NIK         string `json:"NIK" form:"NIK"`
	Name        string `json:"name" form:"name"`
	Gender      string `json:"gender" form:"gender"`
	Email       string `json:"email" form:"email"`
	PhoneNumber string `json:"phone_number" form:"phone_number"`
	JoinedAt    string `json:"joined_at" form:"joined_at"`
	JobRole     string `json:"job_role" form:"job_role"`
}

type EmployeeHistory

type EmployeeHistory struct {
	Employee
	History
}

type EmployeeRepository

type EmployeeRepository interface {
	GetOne(ctx context.Context, args QueryArgs) (Employee, error)
	GetByID(ctx context.Context, id uuid.UUID) (Employee, error)
	Store(ctx context.Context, a *Employee) error
	Update(ctx context.Context, a *Employee) error
}

type EmployeeUsecase

type EmployeeUsecase interface {
	GetByID(ctx context.Context, id uuid.UUID) (User, error)
	Store(context.Context, *Employee) error
	Update(ctx context.Context, a *Employee) error
}

type ForgotPassword

type ForgotPassword struct {
	Email string `json:"email" validate:"required,email"`
}

type History

type History struct {
	Action string `json:"action"`
}

type Query

type Query struct {
	Args, Clause string
}

type QueryArgs

type QueryArgs struct {
	SelectClause
	WhereClause
}

type Role

type Role struct {
	Base
	Name string `json:"name"`
}

type RoleRepository

type RoleRepository interface {
	GetByName(ctx context.Context, name string) (Role, error)
	Store(ctx context.Context, r *Role) error
}

type RoleUsecase

type RoleUsecase interface {
	GetByName(ctx context.Context, name string) (Role, error)
	Store(ctx context.Context, r *Role) error
}

type SelectClause

type SelectClause struct {
	User, UserRoles, Role, Employee string
}

type User

type User struct {
	Base
	Username      string                `json:"username,omitempty" form:"username" gorm:"size:191"`
	Email         string                `json:"email,omitempty" validate:"required" form:"email" gorm:"index"`
	Password      string                `json:"password,omitempty" form:"password"`
	Name          string                `json:"name,omitempty" form:"name"`
	Gender        string                `json:"gender,omitempty" form:"gender"`
	Status        string                `gorm:"default:'not active'" json:"status,omitempty" form:"status"`
	UserRoles     []UserRole            `gorm:"foreignKey:UserID;" json:"user_role,omitempty" form:"user_roles"`
	ProfilePic    string                `json:"profile_pic,omitempty"`
	File          *multipart.FileHeader `gorm:"-" json:"file,omitempty"`
	VerifiedAt    *time.Time            `json:"verified_at,omitempty" form:"verified_at"`
	OauthProvider string                `json:"oauth_provider,omitempty"`
	OauthToken    string                `json:"oauth_token,omitempty"`
}

type UserFilepath

type UserFilepath struct {
	Base
	Filename string `json:"filename"`
	Mimetype string `json:"mimetype"`
	Path     string `json:"path"`
	UserID   uuid.UUID
	User     User `json:"user"`
}

type UserFilepathRepository

type UserFilepathRepository interface {
	Store(ctx context.Context, f *UserFilepath) error
}

type UserQueryArgs

type UserQueryArgs struct {
	SelectClause
	WhereClause
}

type UserRepository

type UserRepository interface {
	GetOneByUsernameOrEmail(ctx context.Context, usernameOrEmail string) (User, error)
	GetOne(ctx context.Context, args QueryArgs) (User, error)
	GetByID(ctx context.Context, id uuid.UUID) (User, error)
	Store(ctx context.Context, a *User) error
	Update(ctx context.Context, a *User) error
}

type UserRole

type UserRole struct {
	Base
	UserID uuid.UUID
	User   *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
	RoleID uuid.UUID
	Role   Role `gorm:"foreignKey:RoleID" json:"role"`
}

type UserRoleRepository

type UserRoleRepository interface {
	Store(ctx context.Context, u *UserRole) error
	GetByUserID(ctx context.Context, userID uuid.UUID) ([]UserRole, error)
}

type UserUpdate

type UserUpdate struct {
	Base
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty" validate:"email"`
	Password string `json:"password,omitempty"`
	Name     string `json:"name,omitempty"`
}

type UserUsecase

type UserUsecase interface {
	GetOneByUsernameOrEmail(ctx context.Context, usernameOrEmail string) (User, error)
	GetByID(ctx context.Context, id uuid.UUID) (User, error)
	Store(context.Context, *User, *UserRole) error
	Update(ctx context.Context, a *User) error
	ResendEmailVerification(ctx context.Context, token string) error
	GetUsingRefreshToken(ctx context.Context, userID uuid.UUID) (refreshToken string, accessToken string, err error)
}

type WhereClause

type WhereClause struct {
	UserRoles, Role, User, Employee Query
}

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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