admin

package
v0.0.0-...-f242e82 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusActive   = "ACTIVE"
	StatusInactive = "INACTIVE"
)

Variables

This section is empty.

Functions

func InitHTTPHandler

func InitHTTPHandler(router *mux.Router, adminSession *middleware.AdminSession, validate *validator.Validate, adminUseCase AdminUseCase)

Types

type AdminRepository

AdminRepository is a set collection of behavior to store, update, and view admin's properties.

func NewAdminRepository

func NewAdminRepository(logger *logrus.Logger, db *sql.DB) AdminRepository

NewAdminRepository acts like the constructor of AdminRepository. It returns collection of behaviors that implements the AdminRepository interface.

type AdminRepositoryFilter

type AdminRepositoryFilter struct {
	Status    *string
	Search    *string
	CreatedAt *CreatedAtFilter
	Offset    *int
	Limit     *int
	OrderBy   map[string]string
}

func NewAdminRepositoryFilter

func NewAdminRepositoryFilter() *AdminRepositoryFilter

func (*AdminRepositoryFilter) SetLimit

func (f *AdminRepositoryFilter) SetLimit(limit int)

func (*AdminRepositoryFilter) SetOffset

func (f *AdminRepositoryFilter) SetOffset(offset int)

func (*AdminRepositoryFilter) SetRangeByCreatedAt

func (f *AdminRepositoryFilter) SetRangeByCreatedAt(from, to time.Time)

func (*AdminRepositoryFilter) SetSearch

func (f *AdminRepositoryFilter) SetSearch(search string)

func (*AdminRepositoryFilter) SetStatus

func (f *AdminRepositoryFilter) SetStatus(status string)

func (*AdminRepositoryFilter) ToSQL

func (f *AdminRepositoryFilter) ToSQL() (string, []interface{}, error)

type AdminUseCase

type AdminUseCase interface {
	SignIn(context.Context, SignInRequest) (SignInResponse, error)
	Create(context.Context, CreateRequest) (CreateResponse, error)
	SignOut(context.Context) error
}

func NewAdminUseCase

func NewAdminUseCase(props AdminUseCaseProperty) AdminUseCase

type AdminUseCaseProperty

type AdminUseCaseProperty struct {
	Logger          *logrus.Logger
	DefaultPassword string
	Timeout         time.Duration
	JSONWebToken    *jwt.JSONWebToken
	Session         session.Session
	AdminRepository AdminRepository
}

type Administrator

type Administrator struct {
	ID           int64
	Name         string
	Email        string
	Password     string
	PasswordSalt string
	Status       string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type CreateRequest

type CreateRequest struct {
	Name  string `json:"name" validate:"required"`
	Email string `json:"email" validate:"email"`
}

type CreateResponse

type CreateResponse struct {
	ID int64 `json:"id"`
}

type CreatedAtFilter

type CreatedAtFilter struct {
	From time.Time
	To   time.Time
}

type HTTPHandler

type HTTPHandler struct {
	SessionMiddleware *middleware.AdminSession
	Validate          *validator.Validate
	AdminUseCase      AdminUseCase
}

func (HTTPHandler) Create

func (handler HTTPHandler) Create(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) SignIn

func (handler HTTPHandler) SignIn(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) SignOut

func (handler HTTPHandler) SignOut(w http.ResponseWriter, r *http.Request)

type SignInRequest

type SignInRequest struct {
	Email    string `json:"email" validate:"email"`
	Password string `json:"password" validate:"required"`
}

type SignInResponse

type SignInResponse struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

Jump to

Keyboard shortcuts

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