ubdata

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataAdapter

type DataAdapter interface {
	// User operations
	AddUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error
	GetUser(ctx context.Context, userID int64) (User, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	UpdateUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error

	// Role operations
	AddRole(ctx context.Context, roleID int64, name string) error
	UpdateRole(ctx context.Context, roleID int64, name string) error
	GetRoles(ctx context.Context) ([]Role, error)

	// Permission operations
	CreatePermission(ctx context.Context, name string) (int64, error)
	GetPermissions(ctx context.Context) ([]Permission, error)

	// Role-Permission operations
	AddPermissionToRole(ctx context.Context, roleID, permissionID int64) error
	RemovePermissionFromRole(ctx context.Context, roleID, permissionID int64) error
	GetRolePermissions(ctx context.Context, roleID int64) ([]Permission, error)

	// User-Role operations
	AddRoleToUser(ctx context.Context, userID, roleID int64) error
	RemoveAllRolesFromUser(ctx context.Context, userID int64) error
	GetUserRoles(ctx context.Context, userID int64) ([]Role, error)
	GetUserPermissions(ctx context.Context, userID int64) ([]Permission, error)

	ProjectUser(ctx context.Context, userID int64, userState ubstate.UserState) error
	ProjectUserRoles(ctx context.Context, userID int64, stateRoles []int64) error
}

DataAdapter defines the common interface for user/role/permission operations

func NewDatabase

func NewDatabase(dbType ubconst.DatabaseType, db *sql.DB) DataAdapter

type Permission

type Permission struct {
	PermissionID int64
	Name         string
}

Permission represents a permission in the system

type PostgresAdapter

type PostgresAdapter struct {
	// contains filtered or unexported fields
}

func NewPostgresAdapter

func NewPostgresAdapter(db *sql.DB) *PostgresAdapter

func (*PostgresAdapter) AddPermissionToRole

func (a *PostgresAdapter) AddPermissionToRole(ctx context.Context, roleID, permissionID int64) error

func (*PostgresAdapter) AddRole

func (a *PostgresAdapter) AddRole(ctx context.Context, roleID int64, name string) error

func (*PostgresAdapter) AddRoleToUser

func (a *PostgresAdapter) AddRoleToUser(ctx context.Context, userID, roleID int64) error

func (*PostgresAdapter) AddUser

func (a *PostgresAdapter) AddUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error

func (*PostgresAdapter) CreatePermission

func (a *PostgresAdapter) CreatePermission(ctx context.Context, name string) (int64, error)

func (*PostgresAdapter) GetPermissions

func (a *PostgresAdapter) GetPermissions(ctx context.Context) ([]Permission, error)

func (*PostgresAdapter) GetRolePermissions

func (a *PostgresAdapter) GetRolePermissions(ctx context.Context, roleID int64) ([]Permission, error)

func (*PostgresAdapter) GetRoles

func (a *PostgresAdapter) GetRoles(ctx context.Context) ([]Role, error)

func (*PostgresAdapter) GetUser

func (a *PostgresAdapter) GetUser(ctx context.Context, userID int64) (User, error)

func (*PostgresAdapter) GetUserByEmail

func (a *PostgresAdapter) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*PostgresAdapter) GetUserPermissions

func (a *PostgresAdapter) GetUserPermissions(ctx context.Context, userID int64) ([]Permission, error)

func (*PostgresAdapter) GetUserRoles

func (a *PostgresAdapter) GetUserRoles(ctx context.Context, userID int64) ([]Role, error)

func (*PostgresAdapter) ProjectUser

func (a *PostgresAdapter) ProjectUser(ctx context.Context, userID int64, userState ubstate.UserState) error

func (*PostgresAdapter) ProjectUserRoles

func (a *PostgresAdapter) ProjectUserRoles(ctx context.Context, userID int64, stateRoles []int64) error

func (*PostgresAdapter) RemoveAllRolesFromUser

func (a *PostgresAdapter) RemoveAllRolesFromUser(ctx context.Context, userID int64) error

func (*PostgresAdapter) RemovePermissionFromRole

func (a *PostgresAdapter) RemovePermissionFromRole(ctx context.Context, roleID, permissionID int64) error

func (*PostgresAdapter) UpdateRole

func (a *PostgresAdapter) UpdateRole(ctx context.Context, roleID int64, name string) error

func (*PostgresAdapter) UpdateUser

func (a *PostgresAdapter) UpdateUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error

type Role

type Role struct {
	RoleID int64
	Name   string
}

Role represents a role in the system

type SQLiteAdapter

type SQLiteAdapter struct {
	// contains filtered or unexported fields
}

func NewSQLiteAdapter

func NewSQLiteAdapter(db *sql.DB) *SQLiteAdapter

func (*SQLiteAdapter) AddPermissionToRole

func (a *SQLiteAdapter) AddPermissionToRole(ctx context.Context, roleID, permissionID int64) error

func (*SQLiteAdapter) AddRole

func (a *SQLiteAdapter) AddRole(ctx context.Context, roleID int64, name string) error

func (*SQLiteAdapter) AddRoleToUser

func (a *SQLiteAdapter) AddRoleToUser(ctx context.Context, userID, roleID int64) error

func (*SQLiteAdapter) AddUser

func (a *SQLiteAdapter) AddUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error

func (*SQLiteAdapter) CreatePermission

func (a *SQLiteAdapter) CreatePermission(ctx context.Context, name string) (int64, error)

func (*SQLiteAdapter) GetPermissions

func (a *SQLiteAdapter) GetPermissions(ctx context.Context) ([]Permission, error)

func (*SQLiteAdapter) GetRolePermissions

func (a *SQLiteAdapter) GetRolePermissions(ctx context.Context, roleID int64) ([]Permission, error)

func (*SQLiteAdapter) GetRoles

func (a *SQLiteAdapter) GetRoles(ctx context.Context) ([]Role, error)

func (*SQLiteAdapter) GetUser

func (a *SQLiteAdapter) GetUser(ctx context.Context, userID int64) (User, error)

func (*SQLiteAdapter) GetUserByEmail

func (a *SQLiteAdapter) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*SQLiteAdapter) GetUserPermissions

func (a *SQLiteAdapter) GetUserPermissions(ctx context.Context, userID int64) ([]Permission, error)

func (*SQLiteAdapter) GetUserRoles

func (a *SQLiteAdapter) GetUserRoles(ctx context.Context, userID int64) ([]Role, error)

func (*SQLiteAdapter) ProjectUser

func (a *SQLiteAdapter) ProjectUser(ctx context.Context, userID int64, userState ubstate.UserState) error

func (*SQLiteAdapter) ProjectUserRoles

func (a *SQLiteAdapter) ProjectUserRoles(ctx context.Context, userID int64, stateRoles []int64) error

func (*SQLiteAdapter) RemoveAllRolesFromUser

func (a *SQLiteAdapter) RemoveAllRolesFromUser(ctx context.Context, userID int64) error

func (*SQLiteAdapter) RemovePermissionFromRole

func (a *SQLiteAdapter) RemovePermissionFromRole(ctx context.Context, roleID, permissionID int64) error

func (*SQLiteAdapter) UpdateRole

func (a *SQLiteAdapter) UpdateRole(ctx context.Context, roleID int64, name string) error

func (*SQLiteAdapter) UpdateUser

func (a *SQLiteAdapter) UpdateUser(ctx context.Context, userID int64, firstName, lastName, displayName, email string) error

type User

type User struct {
	UserID      int64
	FirstName   string
	LastName    string
	DisplayName string
	Email       string
}

User represents a user in the system

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL