models

package
v0.0.0-...-8c9b190 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	ID          int    `json:"id" db:"id"`
	Name        string `json:"name" db:"name"`
	Description string `json:"description" db:"description"`
}

Context model for context-specific permissions

type Permission

type Permission struct {
	ID          int    `json:"id" db:"id"`
	Name        string `json:"name" db:"name"`
	Description string `json:"description" db:"description"`
}

Permission model Permission model

type Resource

type Resource struct {
	ID          int    `json:"id" db:"id"`
	Name        string `json:"name" db:"name"`
	Description string `json:"description" db:"description"`
}

Resource model

type Role

type Role struct {
	ID           int              `json:"id" db:"id"`
	Name         string           `json:"name" db:"name"`
	Description  string           `json:"description" db:"description"`
	ParentRoleID *int             `json:"parent_role_id,omitempty" db:"parent_role_id"`
	ParentRole   *Role            `json:"parent_role,omitempty"`
	ChildRoles   []Role           `json:"child_roles,omitempty"`
	Permissions  []RolePermission `json:"permissions,omitempty"`
}

Role model with hierarchical support

type RolePermission

type RolePermission struct {
	RoleID       int         `json:"role_id" db:"role_id"`
	PermissionID int         `json:"permission_id" db:"permission_id"`
	ResourceID   int         `json:"resource_id" db:"resource_id"`
	ContextID    *int        `json:"context_id,omitempty" db:"context_id"`
	Role         *Role       `json:"role,omitempty"`
	Permission   *Permission `json:"permission,omitempty"`
	Resource     *Resource   `json:"resource,omitempty"`
	Context      *Context    `json:"context,omitempty"`
}

Enhanced RolePermission with resource and context

type RolesList

type RolesList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	Roles      []*Role `json:"roles"`
}

type Session

type Session struct {
	SessionID string `json:"session_id" redis:"session_id"`
	UserID    int    `json:"user_id" redis:"user_id"`
}

Session model

type UploadInput

type UploadInput struct {
	File        io.Reader
	Name        string
	Size        int64
	ContentType string
	BucketName  string
}

AWS Upload Input

type User

type User struct {
	ID          int              `json:"id" db:"id"`
	Username    string           `json:"username" db:"username"`
	Email       string           `json:"email" db:"email"`
	Password    string           `json:"-" db:"password"`
	CreatedAt   time.Time        `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time        `json:"updated_at" db:"updated_at"`
	LoginAt     *time.Time       `json:"login_at,omitempty" db:"login_at"`
	Roles       []Role           `json:"roles,omitempty"`
	Permissions []RolePermission `json:"permissions,omitempty"`
}

User full model User model with enhanced fields

func (*User) ComparePasswords

func (u *User) ComparePasswords(password string) error

Compare user password and payload

func (*User) HashPassword

func (u *User) HashPassword() error

Hash user password with bcrypt

func (*User) PrepareCreate

func (u *User) PrepareCreate() error

Prepare user for register

func (*User) PrepareUpdate

func (u *User) PrepareUpdate() error

Prepare user for register

func (*User) SanitizePassword

func (u *User) SanitizePassword()

Sanitize user password

type UserRole

type UserRole struct {
	UserID int `json:"user_id" db:"user_id"`
	RoleID int `json:"role_id" db:"role_id"`
}

UserRole junction table

type UserWithRole

type UserWithRole struct {
	User User `json:"user" db:"user"`
	Role Role `json:"role" db:"role"`
}

type UserWithToken

type UserWithToken struct {
	User  *User  `json:"user"`
	Token string `json:"token"`
}

Find user query

type UsersList

type UsersList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	Users      []*User `json:"users"`
}

All Users response

Jump to

Keyboard shortcuts

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