userBadges

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceAuto      = "auto"
	SourceManual    = "manual"
	SourceMigration = "migration"
)

Variables

This section is empty.

Functions

func Exists

func Exists(userID uint64, badgeCode string) bool

func Grant

func Grant(userID uint64, badgeCode string, source string, reason string, grantedBy uint64, metadata Metadata) (bool, error)

func GrantAuto

func GrantAuto(userID uint64, badgeCode string, reason string, metadata Metadata) (bool, error)

func GrantManual

func GrantManual(userID uint64, badgeCode string, source string, reason string, grantedBy uint64, metadata Metadata) (bool, error)

func Revoke

func Revoke(userID uint64, badgeCode string) error

Types

type Entity

type Entity struct {
	Id        uint64     `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`
	UserId    uint64     `` /* 137-byte string literal not displayed */
	BadgeCode string     `gorm:"column:badge_code;type:varchar(64);not null;default:'';uniqueIndex:idx_user_badge_code;index;" json:"badgeCode"`
	Source    string     `gorm:"column:source;type:varchar(16);not null;default:'auto';" json:"source"`
	Reason    string     `gorm:"column:reason;type:varchar(255);not null;default:'';" json:"reason"`
	Metadata  Metadata   `gorm:"column:metadata;type:json;serializer:json" json:"metadata"`
	GrantedBy uint64     `gorm:"column:granted_by;type:bigint unsigned;not null;default:0;" json:"grantedBy"`
	GrantedAt time.Time  `gorm:"column:granted_at;index:idx_user_badge_granted;" json:"grantedAt"`
	RevokedAt *time.Time `gorm:"column:revoked_at;type:datetime;index;" json:"revokedAt"`
	CreatedAt time.Time  `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"`
	UpdatedAt time.Time  `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
}

func GetActiveByUserID

func GetActiveByUserID(userID uint64) (entities []*Entity)

func (*Entity) TableName

func (itself *Entity) TableName() string

type Metadata

type Metadata map[string]any

Jump to

Keyboard shortcuts

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