web

package
v0.0.0-...-b8b4108 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidUsernameOrPassword int = -(iota + 10000)
	ErrInvalidPassword
)
View Source
const (
	PASSWORD_PLACEHOLDER string = "password placeholder"
)

Variables

This section is empty.

Functions

func Actions

func Actions() []string

func Allow

func Allow(session *auth.Session, obj, act string, enforcer *casbin.Enforcer) bool

func AllowAny

func AllowAny(session *auth.Session, obj string, enforcer *casbin.Enforcer) bool

func AutowiredCreator

func AutowiredCreator(c *gin.Context, record any)

func ClearSessions

func ClearSessions(db *gorm.DB)

func Convert

func Convert(matchMode, value string) (condition string)

func FilterClause

func FilterClause(sb *strings.Builder, table, field, matchMode, value string)

func GetBindingTag

func GetBindingTag(field reflect.StructField) string

func GetComponent

func GetComponent(field reflect.StructField) tag.Component

func GetSession

func GetSession(c *gin.Context) *auth.Session

func Group

func Group(model any) string

func HandleBatchEnforcer

func HandleBatchEnforcer(ids []uint, model any, enforcer *casbin.Enforcer)

func HandleEnforcer

func HandleEnforcer(record any, enforcer *casbin.Enforcer)

func HandlePassword

func HandlePassword(c *gin.Context, record any, db *gorm.DB)

func Icon

func Icon(model any) string

func IsCtrl

func IsCtrl(m any) bool

func IsLazy

func IsLazy(m any) bool

func IsPurge

func IsPurge(m any) bool

func IsTabler

func IsTabler(t reflect.Type) bool

func Item

func Item(model any) string

func Obj

func Obj(model any) string

func ParseRoleID

func ParseRoleID(roleID string) uint

func RecordOpLog

func RecordOpLog(db *gorm.DB, c *gin.Context, record any, action string)

func RecordOpLogs

func RecordOpLogs(db *gorm.DB, c *gin.Context, ids []uint, action string)

func SecureRecord

func SecureRecord(secrets []Column, recordVal reflect.Value)

func SecureRecords

func SecureRecords(secrets []Column, recordsVal reflect.Value)

func SetCookieSessionid

func SetCookieSessionid(c *gin.Context, sessionid string, rememberMe bool, domain string, secure bool)

func TableFieldName

func TableFieldName(db *gorm.DB, model any, modelType reflect.Type, filterField string) (table, field string)

func TableName

func TableName(db *gorm.DB, model any, modelType reflect.Type) (table string)

Types

type ChangePasswordForm

type ChangePasswordForm struct {
	Password, NewPassword string `binding:"required,min=8"`
}

type Column

type Column struct {
	Name         string
	Component    Component
	ValidateRule string
}

func Reflect

func Reflect(modelType reflect.Type) (secrets, joins, preloads, columns []Column)

type Component

type Component struct {
	Name string
	Tag  tag.Component
}

type DataTable

type DataTable struct {
	Lazy    bool     `json:"lazy"`
	Ctrl    bool     `json:"ctrl"`
	Columns []Column `json:"columns"`
	Perms   *Perms   `json:"perms"`
}

type LazyParam

type LazyParam struct {
	Offset    int    `form:"offset"`
	Limit     int    `form:"limit"`
	SortField string `form:"sortField"`
	SortOrder int    `form:"sortOrder"`
	Filters   string `form:"filters"`
}
type Menu struct {
	Name  string `json:"label"`
	Icon  string `json:"icon,omitempty"`
	Items []Menu `json:"items,omitempty"`
}

type Option

type Option struct {
	Label string `json:"label"`
	Value any    `json:"value"`
}

type Perm

type Perm struct {
	Code,
	Group,
	Item,
	Action string
}

func NewPerm

func NewPerm(obj, action string) Perm

func (*Perm) Val

func (p *Perm) Val() []string

type Perms

type Perms struct {
	Post   bool `json:"post"`
	Delete bool `json:"delete"`
	Put    bool `json:"put"`
	Get    bool `json:"get"`
}

type PermsParam

type PermsParam struct {
	RoleID uint `uri:"roleID"`
}

type RecordList

type RecordList struct {
	Total uint `json:"total"`
	List  any  `json:"list"`
}

type Result

type Result struct {
	Code int `json:"code"`
	Data any `json:"data"`
}

type RolesParam

type RolesParam struct {
	UserID uint `uri:"userID"`
}

type SigninForm

type SigninForm struct {
	Username   string `binding:"required,alphanum,min=3,max=40"`
	Password   string `binding:"required,min=8"`
	RememberMe bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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