services

package
v0.0.0-...-1e04ee6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenLength = 16
)

Variables

View Source
var UnAuthorizedErr = errors.New("Unauthorized")

Functions

This section is empty.

Types

type Service

type Service struct {
	Database *ent.Client
}

func (*Service) CheckUserPassword

func (svc *Service) CheckUserPassword(usr *ent.User, password string) bool

func (*Service) CreateContact

func (svc *Service) CreateContact(ctx context.Context, data *models.ContactPayload, userID int) (*ent.Contact, error)

func (*Service) CreateToken

func (svc *Service) CreateToken(ctx context.Context, user *ent.User) (*ent.Token, error)

func (*Service) CreateUser

func (svc *Service) CreateUser(ctx context.Context, user models.User) (*ent.User, error)

CreateUser bcyrpt password and save it in databas

func (*Service) CurrentUser

func (svc *Service) CurrentUser(ctx context.Context, r *http.Request) (int, error)

func (*Service) DeleteContact

func (svc *Service) DeleteContact(ctx context.Context, cnc *ent.Contact) error

func (*Service) GetContact

func (svc *Service) GetContact(ctx context.Context, contactID int) (*ent.Contact, error)

func (*Service) GetUserByUsername

func (svc *Service) GetUserByUsername(ctx context.Context, username string) (*ent.User, error)

func (*Service) GetUserContacts

func (svc *Service) GetUserContacts(ctx context.Context, userId int) ([]*ent.Contact, error)

func (*Service) GetUserIDByToken

func (svc *Service) GetUserIDByToken(ctx context.Context, tokenValue string) (int, error)

func (*Service) UpdateContact

func (svc *Service) UpdateContact(
	ctx context.Context, contct *ent.Contact, data models.ContactPayload) (*ent.Contact, error)

Jump to

Keyboard shortcuts

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