challenge

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

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

Go to latest
Published: Apr 24, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoFile           = errors.New("uploaded files not found")
	ErrFileExcedLimit   = errors.New("file size exceeds limit")
	ErrFileNotOnStorage = errors.New("file not found on storage")
)
View Source
var (
	ErrFileNotFound = errors.New("file not found")
)

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	ID          bson.ObjectID `bson:"_id,omitempty" json:"id"`
	Title       string        `bson:"title" json:"title"`
	Category    string        `bson:"category" json:"category"`
	Description string        `bson:"description" json:"description"`
	Points      int           `bson:"points" json:"points"`
	State       string        `bson:"state" json:"state"`
	Type        string        `bson:"type" json:"type"`
	Solves      int           `bson:"solves" json:"solves"`
	Flag        string        `bson:"flag" json:"flag"`
	Author      string        `bson:"author,omitempty" json:"author,omitempty"`
	Files       []FileMeta    `bson:"files,omitempty" json:"files,omitempty"`
}

type FileMeta

type FileMeta struct {
	UUID       string    `bson:"uuid" json:"uuid"`
	Name       string    `bson:"name" json:"name"`
	Size       int64     `bson:"size" json:"size"`
	UploadedAt time.Time `bson:"uploadedat" json:"uploadedat"`
}

type FileService

type FileService struct {
	// contains filtered or unexported fields
}

func NewFileService

func NewFileService() *FileService

func (*FileService) ValidateFile

func (fs *FileService) ValidateFile(file *FileMeta) (string, error)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) AddChallengeFile

func (h *Handler) AddChallengeFile(c *gin.Context)

func (*Handler) CreateChallenge

func (h *Handler) CreateChallenge(c *gin.Context)

func (*Handler) DeleteChallenge

func (h *Handler) DeleteChallenge(c *gin.Context)

func (*Handler) DeleteChallengeFile

func (h *Handler) DeleteChallengeFile(c *gin.Context)

func (*Handler) DownloadChallengeFile

func (h *Handler) DownloadChallengeFile(c *gin.Context)

func (*Handler) GetChallenge

func (h *Handler) GetChallenge(c *gin.Context)

func (*Handler) GetChallenges

func (h *Handler) GetChallenges(c *gin.Context)

func (*Handler) GetFlag

func (h *Handler) GetFlag(c *gin.Context)

func (*Handler) GetSolves

func (h *Handler) GetSolves(c *gin.Context)

func (*Handler) UpdateChallenge

func (h *Handler) UpdateChallenge(c *gin.Context)

func (*Handler) UpdateChallengeFile

func (h *Handler) UpdateChallengeFile(c *gin.Context)

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(db *mongo.Database) *Repository

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, c *Challenge) error

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id string) error

func (*Repository) GetAll

func (r *Repository) GetAll(ctx context.Context) ([]Challenge, error)

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id string) (*Challenge, error)

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, id string, update any) error

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repo *Repository) *Service

func (*Service) AddChallengeFile

func (s *Service) AddChallengeFile(ctx context.Context, id string, form *multipart.Form, gc *gin.Context) ([]FileMeta, error)

func (*Service) CleanOrphanFileUploads

func (s *Service) CleanOrphanFileUploads(ctx context.Context) ([]string, error)

func (*Service) CreateChallenge

func (s *Service) CreateChallenge(ctx context.Context, c *Challenge) error

func (*Service) CreateChallengeWithFiles

func (s *Service) CreateChallengeWithFiles(ctx context.Context, c *Challenge, form *multipart.Form, gc *gin.Context) error

func (*Service) DeleteChallenge

func (s *Service) DeleteChallenge(ctx context.Context, id string) error

func (*Service) DeleteChallengeFile

func (s *Service) DeleteChallengeFile(ctx context.Context, id string, fileUUID string, gc *gin.Context) error

func (*Service) FileExistsInChallenge

func (s *Service) FileExistsInChallenge(ctx context.Context, id, fileUUID string) (*FileMeta, error)

func (*Service) GetChallenge

func (s *Service) GetChallenge(ctx context.Context, id string) (*Challenge, error)

func (*Service) GetChallengeFile

func (s *Service) GetChallengeFile(ctx context.Context, id, fileUUID string) (string, string, error)

func (*Service) ListChallenges

func (s *Service) ListChallenges(ctx context.Context) ([]Challenge, error)

func (*Service) UpdateChallenge

func (s *Service) UpdateChallenge(ctx context.Context, id string, update *UpdateChallengeRequest) error

func (*Service) UpdateChallengeFile

func (s *Service) UpdateChallengeFile(ctx context.Context, id string, fileUUID string, form *multipart.Form, gc *gin.Context) error

type UpdateChallengeRequest

type UpdateChallengeRequest struct {
	Title       *string `bson:"title" json:"title"`
	Category    *string `bson:"category" json:"category"`
	Description *string `bson:"description" json:"description"`
	Points      *int    `bson:"points" json:"points"`
	State       *string `bson:"state" json:"state"`
	Type        *string `bson:"type" json:"type"`
	Solves      *int    `bson:"solves" json:"solves"`
	Flag        *string `bson:"flag" json:"flag"`
	Author      *string `bson:"author" json:"author"`
}

Jump to

Keyboard shortcuts

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