services

package
v0.0.0-...-a494c4b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminService

type AdminService interface {
	CreateAdmin(ctx context.Context, name string, email string, password string, role string, createdBy *string, phone *string) (*models.Admin, error)
	LoginAdmin(ctx context.Context, email string, password string) (*LoginResult, error)
	UpdateAdminRole(ctx context.Context, adminID string, role string) (bool, error)
	UpdateAdmin(ctx context.Context, adminID string, fullname *string, email *string, phone *string) (bool, error)
	UpdateAdminPassword(ctx context.Context, adminID string, oldPassword string, newPassword string) (bool, error)
	DeleteAdmin(ctx context.Context, adminID string) (bool, error)
	ForgotPasswordRequest(ctx context.Context, email string) (*models.Admin, error)
	ResendCode(ctx context.Context, adminID string) (*models.Admin, error)
	CompareAdminCodes(ctx context.Context, adminID string, code string) (bool, error)
	ResetPassword(ctx context.Context, adminID string, password string) (bool, error)
}

AdminService inteface holds the user-databse transactions of this controller

func NewAdminSvc

func NewAdminSvc(db *orm.ORM, rdb *redis.Client) AdminService

NewAdminSvc exposed the ORM to the admin functions in the module

type LoginResult

type LoginResult struct {
	Token string       `json:"token"`
	Admin models.Admin `json:"admin"`
}

LoginResult is the typing for returning login successful data to user

type ORM

type ORM struct {
	DB *orm.ORM
	// contains filtered or unexported fields
}

ORM gets orm connection

func (*ORM) CompareAdminCodes

func (orm *ORM) CompareAdminCodes(ctx context.Context, adminID string, code string) (bool, error)

CompareAdminCodes compares the admin code sent by user

func (*ORM) CreateAdmin

func (orm *ORM) CreateAdmin(ctx context.Context, name string, email string, password string, role string, createdBy *string, phone *string) (*models.Admin, error)

CreateAdmin creates an admin when invoked

func (*ORM) DeleteAdmin

func (orm *ORM) DeleteAdmin(ctx context.Context, adminID string) (bool, error)

DeleteAdmin deletes an admin

func (*ORM) ForgotPasswordRequest

func (orm *ORM) ForgotPasswordRequest(ctx context.Context, email string) (*models.Admin, error)

ForgotPasswordRequest is to start the process

func (*ORM) LoginAdmin

func (orm *ORM) LoginAdmin(ctx context.Context, email string, password string) (*LoginResult, error)

LoginAdmin checks if the email is having valid credentials and returns them a unique, secured token to help them get resources from app

func (*ORM) ResendCode

func (orm *ORM) ResendCode(ctx context.Context, adminID string) (*models.Admin, error)

ResendCode helps to resend a new code

func (*ORM) ResetPassword

func (orm *ORM) ResetPassword(ctx context.Context, adminID string, password string) (bool, error)

ResetPassword updates the admins new password

func (*ORM) UpdateAdmin

func (orm *ORM) UpdateAdmin(ctx context.Context, adminID string, fullname *string, email *string, phone *string) (bool, error)

UpdateAdmin updates data of an admin

func (*ORM) UpdateAdminPassword

func (orm *ORM) UpdateAdminPassword(ctx context.Context, adminID string, oldPassword string, newPassword string) (bool, error)

UpdateAdminPassword updates password of an admin

func (*ORM) UpdateAdminRole

func (orm *ORM) UpdateAdminRole(ctx context.Context, adminID string, role string) (bool, error)

UpdateAdminRole updates role of an admin

Jump to

Keyboard shortcuts

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