grading

package
v0.0.0-...-e1a70cd 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",
		"grade",
	}

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

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

	FieldsPatchable = []string{
		"grade",
		"end_date",
	}

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

Functions

This section is empty.

Types

type Controller

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

func NewController

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

func (*Controller) Delete

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

Delete Gradings : HTTP endpoint to delete gradings @Tags Gradings @Description Delete a grading @Produce json @Param id path string true "Grading ID" @Success 200 {object} DeleteResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /gradings/{id} [DELETE]

func (*Controller) Get

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

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

func (*Controller) Patch

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

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

func (*Controller) Post

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

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

type DeleteResponseDto

type DeleteResponseDto = dtorespwithoutdata.Class

type Entity

type Entity struct {
	Id        int
	Ehid      string
	StartDate time.Time
	EndDate   sql.NullTime
	Grade     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"`
	Grade     string `json:"grade"`
}

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
	SelectActiveByEhid(fields []string, ehid string) *gorm.DB
	ByEhidAndIntersectingDates(ehid string, startDate string, endDate string) *gorm.DB
	ByEhidAndEndDateIsNull(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) ByEhidAndEndDateIsNull

func (q *QueryImpl) ByEhidAndEndDateIsNull(ehid string) *gorm.DB

func (*QueryImpl) ByEhidAndIntersectingDates

func (q *QueryImpl) ByEhidAndIntersectingDates(ehid string, startDate string, endDate string) *gorm.DB

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)
	FindCurrentByEhid(ehid string) (*Entity, error)
	CountIntersectingDates(ehid string, startDate string, endDate string) (int64, error)
	CountEndDateIsNull(ehid string) (int64, error)
}

func NewRepository

func NewRepository(cfg *config.Service) Repository

type RepositoryImpl

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

func (*RepositoryImpl) CountEndDateIsNull

func (r *RepositoryImpl) CountEndDateIsNull(ehid string) (int64, error)

func (*RepositoryImpl) CountIntersectingDates

func (r *RepositoryImpl) CountIntersectingDates(
	ehid string,
	startDate string,
	endDate string,
) (int64, error)

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) UpdateById

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

type Service

type Service struct {
	ConfigService     *config.Service
	GradingRepository 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) 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"`
	Grade     string `json:"grade"`
}

Jump to

Keyboard shortcuts

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