Documentation ¶
Index ¶
- Constants
- func InitHTTPHandler(router *mux.Router, adminSession *middleware.AdminSession, ...)
- type AdminRepository
- type AdminRepositoryFilter
- func (f *AdminRepositoryFilter) SetLimit(limit int)
- func (f *AdminRepositoryFilter) SetOffset(offset int)
- func (f *AdminRepositoryFilter) SetRangeByCreatedAt(from, to time.Time)
- func (f *AdminRepositoryFilter) SetSearch(search string)
- func (f *AdminRepositoryFilter) SetStatus(status string)
- func (f *AdminRepositoryFilter) ToSQL() (string, []interface{}, error)
- type AdminUseCase
- type AdminUseCaseProperty
- type Administrator
- type CreateRequest
- type CreateResponse
- type CreatedAtFilter
- type HTTPHandler
- type SignInRequest
- type SignInResponse
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 ¶
type AdminRepository interface { Save(context.Context, Administrator, *sql.Tx) (int64, error) Update(context.Context, int64, Administrator, *sql.Tx) error FindByID(context.Context, int64, *sql.Tx) (Administrator, error) FindByEmail(context.Context, string, *sql.Tx) (Administrator, error) FindMany(context.Context, AdminRepositoryFilter, *sql.Tx) ([]Administrator, error) }
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 CreateRequest ¶
type CreateResponse ¶
type CreateResponse struct {
ID int64 `json:"id"`
}
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 SignInResponse ¶
Click to show internal directories.
Click to hide internal directories.