membership

package
v0.0.0-...-20be885 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldsAll = []string{
		"id",
		"ehid",
		"start_date",
		"end_date",
		"node_id",
	}

	FieldsAllExceptId = []string{
		"ehid",
		"start_date",
		"end_date",
		"node_id",
	}

	FieldsAllExceptIdAndEndDate = []string{
		"ehid",
		"start_date",
		"node_id",
	}

	FieldsPatchable = []string{
		"end_date",
	}

	OrderAsc  = "ASC"
	OrderDesc = "DESC"
	OrderNone = ""
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	ConfigService     *config.Service
	LocalErrorService *localerror.Service
	MembershipService *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 Memberships : HTTP endpoint to delete memberships @Tags Memberships @Description Delete a membership @Produce json @Param id path string true "Membership ID" @Success 200 {object} DeleteResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /memberships/{id} [DELETE]

func (*Controller) Get

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

Get Memberships : HTTP endpoint to get memberships @Tags Memberships @Description Get a memberhsip @Produce json @Param id path string true "Membership ID" @Success 200 {object} GetResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /memberships/{id} [GET]

func (*Controller) Patch

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

Patch Memberships : HTTP endpoint to patch a membership @Tags Memberships @Description Patch a membership @Accept json @Produce json @Param id path string true "Membership ID" @Param data body PatchRequestDto true "Membership Patch Request" @Success 200 {object} PatchResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /memberships/{id} [PATCH]

func (*Controller) Post

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

Post Memberships : HTTP endpoint to post new memberships @Tags Memberships @Description Post a new memberships @Accept json @Produce json @Param data body PostRequestDto true "Membership Request" @Success 200 {object} PostResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /memberships [POST]

type DeleteResponseDto

type DeleteResponseDto = dtorespwithoutdata.Class

type Entity

type Entity struct {
	Id        int
	Ehid      string
	StartDate time.Time
	EndDate   sql.NullTime
	NodeId    string
}

type GetResponseDto

type GetResponseDto = dtorespwithdata.Class[ViewEntity]

type PatchRequestDto

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

type PatchResponseDto

type PatchResponseDto = dtorespwithoutdata.Class

type PostRequestDto

type PostRequestDto struct {
	Ehid      string `json:"ehid"`
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
	NodeId    string `json:"node_id"`
}

type PostResponseDto

type PostResponseDto = dtorespwithdata.Class[ViewEntity]

type Query

type Query interface {
	SelectById(fields []string, id int) *gorm.DB
	SelectByEhid(fields []string, ehid string) *gorm.DB
	SelectByEhidOrderByStartDate(fields []string, ehid string, orderDir string) *gorm.DB
	SelectActiveByNodeId(fields []string, nodeId string) *gorm.DB
	SelectActiveByEhid(fields []string, ehid string) *gorm.DB
}

func NewQuery

func NewQuery(db *gorm.DB, tableName string) Query

type QueryImpl

type QueryImpl struct {
	Db        *gorm.DB
	TableName string
}

func (*QueryImpl) SelectActiveByEhid

func (q *QueryImpl) SelectActiveByEhid(fields []string, ehid string) *gorm.DB

func (*QueryImpl) SelectActiveByNodeId

func (q *QueryImpl) SelectActiveByNodeId(fields []string, nodeId string) *gorm.DB

func (*QueryImpl) SelectByEhid

func (q *QueryImpl) SelectByEhid(fields []string, ehid string) *gorm.DB

func (*QueryImpl) SelectByEhidOrderByStartDate

func (q *QueryImpl) SelectByEhidOrderByStartDate(fields []string, ehid string, orderDir string) *gorm.DB

func (*QueryImpl) SelectById

func (q *QueryImpl) SelectById(fields []string, id int) *gorm.DB

type Repository

type Repository interface {
	Create(req *Entity) (*Entity, error)
	FindById(id int) (*Entity, error)
	UpdateById(fields map[string]interface{}, id int) error
	DeleteById(id int) error
	FindByEhidOrderByStartDate(ehid string, orderDir string) ([]Entity, error)
	FindCurrentByNodeId(nodeId string) ([]Entity, error)
	FindCurrentByEhid(ehid string) ([]Entity, error)
}

func NewRepository

func NewRepository(cfg *config.Service) Repository

type RepositoryImpl

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

func (*RepositoryImpl) Create

func (r *RepositoryImpl) Create(req *Entity) (*Entity, error)

func (*RepositoryImpl) DeleteById

func (r *RepositoryImpl) DeleteById(id int) error

func (*RepositoryImpl) FindByEhidOrderByStartDate

func (r *RepositoryImpl) FindByEhidOrderByStartDate(ehid string, orderDir string) ([]Entity, error)

func (*RepositoryImpl) FindById

func (r *RepositoryImpl) FindById(id int) (*Entity, error)

func (*RepositoryImpl) FindCurrentByEhid

func (r *RepositoryImpl) FindCurrentByEhid(ehid string) ([]Entity, error)

func (*RepositoryImpl) FindCurrentByNodeId

func (r *RepositoryImpl) FindCurrentByNodeId(nodeId string) ([]Entity, error)

func (*RepositoryImpl) UpdateById

func (r *RepositoryImpl) UpdateById(fields map[string]interface{}, id int) error

type Service

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

func NewService

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

func (*Service) Create

func (s *Service) Create(req PostRequestDto) (*ViewEntity, error)

func (*Service) DeleteById

func (s *Service) DeleteById(id int) error

func (*Service) RetrieveByEhidOrderByStartDate

func (s *Service) RetrieveByEhidOrderByStartDate(ehid string, orderDir string) ([]ViewEntity, error)

func (*Service) RetrieveById

func (s *Service) RetrieveById(id int) (*ViewEntity, error)

func (*Service) RetrieveCurrentByEhid

func (s *Service) RetrieveCurrentByEhid(ehid string) ([]ViewEntity, error)

func (*Service) RetrieveCurrentByNodeId

func (s *Service) RetrieveCurrentByNodeId(nodeId string) ([]ViewEntity, error)

func (*Service) UpdateById

func (s *Service) UpdateById(fields map[string]interface{}, id int) error

type ViewEntity

type ViewEntity struct {
	Id        int    `json:"id"`
	Ehid      string `json:"ehid"`
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
	NodeId    string `json:"node_id"`
}

Jump to

Keyboard shortcuts

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