designation

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxCountUnlimited = -1
	RankLowest        = 2147483647
)
View Source
var (
	FieldsAll = []string{
		"id",
		"node_id",
		"role_id",
		"ehid",
	}

	FieldsAllExceptId = []string{
		"node_id",
		"role_id",
		"ehid",
	}

	FieldsAllExceptNodeId = []string{
		"id",
		"role_id",
		"ehid",
	}

	FieldsPatchable = []string{
		"node_id",
		"role_id",
		"ehid",
	}
)

Functions

This section is empty.

Types

type Controller

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

func NewController

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

func (*Controller) Delete

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

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

func (*Controller) Get

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

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

func (*Controller) Patch

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

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

func (*Controller) Post

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

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

type DeleteResponseDto

type DeleteResponseDto = dtorespwithoutdata.Class

type Entity

type Entity struct {
	Id     string `json:"id"`
	NodeId string `json:"node_id"`
	RoleId string `json:"role_id"`
	Ehid   string `json:"ehid"`
}

type GetResponseDto

type GetResponseDto = dtorespwithdata.Class[Entity]

type PatchRequestDto

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

type PatchResponseDto

type PatchResponseDto = dtorespwithoutdata.Class

type PostRequestDto

type PostRequestDto struct {
	NodeId string `json:"node_id"`
	RoleId string `json:"role_id"`
	Ehid   string `json:"ehid"`
}

type PostResponseDto

type PostResponseDto = dtorespwithdata.Class[Entity]

type Query

type Query interface {
	SelectById(fields []string, id string) *gorm.DB
	SelectByNodeId(fields []string, nodeId string) *gorm.DB
	SelectByNodeIdAndRoleId(fields []string, nodeId string, roleId 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) SelectById

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

func (*QueryImpl) SelectByNodeId

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

func (*QueryImpl) SelectByNodeIdAndRoleId

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

type Repository

type Repository interface {
	Create(req *Entity) (*Entity, error)
	FindById(id string) (*Entity, error)
	UpdateById(fields map[string]interface{}, ehid string) error
	DeleteById(id string) error
	FindByNodeId(nodeId string) ([]Entity, error)
	FindByNodeIdAndRoleId(nodeId string, roleId 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 string) error

func (*RepositoryImpl) FindById

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

func (*RepositoryImpl) FindByNodeId

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

func (*RepositoryImpl) FindByNodeIdAndRoleId

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

func (*RepositoryImpl) UpdateById

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

type Service

type Service struct {
	ConfigService         *config.Service
	DesignationRepository Repository
	RoleRepository        role.Repository
}

func NewService

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

func (*Service) Create

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

func (*Service) DeleteById

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

func (*Service) RetrieveById

func (s *Service) RetrieveById(id string) (*Entity, error)

func (*Service) RetrieveByNodeId

func (s *Service) RetrieveByNodeId(nodeId string) ([]Entity, error)

func (*Service) RetrieveByNodeIdAndRoleId

func (s *Service) RetrieveByNodeIdAndRoleId(nodeId string, roleId string) ([]Entity, error)

func (*Service) UpdateById

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

Jump to

Keyboard shortcuts

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