profile

package
v0.0.0-...-5bec41d Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldsPatchable = []string{
		"name",
		"email_address",
		"dob",
	}
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	ConfigService     *config.Service
	LocalErrorService *localerror.Service
	ProfileService    *Service
}

func NewController

func NewController(cfg *config.Service, les *localerror.Service, svc *Service) *Controller

func (*Controller) Delete

func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)

Delete Profiles : HTTP endpoint to delete a profile @Tags Profiles @Description Delete a profile @Produce json @Param ehid path string true "Employee Hash ID" @Success 200 {object} DeleteResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /profiles/{ehid} [DELETE]

func (*Controller) Get

func (c *Controller) Get(w http.ResponseWriter, r *http.Request)

Get Profiles : HTTP endpoint to get a profile @Tags Profiles @Description Get a profile @Produce json @Param ehid path string true "Employee Hash ID" @Success 200 {object} GetResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /profiles/{ehid} [GET]

func (*Controller) GetMyEhid

func (c *Controller) GetMyEhid(w http.ResponseWriter, r *http.Request)

Get My EHID : HTTP endpoint to get current user's EHID @Tags Profiles @Description Get current user's EHID @Produce json @Param Authorization header string true "Bearer Token" @Success 200 {object} GetEhidResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /profiles/me/ehid [GET]

func (*Controller) Patch

func (c *Controller) Patch(w http.ResponseWriter, r *http.Request)

Patch Profiles : HTTP endpoint to patch a profile @Tags Profiles @Description Patch a profile @Accept json @Produce json @Param ehid path string true "Employee Hash ID" @Param data body PatchRequestDto true "Profile Patch Request" @Success 200 {object} PatchResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /profiles/{ehid} [PATCH]

type DeleteResponseDto

type DeleteResponseDto = dtorespwithoutdata.Class

type Entity

type Entity struct {
	Ehid         string `json:"ehid"`
	EmployeeId   string `json:"employee_id"`
	Name         string `json:"name"`
	EmailAddress string `json:"email_address"`
	Dob          string `json:"dob"`
}

type GetEhidResponseDto

type GetEhidResponseDto = dtorespwithdata.Class[string]

type GetResponseDto

type GetResponseDto = dtorespwithdata.Class[Entity]

type PatchRequestDto

type PatchRequestDto struct {
	Fields map[string]string `json:"fields"`
}

type PatchResponseDto

type PatchResponseDto = dtorespwithoutdata.Class

type Repository

type Repository interface {
	CreateWithDb(db *gorm.DB, employeeId string, ehid string) error
	UpdateByEhid(fields map[string]string, ehid string) error
	FindByEhid(ehid string) (*Entity, error)
	FindEmployeeIdByEhid(ehid string) (string, error)
	DeleteByEhid(ehid string) error
}

func NewRepository

func NewRepository(cfg *config.Service) Repository

type RepositoryImpl

type RepositoryImpl struct {
	ConfigService *config.Service
	TableName     string
}

func (*RepositoryImpl) CreateWithDb

func (r *RepositoryImpl) CreateWithDb(
	db *gorm.DB,
	employeeId string,
	ehid string,
) error

func (*RepositoryImpl) DeleteByEhid

func (r *RepositoryImpl) DeleteByEhid(ehid string) error

func (*RepositoryImpl) FindByEhid

func (r *RepositoryImpl) FindByEhid(ehid string) (*Entity, error)

func (*RepositoryImpl) FindEmployeeIdByEhid

func (r *RepositoryImpl) FindEmployeeIdByEhid(ehid string) (string, error)

func (*RepositoryImpl) UpdateByEhid

func (r *RepositoryImpl) UpdateByEhid(
	fields map[string]string,
	ehid string,
) error

type Service

type Service struct {
	ConfigService     *config.Service
	ProfileRepository Repository
}

func NewService

func NewService(cfg *config.Service, r Repository) *Service

func (*Service) DeleteByEhid

func (s *Service) DeleteByEhid(ehid string) error

func (*Service) RetrieveByEhid

func (s *Service) RetrieveByEhid(ehid string) (*Entity, error)

func (*Service) RetrieveEmployeeIdByEhid

func (s *Service) RetrieveEmployeeIdByEhid(ehid string) (string, error)

func (*Service) UpdateByEhid

func (s *Service) UpdateByEhid(fields map[string]string, ehid string) error

Jump to

Keyboard shortcuts

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