fix: make it runnable
This commit is contained in:
parent
c9c4fc65e7
commit
bf508a5f1f
23 changed files with 311 additions and 286 deletions
|
@ -25,26 +25,25 @@ func NewContestService(
|
|||
}
|
||||
|
||||
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")
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.CreateContest(ctx, contest)
|
||||
}
|
||||
|
||||
func (service *ContestService) ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.ReadContestById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *ContestService) UpdateContest(ctx context.Context, contest *models.Contest) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.UpdateContest(ctx, contest)
|
||||
}
|
||||
|
||||
func (service *ContestService) DeleteContest(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.contestStorage.DeleteContest(ctx, id)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,25 +25,25 @@ func NewLanguageService(
|
|||
}
|
||||
|
||||
func (service *LanguageService) CreateLanguage(ctx context.Context, language *models.Language) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.languageStorage.CreateLanguage(ctx, language)
|
||||
}
|
||||
|
||||
func (service *LanguageService) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.languageStorage.ReadLanguageById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *LanguageService) UpdateLanguage(ctx context.Context, language *models.Language) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.languageStorage.UpdateLanguage(ctx, language)
|
||||
}
|
||||
|
||||
func (service *LanguageService) DeleteLanguage(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.languageStorage.DeleteLanguage(ctx, id)
|
||||
}
|
||||
|
|
|
@ -25,25 +25,25 @@ func NewParticipantService(
|
|||
}
|
||||
|
||||
func (service *ParticipantService) CreateParticipant(ctx context.Context, participant *models.Participant) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.participantStorage.CreateParticipant(ctx, participant)
|
||||
}
|
||||
|
||||
func (service *ParticipantService) ReadParticipantById(ctx context.Context, id int32) (*models.Participant, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.participantStorage.ReadParticipantById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *ParticipantService) UpdateParticipant(ctx context.Context, participant *models.Participant) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.participantStorage.UpdateParticipant(ctx, participant)
|
||||
}
|
||||
|
||||
func (service *ParticipantService) DeleteParticipant(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.participantStorage.DeleteParticipant(ctx, id)
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
)
|
||||
|
||||
type ProblemStorage interface {
|
||||
CreateProblem(ctx context.Context, problem *models.Problem) (int32, error)
|
||||
CreateProblem(ctx context.Context, problem *models.Problem, testGroupData []models.TestGroupData) (int32, error)
|
||||
ReadProblemById(ctx context.Context, id int32) (*models.Problem, error)
|
||||
UpdateProblem(ctx context.Context, problem *models.Problem) error
|
||||
DeleteProblem(ctx context.Context, id int32) error
|
||||
}
|
||||
|
||||
type PandocClient interface {
|
||||
ConvertLatexToHtml5(text string) (string, error)
|
||||
ConvertLatexToHtml5(ctx context.Context, text string) (string, error)
|
||||
}
|
||||
|
||||
type ProblemService struct {
|
||||
|
@ -32,29 +32,29 @@ func NewProblemService(
|
|||
}
|
||||
|
||||
func (service *ProblemService) CreateProblem(ctx context.Context, problem *models.Problem, ch <-chan []byte) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
html, err := service.pandocClient.ConvertLatexToHtml5(*problem.Description)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
//html, err := service.pandocClient.ConvertLatexToHtml5(*problem.Description)
|
||||
//if err != nil {
|
||||
// return 0, err
|
||||
//}
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.CreateProblem(ctx, problem)
|
||||
//return service.problemStorage.CreateProblem(ctx, problem)
|
||||
}
|
||||
|
||||
func (service *ProblemService) ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.ReadProblemById(ctx, id)
|
||||
//return service.problemStorage.ReadProblemById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *ProblemService) UpdateProblem(ctx context.Context, problem *models.Problem) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.UpdateProblem(ctx, problem)
|
||||
//return service.problemStorage.UpdateProblem(ctx, problem)
|
||||
}
|
||||
|
||||
func (service *ProblemService) DeleteProblem(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.DeleteProblem(ctx, id)
|
||||
//return service.problemStorage.DeleteProblem(ctx, id)
|
||||
}
|
||||
|
|
|
@ -1,50 +1,49 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||
"context"
|
||||
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||
)
|
||||
|
||||
type SolutionStorage interface {
|
||||
CreateSolution(ctx context.Context, models.Solution) (int32, error)
|
||||
ReadSolutionById(ctx context.Context, id int32) (models.Solution, error)
|
||||
RejudgeSolution(ctx context.Context, id int32) error
|
||||
DeleteSolution(ctx context.Context, id int32) error
|
||||
CreateSolution(ctx context.Context, solution models.Solution) (int32, error)
|
||||
ReadSolutionById(ctx context.Context, id int32) (models.Solution, error)
|
||||
RejudgeSolution(ctx context.Context, id int32) error
|
||||
DeleteSolution(ctx context.Context, id int32) error
|
||||
}
|
||||
|
||||
type SolutionService struct {
|
||||
solutionStorage SolutionStorage
|
||||
solutionStorage SolutionStorage
|
||||
}
|
||||
|
||||
func NewSolutionService(
|
||||
solutionStorage SolutionStorage,
|
||||
solutionStorage SolutionStorage,
|
||||
) *SolutionService {
|
||||
return &SolutionService{
|
||||
solutionStorage: solutionStorage,
|
||||
}
|
||||
return &SolutionService{
|
||||
solutionStorage: solutionStorage,
|
||||
}
|
||||
}
|
||||
|
||||
func (service *SolutionService) CreateSolution(ctx context.Context, solution models.Solution) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.CreateSolution(ctx, solution)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.CreateSolution(ctx, solution)
|
||||
}
|
||||
|
||||
func (service *SolutionService) ReadSolutionById(ctx context.Context, id int32) (models.Solution, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.ReadSolutionById(ctx, id)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.ReadSolutionById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *SolutionService) RejudgeSolution(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.RejudgeSolution(ctx, id)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.RejudgeSolution(ctx, id)
|
||||
}
|
||||
|
||||
func (service *SolutionService) DeleteSolution(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.DeleteSolution(ctx, id)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.solutionStorage.DeleteSolution(ctx, id)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||
"context"
|
||||
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||
)
|
||||
|
||||
type TaskStorage interface {
|
||||
CreateTask(ctx context.Context, models.Task) (int32, error)
|
||||
DeleteTask(ctx context.Context, id int32) error
|
||||
CreateTask(ctx context.Context, task models.Task) (int32, error)
|
||||
DeleteTask(ctx context.Context, id int32) error
|
||||
}
|
||||
|
||||
type TaskService struct {
|
||||
taskStorage TaskStorage
|
||||
taskStorage TaskStorage
|
||||
}
|
||||
|
||||
func NewTaskService(
|
||||
taskStorage TaskStorage,
|
||||
taskStorage TaskStorage,
|
||||
) *TaskService {
|
||||
return &TaskService{
|
||||
taskStorage: taskStorage,
|
||||
}
|
||||
return &TaskService{
|
||||
taskStorage: taskStorage,
|
||||
}
|
||||
}
|
||||
|
||||
func (service *TaskService) CreateTask(ctx context.Context, task models.Task) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.taskStorage.CreateTask(ctx, task)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.taskStorage.CreateTask(ctx, task)
|
||||
}
|
||||
|
||||
func (service *TaskService) DeleteTask(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.taskStorage.DeleteTask(ctx, id)
|
||||
//userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
return service.taskStorage.DeleteTask(ctx, id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue