fix
This commit is contained in:
parent
3a1e382687
commit
7b0e1b21f1
2 changed files with 7 additions and 7 deletions
|
@ -2,11 +2,11 @@ package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"git.sch9.ru/new_gate/ms-tester/internal/languages"
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LanguageStorage interface {
|
type LanguageStorage interface {
|
||||||
ReadLanguageById(ctx context.Context, id int32) (*languages.Language, error)
|
ReadLanguageById(ctx context.Context, id int32) (*models.Language, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LanguageService struct {
|
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)
|
//userId := ctx.Value("user_id").(int32)
|
||||||
panic("access control is not implemented yet")
|
panic("access control is not implemented yet")
|
||||||
return service.languageStorage.ReadLanguageById(ctx, id)
|
return service.languageStorage.ReadLanguageById(ctx, id)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
"git.sch9.ru/new_gate/ms-tester/internal/lib"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"go.uber.org/zap"
|
"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) {
|
func (storage *LanguageStorage) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) {
|
||||||
if(id<=int32(len(languages.Languages))) {
|
if(id<=int32(len(models.Languages))) {
|
||||||
return nil,lib.StorageError(nil,lib.ErrNotFound,"language not found")
|
return nil,lib.StorageError(nil,lib.ErrNotFound,"language not found")
|
||||||
}
|
}
|
||||||
return &languages.Languages[id], nil
|
return &models.Languages[id], nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue