skeleton added
This commit is contained in:
11
domain/admin/interface.go
Normal file
11
domain/admin/interface.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"tgVideoCall/domain/admin/models"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
GetAdmin(ctx context.Context,userID int) (models.Admin, error)
|
||||
}
|
||||
14
domain/admin/models/models.go
Normal file
14
domain/admin/models/models.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotAdmin = errors.New("user is not admin")
|
||||
)
|
||||
|
||||
type Admin struct {
|
||||
UserID int64 `db:"user_id"`
|
||||
Role string `db:"role"`
|
||||
}
|
||||
31
domain/admin/service.go
Normal file
31
domain/admin/service.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"tgVideoCall/gates/storage"
|
||||
"tgVideoCall/domain/admin/models"
|
||||
"tgVideoCall/pkg/config"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
log slog.Logger
|
||||
cfg config.Config
|
||||
ctx context.Context
|
||||
db Storage
|
||||
}
|
||||
|
||||
func NewService(ctx context.Context, cfg config.Config, log slog.Logger, db *storage.DB) *Service {
|
||||
return &Service{
|
||||
log: log,
|
||||
db: db,
|
||||
cfg: cfg,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Service) GetAdmin(ctx context.Context, userID int) (models.Admin, error) {
|
||||
return s.db.GetAdmin(ctx, userID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user