gorm

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseStringUint

func ParseStringUint(s string) (uint, error)

ParseStringUint parses a string ID to uint, returns 0 and error if invalid.

Types

type GormRole

type GormRole struct {
	ID        uint      `gorm:"primaryKey"`
	Name      string    `gorm:"uniqueIndex;not null"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type GormRoleRepository

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

func NewGormRoleRepository

func NewGormRoleRepository(db *gorm.DB) *GormRoleRepository

func (*GormRoleRepository) Create

func (r *GormRoleRepository) Create(ctx context.Context, role core.Role) (*core.Role, error)

func (*GormRoleRepository) Delete

func (r *GormRoleRepository) Delete(ctx context.Context, id string) error

func (*GormRoleRepository) GetByID

func (r *GormRoleRepository) GetByID(ctx context.Context, id string) (*core.Role, error)

func (*GormRoleRepository) GetByName

func (r *GormRoleRepository) GetByName(ctx context.Context, name string) (*core.Role, error)

func (*GormRoleRepository) List

func (r *GormRoleRepository) List(ctx context.Context) ([]core.Role, error)

func (*GormRoleRepository) Update

func (r *GormRoleRepository) Update(ctx context.Context, role core.Role) (*core.Role, error)

type GormUser

type GormUser struct {
	ID             uint      `gorm:"primaryKey;autoIncrement"`
	Username       string    `gorm:"uniqueIndex;not null"`
	Email          string    `gorm:"uniqueIndex;not null"`
	HashedPassword string    `gorm:"not null"`
	RoleID         uint      `gorm:"not null"`
	Role           GormRole  `gorm:"foreignKey:RoleID;references:ID"`
	LastSeen       time.Time `gorm:"not null;default:CURRENT_TIMESTAMP"`
	CreatedAt      time.Time `gorm:"autoCreateTime"`
	UpdatedAt      time.Time `gorm:"autoUpdateTime"`
}

type GormUserRepository

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

func NewGormUserRepository

func NewGormUserRepository(db *gorm.DB) *GormUserRepository

func (*GormUserRepository) Create

func (r *GormUserRepository) Create(ctx context.Context, user core.User) (*core.User, error)

func (*GormUserRepository) Delete

func (r *GormUserRepository) Delete(ctx context.Context, id string) error

func (*GormUserRepository) GetByEmail

func (r *GormUserRepository) GetByEmail(ctx context.Context, email string) (*core.User, error)

func (*GormUserRepository) GetByID

func (r *GormUserRepository) GetByID(ctx context.Context, id string) (*core.User, error)

func (*GormUserRepository) GetByUsername

func (r *GormUserRepository) GetByUsername(ctx context.Context, username string) (*core.User, error)

func (*GormUserRepository) List

func (r *GormUserRepository) List(ctx context.Context) ([]core.User, error)

func (*GormUserRepository) Update

func (r *GormUserRepository) Update(ctx context.Context, user core.User) (*core.User, error)

Jump to

Keyboard shortcuts

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