ms-auth/internal/users/repository.go
Vyacheslav1557 3b03447d2f feat(user):
2024-12-30 20:04:26 +05:00

34 lines
1 KiB
Go

package users
import (
"context"
"git.sch9.ru/new_gate/ms-auth/internal/models"
)
type Caller interface {
CreateUser(ctx context.Context, username string, password string, role models.Role) (int32, error)
ReadUserByUsername(ctx context.Context, username string) (*models.User, error)
ReadUserById(ctx context.Context, id int32) (*models.User, error)
UpdateUser(ctx context.Context, id int32, username *string, role *models.Role) error
DeleteUser(ctx context.Context, id int32) error
}
type TxCaller interface {
Caller
Commit() error
Rollback() error
}
type PgRepository interface {
BeginTx(ctx context.Context) (TxCaller, error)
C() Caller
}
type ValkeyRepository interface {
CreateSession(ctx context.Context, userId int32, role models.Role) (string, error)
ReadSession(ctx context.Context, sessionId string) (*models.Session, error)
UpdateSession(ctx context.Context, sessionId string) error
DeleteSession(ctx context.Context, sessionId string) error
DeleteAllSessions(ctx context.Context, userId int32) error
}