ms-tester/internal/services/contest.go

51 lines
1.6 KiB
Go
Raw Normal View History

2024-08-16 16:50:47 +00:00
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)
}
2024-08-16 17:04:49 +00:00
func (service *ContestService) ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
2024-08-16 16:50:47 +00:00
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
2024-08-16 17:04:49 +00:00
return service.contestStorage.ReadContestById(ctx, id)
2024-08-16 16:50:47 +00:00
}
2024-08-16 17:04:49 +00:00
func (service *ContestService) UpdateContest(ctx context.Context, contest *models.Contest) error {
2024-08-16 16:50:47 +00:00
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.contestStorage.UpdateContest(ctx, contest)
}
2024-08-16 17:04:49 +00:00
func (service *ContestService) DeleteContest(ctx context.Context, id int32) error {
2024-08-16 16:50:47 +00:00
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
2024-08-16 17:04:49 +00:00
return service.contestStorage.DeleteContest(ctx, id)
2024-08-16 16:50:47 +00:00
}