Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(r *routing.RouteGroup, service Service, authHandler routing.Handler, logger log.Logger)
RegisterHandlers sets up the routing of the HTTP handlers.
Types ¶
type CreateSchoolRequest ¶
type CreateSchoolRequest struct {
Name string `json:"name"`
}
CreateSchoolRequest represents an school creation request.
func (CreateSchoolRequest) Validate ¶
func (m CreateSchoolRequest) Validate() error
Validate validates the CreateSchoolRequest fields.
type Repository ¶
type Repository interface { // Get returns the school with the specified school ID. Get(ctx context.Context, id string) (entity.School, error) // Count returns the number of school. Count(ctx context.Context) (int, error) // Query returns the list of school with the given offset and limit. Query(ctx context.Context, offset, limit int) ([]entity.School, error) // Create saves a new school in the storage. Create(ctx context.Context, school entity.School) error // Update updates the school with given ID in the storage. Update(ctx context.Context, school entity.School) error // Delete removes the school with given ID from the storage. Delete(ctx context.Context, id string) error }
Repository encapsulates the logic to access school from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new school repository
type Service ¶
type Service interface { Get(ctx context.Context, id string) (School, error) Query(ctx context.Context, offset, limit int) ([]School, error) Count(ctx context.Context) (int, error) Create(ctx context.Context, input CreateSchoolRequest) (School, error) Update(ctx context.Context, id string, input UpdateSchoolRequest) (School, error) Delete(ctx context.Context, id string) (School, error) }
Service encapsulates usecase logic for School.
func NewService ¶
func NewService(repo Repository, logger log.Logger) Service
NewService creates a new School service.
type UpdateSchoolRequest ¶
type UpdateSchoolRequest struct {
Name string `json:"name"`
}
UpdateSchoolRequest represents an School update request.
func (UpdateSchoolRequest) Validate ¶
func (m UpdateSchoolRequest) Validate() error
Validate validates the CreateSchoolRequest fields.
Click to show internal directories.
Click to hide internal directories.