refactor(tester): refactor api

This commit is contained in:
Vyacheslav1557 2025-03-29 00:36:23 +05:00
parent 3396746d60
commit 5536c086e0
11 changed files with 257 additions and 231 deletions

View file

@ -16,6 +16,20 @@ type ContestsListItem struct {
UpdatedAt time.Time `db:"updated_at"`
}
type ContestsList struct {
Contests []*ContestsListItem
Pagination Pagination
}
type ContestsFilter struct {
Page int32
PageSize int32
}
func (f ContestsFilter) Offset() int32 {
return (f.Page - 1) * f.PageSize
}
type ContestUpdate struct {
Title *string `json:"title"`
}

View file

@ -0,0 +1,6 @@
package models
type Pagination struct {
Page int32 `json:"page"`
Total int32 `json:"total"`
}

View file

@ -20,6 +20,22 @@ type ParticipantsListItem struct {
UpdatedAt time.Time `db:"updated_at"`
}
type ParticipantsList struct {
Participants []*ParticipantsListItem
Pagination Pagination
}
type ParticipantsFilter struct {
Page int32
PageSize int32
ContestId int32
}
func (f ParticipantsFilter) Offset() int32 {
return (f.Page - 1) * f.PageSize
}
type ParticipantUpdate struct {
Name *string `json:"name"`
}

View file

@ -25,7 +25,7 @@ type Problem struct {
UpdatedAt time.Time `db:"updated_at"`
}
type ProblemListItem struct {
type ProblemsListItem struct {
Id int32 `db:"id"`
Title string `db:"title"`
MemoryLimit int32 `db:"memory_limit"`
@ -34,6 +34,20 @@ type ProblemListItem struct {
UpdatedAt time.Time `db:"updated_at"`
}
type ProblemsList struct {
Problems []*ProblemsListItem `json:"problems"`
Pagination Pagination `json:"pagination"`
}
type ProblemsFilter struct {
Page int32
PageSize int32
}
func (f ProblemsFilter) Offset() int32 {
return (f.Page - 1) * f.PageSize
}
type ProblemUpdate struct {
Title *string `db:"title"`
MemoryLimit *int32 `db:"memory_limit"`

View file

@ -38,6 +38,11 @@ type SolutionsListItem struct {
CreatedAt time.Time `db:"created_at"`
}
type SolutionsList struct {
Solutions []*SolutionsListItem
Pagination Pagination
}
type SolutionsFilter struct {
Page int32
PageSize int32
@ -49,6 +54,10 @@ type SolutionsFilter struct {
Order *int32
}
func (f SolutionsFilter) Offset() int32 {
return (f.Page - 1) * f.PageSize
}
//type Result int32
//
//const (