nut

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: MIT Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NOTICE notice
	NOTICE = "notice"
	// WARNING warning
	WARNING = "warning"
	// ERROR error
	ERROR = "error"

	// TITLE title
	TITLE = "title"
	// MESSAGE message
	MESSAGE = "message"

	// UID uid
	UID = "uid"
	// CurrentUser current user
	CurrentUser = "current-user"
	// IsAdmin is admin?
	IsAdmin = "is-admin"
)
View Source
const (
	// RoleAdmin admin role
	RoleAdmin = "admin"
	// RoleRoot root role
	RoleRoot = "root"
	// UserTypeEmail email user
	UserTypeEmail = "email"

	// DefaultResourceType default resource type
	DefaultResourceType = ""
	// DefaultResourceID default resourc id
	DefaultResourceID = 0
)
View Source
const (

	// SendEmailJob send email
	SendEmailJob = "send.email"
)

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(ca bool, subject pkix.Name, years int) ([]byte, []byte, error)

CreateCertificate create certs

func WritePemFile

func WritePemFile(file, _type string, buf []byte, mode os.FileMode) error

WritePemFile wirte to a pem format file

Types

type Attachment

type Attachment struct {
	ID           uint      `json:"id" gorm:"primary_key"`
	Title        string    `json:"title"`
	URL          string    `json:"url"`
	Length       int64     `json:"length"`
	MediaType    string    `json:"mediaType"`
	ResourceID   uint      `json:"resourceId" sql:",notnull"`
	ResourceType string    `json:"resourceType" sql:",notnull"`
	User         User      `json:"user"`
	UserID       uint      `json:"userId"`
	UpdatedAt    time.Time `json:"updatedAt"`
	CreatedAt    time.Time `json:"crateAt"`
}

Attachment attachment

func (*Attachment) IsPicture

func (p *Attachment) IsPicture() bool

IsPicture is picture?

func (Attachment) TableName

func (p Attachment) TableName() string

TableName table name

type Card

type Card struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	Title     string    `json:"title"`
	Summary   string    `json:"summary"`
	Type      string    `json:"type"`
	Href      string    `json:"href"`
	SortOrder int       `json:"sortOrder" sql:",notnull"`
	Action    string    `json:"action"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
}

Card card

func (Card) TableName

func (p Card) TableName() string

TableName table name

type Dao

type Dao struct {
	Security *web.Security `inject:""`
	I18n     *web.I18n     `inject:""`
}

Dao dao

func (*Dao) AddEmailUser

func (p *Dao) AddEmailUser(db *gorm.DB, lang, ip, name, email, password string) (*User, error)

AddEmailUser add email user

func (*Dao) AddLog

func (p *Dao) AddLog(db *gorm.DB, user uint, ip, lang, format string, args ...interface{}) error

AddLog add log

func (*Dao) Allow

func (p *Dao) Allow(db *gorm.DB, user uint, role uint, years, months, days int) error

Allow allow permission

func (*Dao) Can

func (p *Dao) Can(db *gorm.DB, user uint, name string, rty string, rid uint) bool

Can can?

func (*Dao) Deny

func (p *Dao) Deny(db *gorm.DB, user uint, role uint) error

Deny deny permission

func (*Dao) GetRole

func (p *Dao) GetRole(db *gorm.DB, name string, rty string, rid uint) (*Role, error)

GetRole create role if not exist

func (*Dao) GetUserByEmail

func (p *Dao) GetUserByEmail(db *gorm.DB, email string) (*User, error)

GetUserByEmail get user by email

func (*Dao) GetUserByUID

func (p *Dao) GetUserByUID(db *gorm.DB, uid string) (*User, error)

GetUserByUID get user by uid

func (*Dao) Is

func (p *Dao) Is(db *gorm.DB, user uint, names ...string) bool

Is is role ?

func (*Dao) SignIn

func (p *Dao) SignIn(db *gorm.DB, lang, ip, email, password string) (*User, error)

SignIn set sign-in info

type FriendLink struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	Title     string    `json:"title"`
	Home      string    `json:"home"`
	SortOrder int       `json:"sortOrder"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
}

FriendLink friend_links

func (FriendLink) TableName

func (p FriendLink) TableName() string

TableName table name

type HTMLHandlerFunc

type HTMLHandlerFunc func(string, *gin.Context) (gin.H, error)

HTMLHandlerFunc html handler func

type Layout

type Layout struct {
	Render    *render.Render `inject:""`
	Dao       *Dao           `inject:""`
	Store     sessions.Store `inject:""`
	Jwt       *web.Jwt       `inject:""`
	DB        *gorm.DB       `inject:""`
	I18n      *web.I18n      `inject:""`
	Languages []string       `inject:"languages"`
}

Layout layout

func (*Layout) Backend

func (p *Layout) Backend(c *gin.Context) string

Backend backend home url

func (*Layout) CurrentUserMiddleware

func (p *Layout) CurrentUserMiddleware(c *gin.Context)

CurrentUserMiddleware current user middleware

func (*Layout) Frontend

func (p *Layout) Frontend(c *gin.Context) string

Frontend frontend home url

func (*Layout) HTML

func (p *Layout) HTML(name string, handler HTMLHandlerFunc) gin.HandlerFunc

HTML wrap html

func (*Layout) JSON

JSON render json

func (*Layout) MustAdminMiddleware

func (p *Layout) MustAdminMiddleware(c *gin.Context)

MustAdminMiddleware must admin middleware

func (*Layout) MustSignInMiddleware

func (p *Layout) MustSignInMiddleware(c *gin.Context)

MustSignInMiddleware must sign in middleware

func (*Layout) Redirect

func (p *Layout) Redirect(to string, fn RedirectHandlerFunc) gin.HandlerFunc

Redirect redirect

func (*Layout) Save

func (p *Layout) Save(c *gin.Context, s *sessions.Session)

Save save session

func (*Layout) Session

func (p *Layout) Session(c *gin.Context) *sessions.Session

Session get session

func (*Layout) XML

XML wrap xml

type LeaveWord

type LeaveWord struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	Body      string    `json:"body"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
}

LeaveWord leave-word

func (LeaveWord) TableName

func (p LeaveWord) TableName() string

TableName table name

type Link struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	Href      string    `json:"href"`
	Label     string    `json:"label"`
	SortOrder int       `json:"sortOrder"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
}

Link link

func (Link) TableName

func (p Link) TableName() string

TableName table name

type Log

type Log struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	Message   string    `json:"message"`
	IP        string    `json:"ip"`
	User      User      `json:"user"`
	UserID    uint      `json:"userId"`
	CreatedAt time.Time `json:"createdAt"`
}

Log log

func (Log) String

func (p Log) String() string

func (Log) TableName

func (p Log) TableName() string

TableName table name

type ObjectHandlerFunc

type ObjectHandlerFunc func(string, *gin.Context) (interface{}, error)

ObjectHandlerFunc object handle func

type Plugin

type Plugin struct {
	I18n      *web.I18n      `inject:""`
	Cache     *web.Cache     `inject:""`
	Jwt       *web.Jwt       `inject:""`
	Jobber    *web.Jobber    `inject:""`
	Settings  *web.Settings  `inject:""`
	Security  *web.Security  `inject:""`
	S3        *web.S3        `inject:""`
	Sitemap   *web.Sitemap   `inject:""`
	RSS       *web.RSS       `inject:""`
	Router    *gin.Engine    `inject:""`
	DB        *gorm.DB       `inject:""`
	Redis     *redis.Pool    `inject:""`
	Render    *render.Render `inject:""`
	Dao       *Dao           `inject:""`
	Layout    *Layout        `inject:""`
	Languages []string       `inject:"languages"`
}

Plugin plugin

func (*Plugin) Init

func (p *Plugin) Init(g *inject.Graph) error

Init init beans

func (*Plugin) Mount

func (p *Plugin) Mount() error

Mount register

func (*Plugin) Shell

func (p *Plugin) Shell() []cli.Command

Shell console commands

type Policy

type Policy struct {
	ID        uint `gorm:"primary_key"`
	StartUp   time.Time
	ShutDown  time.Time
	User      User
	UserID    uint
	Role      Role
	RoleID    uint
	UpdatedAt time.Time
	CreatedAt time.Time
}

Policy policy

func (*Policy) Enable

func (p *Policy) Enable() bool

Enable is enable?

func (Policy) TableName

func (p Policy) TableName() string

TableName table name

type RedirectHandlerFunc

type RedirectHandlerFunc func(string, *gin.Context) error

RedirectHandlerFunc redirect handle func

type Role

type Role struct {
	ID           uint `gorm:"primary_key"`
	Name         string
	ResourceID   uint
	ResourceType string
	UpdatedAt    time.Time
	CreatedAt    time.Time
}

Role role

func (Role) String

func (p Role) String() string

func (Role) TableName

func (p Role) TableName() string

TableName table name

type User

type User struct {
	ID              uint       `json:"id" gorm:"primary_key"`
	Name            string     `json:"name"`
	Email           string     `json:"email"`
	UID             string     `json:"uid" gorm:"column:uid"`
	Password        []byte     `json:"-"`
	ProviderID      string     `json:"providerId"`
	ProviderType    string     `json:"providerType"`
	SignInCount     uint       `json:"signInCount"`
	LastSignInAt    *time.Time `json:"lastSignInAt"`
	LastSignInIP    string     `json:"lastSignInIp"`
	CurrentSignInAt *time.Time `json:"currentSignInAt"`
	CurrentSignInIP string     `json:"currentSignInIp"`
	ConfirmedAt     *time.Time `json:"confirmedAt"`
	LockedAt        *time.Time `json:"lockAt"`
	Logs            []Log      `json:"logs"`
	UpdatedAt       time.Time  `json:"updatedAt"`
	CreatedAt       time.Time  `json:"createdAt"`
}

User user

func (*User) IsConfirm

func (p *User) IsConfirm() bool

IsConfirm is confirm?

func (*User) IsLock

func (p *User) IsLock() bool

IsLock is lock?

func (p *User) SetGravatarLogo()

SetGravatarLogo set logo by gravatar

func (*User) SetUID

func (p *User) SetUID()

SetUID generate uid

func (User) String

func (p User) String() string

func (User) TableName

func (p User) TableName() string

TableName table name

type Vote

type Vote struct {
	ID           uint `gorm:"primary_key"`
	Point        int
	ResourceID   uint
	ResourceType string
	UpdatedAt    time.Time
	CreatedAt    time.Time
}

Vote vote

func (Vote) TableName

func (p Vote) TableName() string

TableName table name

Jump to

Keyboard shortcuts

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