base

package module
v0.0.0-...-c3427f9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2015 License: MIT Imports: 9 Imported by: 0

README

base

基础模块

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthDao

type AuthDao struct {
	HMac *web.HMac `inject:""`
	Aes  *web.Aes  `inject:""`
}

func (*AuthDao) AddRole

func (p *AuthDao) AddRole(db *gorm.DB, user uint, name string, resource_type string, resource_id uint, startUp, shutDown *time.Time)

func (*AuthDao) Auth

func (p *AuthDao) Auth(db *gorm.DB, email, password string) *User

func (*AuthDao) Can

func (p *AuthDao) Can(db *gorm.DB, user uint, name string, resource_type string, resource_id uint) bool

func (*AuthDao) Confirm

func (p *AuthDao) Confirm(db *gorm.DB, user uint)

func (*AuthDao) CreateByEmail

func (p *AuthDao) CreateByEmail(db *gorm.DB, email, name, password string) *User

func (*AuthDao) DelRole

func (p *AuthDao) DelRole(db *gorm.DB, user uint, name string, resource_type string, resource_id uint)

func (*AuthDao) GetByEmail

func (p *AuthDao) GetByEmail(db *gorm.DB, email string) *User

func (*AuthDao) Log

func (p *AuthDao) Log(db *gorm.DB, user uint, message string, flag string)

func (*AuthDao) ResetUid

func (p *AuthDao) ResetUid(db *gorm.DB, user uint)

type Contact

type Contact struct {
	Model
	Qq       string
	Skype    string
	WeChat   string
	LinkedIn string
	FaceBook string
	Email    string
	Phone    string
	Tel      string
	Fax      string
	Address  string
	Details  string `sql:"type:TEXT"`
}

type DateZone

type DateZone struct {
	StartUp  *time.Time `sql:"type:DATE;default:CURRENT_DATE;not null"`
	ShutDown *time.Time `sql:"type:DATE;default:'9999-12-31';not null"`
}

type Engine

type Engine struct {
	Mux        *web.Mux        `inject:""`
	Logger     *logging.Logger `inject:""`
	Redis      *redis.Pool     `inject:""`
	Db         *gorm.DB        `inject:""`
	AuthDao    *AuthDao        `inject:""`
	LocaleDao  *LocaleDao      `inject:""`
	SettingDao *SettingDao     `inject:""`
	Cache      web.Cache       `inject:""`
}

func (Engine) Info

func (p Engine) Info() (string, string)

func (*Engine) Locales

func (p *Engine) Locales(c *web.Context) *web.HttpError

func (*Engine) Migrate

func (p *Engine) Migrate() error

func (*Engine) Mount

func (p *Engine) Mount()

func (*Engine) Rss

func (p *Engine) Rss(c *web.Context) *web.HttpError

func (*Engine) Seed

func (p *Engine) Seed() error

func (*Engine) SiteInfo

func (p *Engine) SiteInfo(c *web.Context) *web.HttpError

func (*Engine) Sitemap

func (p *Engine) Sitemap(c *web.Context) *web.HttpError

type Locale

type Locale struct {
	ID      uint   `gorm:"primary_key"`
	Lang    string `sql:"index;size:5;not null;default 'en_US'"`
	Code    string `sql:"size:255;index;not null"`
	Message string `sql:"type:TEXT;not null"`
}

type LocaleDao

type LocaleDao struct {
	Logger *logging.Logger `inject:""`
}

-----------------------------------------------------------------------------

func (*LocaleDao) Get

func (p *LocaleDao) Get(db *gorm.DB, lang, code string) string

func (*LocaleDao) Load

func (p *LocaleDao) Load(db *gorm.DB, path string) error

func (*LocaleDao) Set

func (p *LocaleDao) Set(db *gorm.DB, lang, code, message string)

func (*LocaleDao) T

func (p *LocaleDao) T(db *gorm.DB, lang, code string, args ...interface{}) string

type Log

type Log struct {
	ID        uint
	UserID    uint   `sql:"not null;index"`
	Message   string `sql:"size:255"`
	Type      string `sql:"size:8;default:'info';index"`
	CreatedAt time.Time
}

type Model

type Model struct {
	ID        uint `gorm:"primary_key"`
	UpdatedAt time.Time
	CreatedAt time.Time `sql:"default:CURRENT_TIMESTAMP;not null"`
}

type Permission

type Permission struct {
	Model
	User   User
	UserID uint `sql:"index;not null"`
	Role   Role
	RoleID uint `sql:"index;not null"`
	DateZone
}

type Role

type Role struct {
	ID           uint
	Name         string `sql:"size:255;index;not null"`
	ResourceType string `sql:"size:255;index;not null"`
	ResourceID   uint   `sql:"index;not null"`
	Permissions  []Permission
}

type Setting

type Setting struct {
	ID  string `gorm:"primary_key"`
	Val []byte `sql:"not null"`
}

type SettingDao

type SettingDao struct {
	Aes *web.Aes `inject:""`
}

-----------------------------------------------------------------------------

func (*SettingDao) Get

func (p *SettingDao) Get(db *gorm.DB, key string, val interface{}, enc bool) error

func (*SettingDao) Set

func (p *SettingDao) Set(db *gorm.DB, key string, val interface{}, enc bool) error

type User

type User struct {
	Model
	Uid       string `sql:"not null;type:UUID;default:gen_random_uuid()"`
	Name      string `sql:"not null;size:64;index"`
	Email     string `sql:"size:128;index"`
	Token     string `sql:"size:255;index;not null"`
	Provider  string `sql:"size:16;not null;default:'email';index"`
	Password  []byte `sql:"size:64"`
	Confirmed *time.Time
	Locked    *time.Time

	ContactID   uint `sql:"not null"`
	Contact     Contact
	Logs        []Log
	Permissions []Permission
}

func (User) Can

func (p User) Can(name, resource_type string) bool

func (*User) Has

func (p *User) Has(name, resource_type string, resource_id uint) bool

func (*User) Is

func (p *User) Is(name string) bool

type VModel

type VModel struct {
	Uid       string    `sql:"type:UUID;default:;index;not null"`
	Ver       uint      `sql:"default:0;not null"`
	CreatedAt time.Time `sql:"default:CURRENT_TIMESTAMP;not null"`
}

Jump to

Keyboard shortcuts

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