users

package
v0.0.0-...-d2923a7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUserService

func NewUserService(r UserRepository, es email.EmailService, redis *redis.Client, auditLog audit_logs.AuditLogService) *service

Types

type Handler

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

func NewUserHandler

func NewUserHandler(svc UserService) *Handler

func (*Handler) CreateUser

func (h *Handler) CreateUser(ctx *gin.Context)

func (*Handler) DeleteUser

func (h *Handler) DeleteUser(ctx *gin.Context)

func (*Handler) GetUserByUUID

func (h *Handler) GetUserByUUID(ctx *gin.Context)

func (*Handler) GetUsers

func (h *Handler) GetUsers(ctx *gin.Context)

func (*Handler) UpdateUser

func (h *Handler) UpdateUser(ctx *gin.Context)

func (*Handler) UpdateUserStatus

func (h *Handler) UpdateUserStatus(ctx *gin.Context)

type Repository

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

func NewUserRepository

func NewUserRepository(db *bun.DB) *Repository

func (*Repository) CheckUserPermission

func (r *Repository) CheckUserPermission(ctx context.Context, userID int64, roleName string) ([]string, error)

func (*Repository) CreateUser

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

func (*Repository) DeleteUser

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

func (*Repository) GetUserByUUID

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

func (*Repository) GetUserByUsernameOrEmail

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

func (*Repository) GetUsers

func (r *Repository) GetUsers(ctx context.Context, q dto.BaseFilters) ([]User, int, error)

func (*Repository) UpdateUser

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

func (*Repository) UpdateUserStatus

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

type User

type User struct {
	bun.BaseModel `bun:"table:users,alias:u"`
	fields.BaseFields

	FirstName string `bun:"first_name" json:"first_name"`
	LastName  string `bun:"last_name" json:"last_name"`
	Email     string `bun:"email" json:"email"`
	Username  string `bun:"username" json:"username"`
	Password  string `bun:"password" json:"-"`
}

type UserRepository

type UserRepository interface {
	GetUserByUUID(ctx context.Context, uuid string) (*User, error)
	GetUsers(ctx context.Context, filters dto.BaseFilters) ([]User, int, error)
	CreateUser(ctx context.Context, user *User) error
	UpdateUser(ctx context.Context, user *User) error
	DeleteUser(ctx context.Context, uuid string) error
	UpdateUserStatus(ctx context.Context, uuid string) error
	GetUserByUsernameOrEmail(ctx context.Context, identifier string) (*User, error)
	CheckUserPermission(ctx context.Context, userID int64, roleName string) ([]string, error)
}

type UserRequest

type UserRequest struct {
	FirstName *string `json:"first_name"`
	LastName  *string `json:"last_name"`
	Email     *string `json:"email"`
	Username  *string `json:"username"`
}

type UserService

type UserService interface {
	GetUserByUUID(ctx context.Context, uuid string) (*User, error)
	GetUsers(ctx context.Context, q dto.Query) ([]User, int, error)
	CreateUser(ctx context.Context, req UserRequest, audit models.AuditLogRequest) error
	UpdateUser(ctx context.Context, uuid string, req UserRequest, audit models.AuditLogRequest) error
	DeleteUser(ctx context.Context, uuid string, audit models.AuditLogRequest) error
	UpdateUserStatus(ctx context.Context, uuid string, audit models.AuditLogRequest) error
}

Jump to

Keyboard shortcuts

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