This commit is contained in:
dragonmuffin 2024-08-25 21:20:14 +05:00
parent 3a1e382687
commit 7b0e1b21f1
2 changed files with 7 additions and 7 deletions

View file

@ -2,11 +2,11 @@ package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/languages"
"git.sch9.ru/new_gate/ms-tester/internal/models"
)
type LanguageStorage interface {
ReadLanguageById(ctx context.Context, id int32) (*languages.Language, error)
ReadLanguageById(ctx context.Context, id int32) (*models.Language, error)
}
type LanguageService struct {
@ -21,7 +21,7 @@ func NewLanguageService(
}
}
func (service *LanguageService) ReadLanguageById(ctx context.Context, id int32) (*languages.Language, error) {
func (service *LanguageService) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) {
//userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.languageStorage.ReadLanguageById(ctx, id)

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/languages"
"git.sch9.ru/new_gate/ms-tester/internal/models"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@ -20,9 +20,9 @@ func NewLanguageStorage(db *sqlx.DB, logger *zap.Logger) *LanguageStorage {
}
}
func (storage *LanguageStorage) ReadLanguageById(ctx context.Context, id int32) (*languages.Language, error) {
if(id<=int32(len(languages.Languages))) {
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")
}
return &languages.Languages[id], nil
return &models.Languages[id], nil
}