dao

package
v0.0.0-...-e417875 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAO

type DAO interface {
	// Create create a user record in the table, it will return the ID of the user
	Create(ctx context.Context, user *commonmodels.User) (int, error)
	// List list users
	List(ctx context.Context, query *q.Query) ([]*commonmodels.User, error)
	// Count counts the number of users
	Count(ctx context.Context, query *q.Query) (int64, error)
	// Update updates the user record based on the model the parm props are the columns will be updated
	Update(ctx context.Context, user *commonmodels.User, props ...string) error
	// Delete delete user
	Delete(ctx context.Context, userID int) error
}

DAO is the data access object interface for user

func New

func New() DAO

New returns an instance of the default DAO

type User

type User struct {
	UserID   int    `orm:"pk;auto;column(user_id)" json:"user_id"`
	Username string `orm:"column(username)" json:"username" sort:"default"`
	// Email defined as sql.NullString because sometimes email is missing in LDAP/OIDC auth,
	// set it to null to avoid unique constraint check
	Email           sql.NullString `orm:"column(email)" json:"email"`
	Password        string         `orm:"column(password)" json:"password"`
	PasswordVersion string         `orm:"column(password_version)" json:"password_version"`
	Realname        string         `orm:"column(realname)" json:"realname"`
	Comment         string         `orm:"column(comment)" json:"comment"`
	Deleted         bool           `orm:"column(deleted)" json:"deleted"`
	SysAdminFlag    bool           `orm:"column(sysadmin_flag)" json:"sysadmin_flag"`
	ResetUUID       string         `orm:"column(reset_uuid)" json:"reset_uuid"`
	Salt            string         `orm:"column(salt)" json:"-"`
	CreationTime    time.Time      `orm:"column(creation_time);auto_now_add" json:"creation_time"`
	UpdateTime      time.Time      `orm:"column(update_time);auto_now" json:"update_time"`
}

User holds the details of a user. only used in DAO, for other place, use the User model in common/models

func (*User) FilterByUsernameOrEmail

func (u *User) FilterByUsernameOrEmail(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter

FilterByUsernameOrEmail generates the query setter to match username or email column to the same value

func (*User) TableName

func (u *User) TableName() string

TableName ...

Jump to

Keyboard shortcuts

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