This commit is contained in:
Vyacheslav1557 2024-10-05 21:05:29 +05:00
parent 30ac81b789
commit 81e75e5a9c
22 changed files with 42 additions and 29 deletions

View file

@ -3,7 +3,7 @@ package lib
type Config struct {
Env string `env:"ENV" env-default:"prod"`
Pandoc string `env:"PANDOC" required:"true"`
Auth string `env:"PANDOC" required:"true"`
Auth string `env:"AUTH" required:"true"`
Address string `env:"ADDRESS" required:"true"`
PostgresDSN string `env:"POSTGRES_DSN" required:"true"`
}

View file

@ -2,8 +2,8 @@ package services
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
)
type ContestStorage interface {

View file

@ -2,7 +2,7 @@ package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
)
type LanguageStorage interface {

View file

@ -2,8 +2,8 @@ package services
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
)
type ParticipantStorage interface {

View file

@ -2,7 +2,7 @@ package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/open-policy-agent/opa/rego"
)

View file

@ -2,8 +2,8 @@ package services
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
)
type ProblemStorage interface {
@ -30,12 +30,12 @@ type ProblemService struct {
func NewProblemService(
problemStorage ProblemStorage,
pandocClient PandocClient,
permissionService IPermissionService,
permissionService IPermissionService,
) *ProblemService {
return &ProblemService{
problemStorage: problemStorage,
pandocClient: pandocClient,
permissionService: permissionService,
permissionService: permissionService,
}
}

View file

@ -2,8 +2,8 @@ package services
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
)
type SolutionStorage interface {

View file

@ -2,8 +2,8 @@ package services
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
)
type TaskStorage interface {

View file

@ -2,7 +2,7 @@ package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
)
type UserStorage interface {

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@ -21,8 +21,8 @@ func NewLanguageStorage(db *sqlx.DB, logger *zap.Logger) *LanguageStorage {
}
func (storage *LanguageStorage) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) {
if(id<=int32(len(models.Languages))) {
return nil,lib.StorageError(nil,lib.ErrNotFound,"language not found")
}
if id <= int32(len(models.Languages)) {
return nil, lib.StorageError(nil, lib.ErrNotFound, "language not found")
}
return &models.Languages[id], nil
}

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)

View file

@ -3,7 +3,7 @@ package storage
import (
"context"
"errors"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
"github.com/jmoiron/sqlx"
)

View file

@ -3,8 +3,8 @@ package transport
import (
"context"
"errors"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
sessionv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/session/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"

View file

@ -2,8 +2,8 @@ package transport
import (
"context"
"git.sch9.ru/new_gate/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
problemv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/problem/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

View file

@ -2,7 +2,7 @@ package transport
import (
"context"
"git.sch9.ru/new_gate/ms-tester/pkg/models"
"git.sch9.ru/new_gate/models"
problemv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/problem/v1"
sessionv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/session/v1"
"go.uber.org/zap"
@ -58,10 +58,14 @@ func NewTesterServer(
}
grpcServer := grpc.NewServer(
grpc.UnaryInterceptor(server.ErrUnwrappingUnaryInterceptor()),
grpc.StreamInterceptor(server.ErrUnwrappingStreamInterceptor()),
grpc.UnaryInterceptor(server.AuthUnaryInterceptor()),
grpc.StreamInterceptor(server.AuthStreamInterceptor()),
grpc.ChainUnaryInterceptor(
server.ErrUnwrappingUnaryInterceptor(),
server.AuthUnaryInterceptor(),
),
grpc.ChainStreamInterceptor(
server.ErrUnwrappingStreamInterceptor(),
server.AuthStreamInterceptor(),
),
)
problemv1.RegisterProblemServiceServer(grpcServer, server)