postgresql

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

func NewRepository

func NewRepository(ctx context.Context, cfg *sqlutils.Config) (*Repository, error)

func (*Repository) ArchiveOldSessions

func (r *Repository) ArchiveOldSessions(ctx context.Context, retentionDays int) (int64, error)

ArchiveOldSessions moves old sessions to archive table (archive pattern approach 3)

func (*Repository) AssignPermissionToGroup

func (r *Repository) AssignPermissionToGroup(ctx context.Context, groupID, permissionID, grantedBy int64) error

AssignPermissionToGroup assigns a permission to a group

func (*Repository) AssignPermissionToUser

func (r *Repository) AssignPermissionToUser(ctx context.Context, userID, permissionID, grantedBy int64, expiresAt *int64) error

AssignPermissionToUser assigns a permission directly to a user

func (*Repository) AssignPermissionsToGroup

func (r *Repository) AssignPermissionsToGroup(ctx context.Context, groupID int64, permissionIDs []int64, grantedBy int64) error

AssignPermissionsToGroup assigns multiple permissions to a group in a single transaction

func (*Repository) AssignPermissionsToUser

func (r *Repository) AssignPermissionsToUser(ctx context.Context, userID int64, permissionIDs []int64, grantedBy int64, expiresAt *int64) error

AssignPermissionsToUser assigns multiple permissions directly to a user in a single transaction

func (*Repository) AssignUserToGroup

func (r *Repository) AssignUserToGroup(ctx context.Context, userID, groupID int64, assignedBy int64, expiresAt *int64) error

AssignUserToGroup assigns a user to a group

func (*Repository) AssignUsersToGroup

func (r *Repository) AssignUsersToGroup(ctx context.Context, userIDs []int64, groupID int64, assignedBy int64, expiresAt *int64) error

AssignUsersToGroup assigns multiple users to a group in a single transaction

func (*Repository) CheckEmailExists

func (r *Repository) CheckEmailExists(ctx context.Context, email string) (bool, error)

CheckEmailExists checks if an email already exists

func (*Repository) CheckGroupNameExists

func (r *Repository) CheckGroupNameExists(ctx context.Context, name string) (bool, error)

CheckGroupNameExists checks if a group name already exists

func (*Repository) CheckUsernameExists

func (r *Repository) CheckUsernameExists(ctx context.Context, username string) (bool, error)

CheckUsernameExists checks if a username already exists

func (*Repository) CleanupOldSessions

func (r *Repository) CleanupOldSessions(ctx context.Context, retentionDays int) (int64, error)

CleanupOldSessions deletes old inactive sessions (cleanup strategy approach 2)

func (*Repository) CountUserProfiles

func (r *Repository) CountUserProfiles(ctx context.Context, userUUID string) (int32, error)

CountUserProfiles returns the total number of profiles for a user

func (*Repository) CreateConfig

func (r *Repository) CreateConfig(ctx context.Context, config *dao.Config) error

CreateConfig creates a new config in the database

func (*Repository) CreateConfigEntity

func (r *Repository) CreateConfigEntity(ctx context.Context, entity *dao.ConfigEntity) error

CreateConfigEntity creates a new config entity in the database

func (*Repository) CreateGroup

func (r *Repository) CreateGroup(ctx context.Context, group *dao.Group) (*dao.Group, error)

CreateGroup creates a new group in the database

func (*Repository) CreateOTPVerification

func (r *Repository) CreateOTPVerification(ctx context.Context, otp *dao.OTPVerification) error

CreateOTPVerification creates a new OTP verification record

func (*Repository) CreatePermission

func (r *Repository) CreatePermission(ctx context.Context, permission *dao.Permission) (*dao.Permission, error)

CreatePermission creates a new permission in the database

func (*Repository) CreateSession

func (r *Repository) CreateSession(ctx context.Context, session *dao.Session) (*dao.Session, error)

CreateSession creates a new session in the database

func (*Repository) CreateUser

func (r *Repository) CreateUser(ctx context.Context, user *dao.User) (*dao.User, error)

CreateUser creates a new user in the database

func (*Repository) CreateUserProfile

func (r *Repository) CreateUserProfile(ctx context.Context, profile *dao.Profile) (*dao.Profile, error)

CreateUserProfile creates a new user profile in the database

func (*Repository) DeleteConfig

func (r *Repository) DeleteConfig(ctx context.Context, id int64) error

DeleteConfig deletes a config

func (*Repository) DeleteConfigEntity

func (r *Repository) DeleteConfigEntity(ctx context.Context, id int64) error

DeleteConfigEntity deletes a config entity

func (*Repository) DeleteGroup

func (r *Repository) DeleteGroup(ctx context.Context, id int64) error

DeleteGroup deletes a group from the database

func (*Repository) DeleteOTPVerification

func (r *Repository) DeleteOTPVerification(ctx context.Context, identifier, otpType string) error

DeleteOTPVerification deletes OTP verification records

func (*Repository) DeletePermission

func (r *Repository) DeletePermission(ctx context.Context, id int64) error

DeletePermission deletes a permission by ID

func (*Repository) DeleteProfileByUUID

func (r *Repository) DeleteProfileByUUID(ctx context.Context, uuid string) error

DeleteProfileByUUID deletes a profile by its UUID

func (*Repository) DeleteSession

func (r *Repository) DeleteSession(ctx context.Context, sessionUUID string) error

DeleteSession deletes a session by its UUID

func (*Repository) DeleteUser

func (r *Repository) DeleteUser(ctx context.Context, id int64, softDelete bool) error

DeleteUser deletes or deactivates a user

func (*Repository) DeleteUserSessions

func (r *Repository) DeleteUserSessions(ctx context.Context, userUUID string) error

DeleteUserSessions deletes all sessions for a user

func (*Repository) GetActiveSessionsCount

func (r *Repository) GetActiveSessionsCount(ctx context.Context, userUUID string) (int32, error)

GetActiveSessionsCount returns count of active sessions for a user

func (*Repository) GetActiveUsers

func (r *Repository) GetActiveUsers(ctx context.Context) (int64, error)

GetActiveUsers returns the number of users with active sessions

func (*Repository) GetArchivedSessions

func (r *Repository) GetArchivedSessions(ctx context.Context, userUUID string, limit, offset int) ([]*dao.SessionArchive, error)

GetArchivedSessions retrieves archived sessions for a user

func (*Repository) GetConfigByEntityAndKey

func (r *Repository) GetConfigByEntityAndKey(ctx context.Context, entityID int64, key string) (*dao.Config, error)

GetConfigByEntityAndKey retrieves a config by entity ID and key

func (*Repository) GetConfigByEntityNameAndKey

func (r *Repository) GetConfigByEntityNameAndKey(ctx context.Context, entityName, key string) (*dao.Config, error)

GetConfigByEntityNameAndKey retrieves a config by entity name and key

func (*Repository) GetConfigByID

func (r *Repository) GetConfigByID(ctx context.Context, id int64) (*dao.Config, error)

GetConfigByID retrieves a config by ID

func (*Repository) GetConfigEntityByID

func (r *Repository) GetConfigEntityByID(ctx context.Context, id int64) (*dao.ConfigEntity, error)

GetConfigEntityByID retrieves a config entity by ID

func (*Repository) GetConfigEntityByName

func (r *Repository) GetConfigEntityByName(ctx context.Context, name string) (*dao.ConfigEntity, error)

GetConfigEntityByName retrieves a config entity by name

func (*Repository) GetConfigsByEntityAndKeys

func (r *Repository) GetConfigsByEntityAndKeys(ctx context.Context, entityID int64, keys []string) (map[string]*dao.Config, error)

GetConfigsByEntityAndKeys retrieves multiple configs by entity ID and keys

func (*Repository) GetConfigsByEntityNameAndKeys

func (r *Repository) GetConfigsByEntityNameAndKeys(ctx context.Context, entityName string, keys []string) (map[string]*dao.Config, error)

GetConfigsByEntityNameAndKeys retrieves multiple configs by entity name and keys

func (*Repository) GetGroupByID

func (r *Repository) GetGroupByID(ctx context.Context, id int64) (*dao.Group, error)

GetGroupByID retrieves a group by its ID

func (*Repository) GetGroupByName

func (r *Repository) GetGroupByName(ctx context.Context, name string) (*dao.Group, error)

GetGroupByName retrieves a group by its name

func (*Repository) GetGroupByUUID

func (r *Repository) GetGroupByUUID(ctx context.Context, uuid string) (*dao.Group, error)

GetGroupByUUID retrieves a group by its UUID

func (*Repository) GetOTPVerification

func (r *Repository) GetOTPVerification(ctx context.Context, identifier, code string) (*dao.OTPVerification, error)

GetOTPVerification retrieves an OTP verification record

func (*Repository) GetPermissionByID

func (r *Repository) GetPermissionByID(ctx context.Context, id int64) (*dao.Permission, error)

GetPermissionByID retrieves a permission by its ID

func (*Repository) GetPermissionByName

func (r *Repository) GetPermissionByName(ctx context.Context, name string) (*dao.Permission, error)

GetPermissionByName retrieves a permission by its name

func (*Repository) GetProfileByUUID

func (r *Repository) GetProfileByUUID(ctx context.Context, uuid string) (*dao.Profile, error)

GetProfileByUUID retrieves a profile by its UUID

func (*Repository) GetSessionByRefreshToken

func (r *Repository) GetSessionByRefreshToken(ctx context.Context, refreshToken string) (*dao.Session, error)

GetSessionByRefreshToken retrieves a session by its refresh token

func (*Repository) GetSessionByToken

func (r *Repository) GetSessionByToken(ctx context.Context, sessionToken string) (*dao.Session, error)

GetSessionByToken retrieves a session by its session token

func (*Repository) GetSessionByUUID

func (r *Repository) GetSessionByUUID(ctx context.Context, sessionUUID string) (*dao.Session, error)

GetSessionByUUID retrieves a session by its UUID

func (*Repository) GetTotalGroups

func (r *Repository) GetTotalGroups(ctx context.Context) (int64, error)

GetTotalGroups returns the total number of groups in the system

func (*Repository) GetTotalPermissions

func (r *Repository) GetTotalPermissions(ctx context.Context) (int64, error)

GetTotalPermissions returns the total number of permissions in the system

func (*Repository) GetTotalUsers

func (r *Repository) GetTotalUsers(ctx context.Context) (int64, error)

GetTotalUsers returns the total number of users in the system

func (*Repository) GetUserByEmail

func (r *Repository) GetUserByEmail(ctx context.Context, email string) (*dao.User, error)

GetUserByEmail retrieves a user by email

func (*Repository) GetUserByID

func (r *Repository) GetUserByID(ctx context.Context, id int64) (*dao.User, error)

GetUserByID retrieves a user by ID

func (*Repository) GetUserByPhone

func (r *Repository) GetUserByPhone(ctx context.Context, identifier string) (*dao.User, error)

GetUserByPhone implements service.Repository.

func (*Repository) GetUserByUUID

func (r *Repository) GetUserByUUID(ctx context.Context, userUUID string) (*dao.User, error)

GetUserByUUID retrieves a user by UUID

func (*Repository) GetUserByUsername

func (r *Repository) GetUserByUsername(ctx context.Context, username string) (*dao.User, error)

GetUserByUsername retrieves a user by username

func (*Repository) GetUserEffectivePermissionNames

func (r *Repository) GetUserEffectivePermissionNames(ctx context.Context, userId int64) ([]string, error)

GetUserEffectivePermissionNames implements service.Repository.

func (*Repository) GetUserEffectivePermissions

func (r *Repository) GetUserEffectivePermissions(ctx context.Context, userId int64) ([]*dao.EffectivePermission, error)

GetUserEffectivePermissions retrieves all effective permissions for a user (direct + group permissions)

func (*Repository) GetUserProfile

func (r *Repository) GetUserProfile(ctx context.Context, userID int64) (*dao.Profile, error)

GetUserProfile retrieves a user profile by user ID

func (*Repository) IsPermissionAssignedToGroup

func (r *Repository) IsPermissionAssignedToGroup(ctx context.Context, groupID, permissionID int64) (bool, error)

IsPermissionAssignedToGroup checks if a permission is assigned to a group

func (*Repository) IsPermissionAssignedToUser

func (r *Repository) IsPermissionAssignedToUser(ctx context.Context, userID, permissionID int64) (bool, error)

IsPermissionAssignedToUser checks if a permission is directly assigned to a user

func (*Repository) IsUserInGroup

func (r *Repository) IsUserInGroup(ctx context.Context, userID, groupID int64) (bool, error)

IsUserInGroup checks if a user is in a specific group

func (*Repository) ListConfigEntities

func (r *Repository) ListConfigEntities(ctx context.Context, filters *filter.ConfigEntityFilter) ([]*dao.ConfigEntity, error)

ListConfigEntities lists config entities with filtering and pagination

func (*Repository) ListConfigs

func (r *Repository) ListConfigs(ctx context.Context, filters *filter.ConfigFilter) ([]*dao.Config, error)

ListConfigs lists configs with filtering and pagination

func (*Repository) ListGroupPermissions

func (r *Repository) ListGroupPermissions(ctx context.Context, groupId int64) ([]*dao.EffectivePermission, error)

ListGroupPermissions retrieves permissions assigned to a group with filtering and pagination

func (*Repository) ListGroupUsers

func (r *Repository) ListGroupUsers(ctx context.Context, filters *filter.GroupUsersFilter) ([]*dao.User, error)

ListGroupUsers retrieves all users in a specific group

func (*Repository) ListGroups

func (r *Repository) ListGroups(ctx context.Context, filters *filter.GroupFilter) ([]*dao.Group, error)

ListGroups retrieves groups with filtering and pagination

func (*Repository) ListPermissions

func (r *Repository) ListPermissions(ctx context.Context, filters *filter.PermissionFilter) ([]*dao.Permission, error)

ListPermissions retrieves permissions with filtering and pagination

func (*Repository) ListUserGroups

func (r *Repository) ListUserGroups(ctx context.Context, filters *filter.UserGroupsFilter) ([]*dao.Group, error)

ListUserGroups retrieves all groups for a specific user

func (*Repository) ListUserPermissions

func (r *Repository) ListUserPermissions(ctx context.Context, userId int64) ([]*dao.EffectivePermission, error)

ListUserPermissions retrieves permissions directly assigned to a user with filtering and pagination

func (*Repository) ListUserProfileUUIDs

func (r *Repository) ListUserProfileUUIDs(ctx context.Context, userID int64) ([]uuid.UUID, error)

ListUserProfileUUIDs implements service.Repository.

func (*Repository) ListUserProfiles

func (r *Repository) ListUserProfiles(ctx context.Context, filters *filter.UserProfilesFilter) ([]*dao.Profile, error)

ListUserProfiles retrieves all profiles for a specific user with pagination

func (*Repository) ListUserSessions

func (r *Repository) ListUserSessions(ctx context.Context, filters *filter.UserSessionsFilter) ([]*dao.Session, error)

ListUserSessions retrieves sessions for a user with pagination

func (*Repository) ListUsers

func (r *Repository) ListUsers(ctx context.Context, filters *filter.UserFilter) ([]*dao.User, error)

ListUsers retrieves users with filtering and pagination

func (*Repository) LogoutSession

func (r *Repository) LogoutSession(ctx context.Context, sessionUUID string) error

LogoutSession marks a session as logged out

func (*Repository) Ping

func (r *Repository) Ping(ctx context.Context) error

Ping implements service.Repository.

func (*Repository) RemovePermissionFromGroup

func (r *Repository) RemovePermissionFromGroup(ctx context.Context, groupID, permissionID int64) error

RemovePermissionFromGroup removes a permission from a group

func (*Repository) RemovePermissionFromUser

func (r *Repository) RemovePermissionFromUser(ctx context.Context, userID, permissionID int64) error

RemovePermissionFromUser removes a permission directly assigned to a user

func (*Repository) RemovePermissionsFromGroup

func (r *Repository) RemovePermissionsFromGroup(ctx context.Context, groupID int64, permissionIDs []int64) error

RemovePermissionsFromGroup removes multiple permissions from a group in a single transaction

func (*Repository) RemovePermissionsFromUser

func (r *Repository) RemovePermissionsFromUser(ctx context.Context, userID int64, permissionIDs []int64) error

RemovePermissionsFromUser removes multiple permissions directly assigned to a user in a single transaction

func (*Repository) RemoveUserFromGroup

func (r *Repository) RemoveUserFromGroup(ctx context.Context, userID, groupID int64) error

RemoveUserFromGroup removes a user from a group

func (*Repository) RemoveUsersFromGroup

func (r *Repository) RemoveUsersFromGroup(ctx context.Context, userIDs []int64, groupID int64) error

RemoveUsersFromGroup removes multiple users from a group in a single transaction

func (*Repository) RevokeSession

func (r *Repository) RevokeSession(ctx context.Context, sessionUUID string) error

RevokeSession marks a session as revoked (soft delete approach 1)

func (*Repository) RevokeUserSessions

func (r *Repository) RevokeUserSessions(ctx context.Context, userUUID string) error

RevokeUserSessions marks all user sessions as revoked

func (*Repository) UpdateConfig

func (r *Repository) UpdateConfig(ctx context.Context, id int64, updates map[string]interface{}) error

UpdateConfig updates a config

func (*Repository) UpdateConfigEntity

func (r *Repository) UpdateConfigEntity(ctx context.Context, id int64, updates map[string]interface{}) error

UpdateConfigEntity updates a config entity

func (*Repository) UpdateGroup

func (r *Repository) UpdateGroup(ctx context.Context, id int64, updates map[string]interface{}) (*dao.Group, error)

UpdateGroup updates a group in the database

func (*Repository) UpdateLastActivity

func (r *Repository) UpdateLastActivity(ctx context.Context, sessionUUID string) error

UpdateLastActivity updates the last activity timestamp for a session

func (*Repository) UpdatePermission

func (r *Repository) UpdatePermission(ctx context.Context, id int64, updates map[string]interface{}) (*dao.Permission, error)

UpdatePermission updates an existing permission

func (*Repository) UpdateProfileByUUID

func (r *Repository) UpdateProfileByUUID(ctx context.Context, uuid string, updates map[string]interface{}) (*dao.Profile, error)

UpdateProfileByUUID updates a profile by its UUID

func (*Repository) UpdateSession

func (r *Repository) UpdateSession(ctx context.Context, sessionUUID string, updates map[string]interface{}) (*dao.Session, error)

UpdateSession updates a session by its UUID

func (*Repository) UpdateUser

func (r *Repository) UpdateUser(ctx context.Context, id int64, updates map[string]interface{}) (*dao.User, error)

UpdateUser updates user fields

func (*Repository) UpdateUserProfile

func (r *Repository) UpdateUserProfile(ctx context.Context, userID int64, updates map[string]interface{}) (*dao.Profile, error)

UpdateUserProfile updates user profile fields

func (*Repository) UpdateVerificationStatus

func (r *Repository) UpdateVerificationStatus(ctx context.Context, userID int64, field string, verified bool) error

UpdateVerificationStatus updates user verification status

Jump to

Keyboard shortcuts

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