add contest service
This commit is contained in:
parent
3fed9d7c03
commit
dc032b4dd3
1 changed files with 50 additions and 0 deletions
50
internal/services/contest.go
Normal file
50
internal/services/contest.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||
)
|
||||
|
||||
type ContestStorage interface {
|
||||
CreateContest(ctx context.Context, contest *models.Contest) (int32, error)
|
||||
ReadContestById(ctx context.Context, id int32) (*models.Contest, error)
|
||||
UpdateContest(ctx context.Context, contest *models.Contest) error
|
||||
DeleteContest(ctx context.Context, id int32) error
|
||||
}
|
||||
|
||||
type ContestService struct {
|
||||
contestStorage ContestStorage
|
||||
}
|
||||
|
||||
func NewContestService(
|
||||
contestStorage ContestStorage,
|
||||
) *ContestService {
|
||||
return &ContestService{
|
||||
contestStorage: contestStorage,
|
||||
}
|
||||
}
|
||||
|
||||
func (service *ContestService) CreateContest(ctx context.Context, contest *models.Contest) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.CreateContest(ctx, contest)
|
||||
}
|
||||
|
||||
func ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.ReadContestById(ctx, contest)
|
||||
}
|
||||
|
||||
func UpdateContest(ctx context.Context, contest *models.Contest) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.UpdateContest(ctx, contest)
|
||||
}
|
||||
|
||||
func DeleteContest(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.DeleteContest(ctx, contest)
|
||||
}
|
||||
|
Loading…
Reference in a new issue