ubdata

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 6 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
	AddOrganization(ctx context.Context, id int64, name string, systemName string, status string) error
	GetOrganization(ctx context.Context, organizationID int64) (Organization, error)
	ListOrganizations(ctx context.Context) ([]Organization, error)
	GetOrganizationBySystemName(ctx context.Context, systemName string) (Organization, error)
	UpdateOrganization(ctx context.Context, id int64, name string, systemName string, status string) error

	// Role operations
	AddRole(ctx context.Context, roleID int64, organizationID int64, name string, systemName string) error
	UpdateRole(ctx context.Context, roleID int64, name string, systemName string) error
	DeleteRole(ctx context.Context, roleID int64) error
	GetOrganizationRoles(ctx context.Context, organizationID int64) ([]RoleRow, error)

	AddPermissionToRole(ctx context.Context, roleID int64, permission string) error
	RemovePermissionFromRole(ctx context.Context, roleID int64, permission string) error
	GetRolePermissions(ctx context.Context, roleID int64) ([]string, error)

	// User-Role operations
	AddUserToRole(ctx context.Context, userID int64, roleID int64) error
	RemoveUserFromRole(ctx context.Context, userID int64, roleID int64) error
	RemoveAllRolesFromUser(ctx context.Context, userID int64) error
	GetUserOrganizationRoles(ctx context.Context, userID int64, organizationId int64) ([]RoleRow, error)
	ListUserOrganizationRoles(ctx context.Context, userID int64) ([]ListUserOrganizationRolesRow, error)
}

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

func NewDatabase

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

type ListUserOrganizationRolesRow added in v0.0.7

type ListUserOrganizationRolesRow struct {
	OrganizationID         int64
	Organization           string
	OrganizationSystemName string
	RoleID                 int64
	RoleName               string
	RoleSystemName         string
}

type Organization added in v0.0.7

type Organization struct {
	ID         int64
	Name       string
	SystemName string
	Status     string
}

type Permission

type Permission struct {
	PermissionID int64
	SystemName   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) AddOrganization added in v0.0.7

func (a *PostgresAdapter) AddOrganization(ctx context.Context, id int64, name string, systemName string, status string) error

func (*PostgresAdapter) AddPermissionToRole

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

func (*PostgresAdapter) AddRole

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

func (*PostgresAdapter) AddUser

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

func (*PostgresAdapter) AddUserToRole added in v0.0.7

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

func (*PostgresAdapter) DeleteRole added in v0.0.7

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

func (*PostgresAdapter) GetOrganization added in v0.0.7

func (a *PostgresAdapter) GetOrganization(ctx context.Context, organizationID int64) (Organization, error)

func (*PostgresAdapter) GetOrganizationBySystemName added in v0.0.7

func (a *PostgresAdapter) GetOrganizationBySystemName(ctx context.Context, systemName string) (Organization, error)

func (*PostgresAdapter) GetOrganizationRoles added in v0.0.7

func (a *PostgresAdapter) GetOrganizationRoles(ctx context.Context, organizationID int64) ([]RoleRow, error)

func (*PostgresAdapter) GetRolePermissions

func (a *PostgresAdapter) GetRolePermissions(ctx context.Context, roleID int64) ([]string, 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) GetUserOrganizationRoles added in v0.0.7

func (a *PostgresAdapter) GetUserOrganizationRoles(ctx context.Context, userID int64, organizationId int64) ([]RoleRow, error)

func (*PostgresAdapter) ListOrganizations added in v0.0.7

func (a *PostgresAdapter) ListOrganizations(ctx context.Context) ([]Organization, error)

func (*PostgresAdapter) ListUserOrganizationRoles added in v0.0.7

func (a *PostgresAdapter) ListUserOrganizationRoles(ctx context.Context, userID int64) ([]ListUserOrganizationRolesRow, 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 int64, permission string) error

func (*PostgresAdapter) RemoveUserFromRole added in v0.0.7

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

func (*PostgresAdapter) UpdateOrganization added in v0.0.7

func (a *PostgresAdapter) UpdateOrganization(ctx context.Context, id int64, name string, systemName string, status string) error

func (*PostgresAdapter) UpdateRole

func (a *PostgresAdapter) UpdateRole(ctx context.Context, roleID int64, name string, systemName 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
	SystemName string
}

Role represents a role in the system

type RoleRow added in v0.0.7

type RoleRow struct {
	ID         int64
	Name       string
	SystemName string
}

type SQLiteAdapter

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

func NewSQLiteAdapter

func NewSQLiteAdapter(db *sql.DB) *SQLiteAdapter

func (*SQLiteAdapter) AddOrganization added in v0.0.7

func (a *SQLiteAdapter) AddOrganization(ctx context.Context, id int64, name string, systemName string, status string) error

func (*SQLiteAdapter) AddPermissionToRole

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

func (*SQLiteAdapter) AddRole

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

func (*SQLiteAdapter) AddUser

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

func (*SQLiteAdapter) AddUserToRole added in v0.0.7

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

func (*SQLiteAdapter) DeleteRole added in v0.0.7

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

func (*SQLiteAdapter) GetOrganization added in v0.0.7

func (a *SQLiteAdapter) GetOrganization(ctx context.Context, organizationID int64) (Organization, error)

func (*SQLiteAdapter) GetOrganizationBySystemName added in v0.0.7

func (a *SQLiteAdapter) GetOrganizationBySystemName(ctx context.Context, systemName string) (Organization, error)

func (*SQLiteAdapter) GetOrganizationRoles added in v0.0.7

func (a *SQLiteAdapter) GetOrganizationRoles(ctx context.Context, organizationID int64) ([]RoleRow, error)

func (*SQLiteAdapter) GetRolePermissions

func (a *SQLiteAdapter) GetRolePermissions(ctx context.Context, roleID int64) ([]string, 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) GetUserOrganizationRoles added in v0.0.7

func (a *SQLiteAdapter) GetUserOrganizationRoles(ctx context.Context, userID int64, organizationId int64) ([]RoleRow, error)

func (*SQLiteAdapter) ListOrganizations added in v0.0.7

func (a *SQLiteAdapter) ListOrganizations(ctx context.Context) ([]Organization, error)

func (*SQLiteAdapter) ListUserOrganizationRoles added in v0.0.7

func (a *SQLiteAdapter) ListUserOrganizationRoles(ctx context.Context, userID int64) ([]ListUserOrganizationRolesRow, 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 int64, permission string) error

func (*SQLiteAdapter) RemoveUserFromRole added in v0.0.7

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

func (*SQLiteAdapter) UpdateOrganization added in v0.0.7

func (a *SQLiteAdapter) UpdateOrganization(ctx context.Context, id int64, name string, systemName string, status string) error

func (*SQLiteAdapter) UpdateRole

func (a *SQLiteAdapter) UpdateRole(ctx context.Context, roleID int64, name string, systemName 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