models

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ByUid = By(func(p1, p2 *Staff) bool {
		return p1.Uid < p2.Uid
	})
)
View Source
var (
	EmptyGroup = &Group{"", "", make([]string, 0)}
)
View Source
var (
	ErrInvalidGender = errors.New("Invalid Gender value")
)
View Source
var (
	ProfileEditables = map[string]string{
		"nickname":    "displayName",
		"cn":          "cn",
		"gn":          "givenName",
		"sn":          "sn",
		"email":       "mail",
		"mobile":      "mobile",
		"eid":         "employeeNumber",
		"etitle":      "employeeType",
		"birthday":    "dateOfBirth",
		"gender":      "gender",
		"avatarPath":  "avatarPath",
		"description": "description",
	}
)
View Source
var (
	VerifyLifeSeconds = 86400
)

Functions

func HashCode

func HashCode(code string) int64

func MarkdownSanitize

func MarkdownSanitize(s string) template.HTML

func SanitizeTitle

func SanitizeTitle(s string) template.HTML

func SetNameFormat

func SetNameFormat(s string)

func SplitName

func SplitName(cn string) (sn, gn string)

这个其实没有用

Types

type Article

type Article struct {
	Id      int       `sql:"id,pk" json:"id" form:"id"`
	Title   string    `sql:"title,notnull" json:"title" form:"title" binding:"required"`
	Content string    `sql:"content,notnull" json:"content" form:"content" binding:"required"`
	Author  string    `sql:"author" json:"author"`
	Created time.Time `sql:"created" json:"created"`
	Updated time.Time `sql:"updated,nullempty" json:"updated,omitempty"`
}

func (*Article) HtmlContent

func (a *Article) HtmlContent() template.HTML

func (*Article) HtmlTitle

func (a *Article) HtmlTitle() template.HTML

func (*Article) StyleName

func (a *Article) StyleName() string

type Authenticator

type Authenticator interface {
	// Authenticate with uid and password
	Authenticate(uid, password string) error
}

Authenticator

type By

type By func(p1, p2 *Staff) bool

By is the type of a "less" function that defines the ordering of its Staff arguments.

func (By) Sort

func (by By) Sort(staffs []*Staff)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type Client

type Client struct {
	Id                   uint        `json:"_id,omitempty"`
	Name                 string      `json:"name"`
	Code                 string      `json:"code,omitempty"`
	Secret               string      `json:"-"`
	RedirectUri          string      `json:"uri"`
	UserData             interface{} `json:"-"`
	CreatedAt            time.Time   `json:"created,omitempty"`
	AllowedGrantTypes    []string    `json:"grant_types,omitempty"`
	AllowedResponseTypes []string    `json:"response_types,omitempty"`
	AllowedScopes        []string    `json:"scopes,omitempty"`
}

func NewClient

func NewClient(name, code, secret, redirectUri string) *Client

func (*Client) GetId

func (c *Client) GetId() string

func (*Client) GetRedirectUri

func (c *Client) GetRedirectUri() string

func (*Client) GetSecret

func (c *Client) GetSecret() string

func (*Client) GetUserData

func (c *Client) GetUserData() interface{}

type Gender

type Gender uint8
const (
	Unknown Gender = 0 + iota
	Male
	Female
)

func (Gender) String

func (this Gender) String() string

func (*Gender) UnmarshalJSON

func (this *Gender) UnmarshalJSON(b []byte) (err error)

type Group

type Group struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Members     []string `json:"members"`
}

func (*Group) Has

func (g *Group) Has(member string) bool

type GroupStore

type GroupStore interface {
	AllGroup() []Group
	GetGroup(name string) (*Group, error)
	SaveGroup(*Group) error
}

Storage for Group

type Link struct {
	Id       int          `sql:"id,pk" json:"id" form:"id"`
	Title    string       `sql:"title,notnull" json:"title" form:"title" binding:"required"`
	Url      template.URL `sql:"url,unique,notnull" json:"url" form:"url" binding:"required"`
	Position int          `sql:"position" json:"position" form:"position"`
	Author   string       `sql:"author" json:"author"`
	Created  time.Time    `sql:"created" json:"created"`
}

func (*Link) HtmlTitle

func (a *Link) HtmlTitle() template.HTML

func (*Link) SetUrl

func (a *Link) SetUrl(href string)

type PasswordStore

type PasswordStore interface {
	// Change password by self
	PasswordChange(uid, old_password, new_password string) error
	// Reset password by administrator
	PasswordReset(uid, new_password string) error
}

Storage for Password

type Scope

type Scope struct {
	Name        string
	Label       string
	Description string
	IsDefault   bool
}

type Staff

type Staff struct {
	Uid            string `json:"uid" form:"uid" binding:"required"`         // 登录名
	Passwd         string `json:"-" form:"password"`                         // 密码
	CommonName     string `json:"cn,omitempty" form:"cn" binding:"required"` // 姓名(全名)
	GivenName      string `json:"gn" form:"gn" binding:"required"`           // 名 FirstName
	Surname        string `json:"sn" form:"sn" binding:"required"`           // 姓 LastName
	Nickname       string `json:"nickname,omitempty" form:"nickname"`        // 昵称
	Birthday       string `json:"birthday,omitempty" form:"birthday"`        // 生日
	Gender         Gender `json:"gender,omitempty" form:"gender"`            // 性别
	Email          string `json:"email" form:"email" binding:"required"`     // 邮箱
	Mobile         string `json:"mobile" form:"mobile" binding:"required"`   // 手机
	Tel            string `json:"tel,omitempty" form:"tel"`                  // 座机
	EmployeeNumber string `json:"eid,omitempty" form:"eid"`                  // 员工编号
	EmployeeType   string `json:"etype,omitempty" form:"etitle"`             // 员工岗位
	AvatarPath     string `json:"avatarPath,omitempty" form:"avatar"`        // 头像
	Description    string `json:"description,omitempty" form:"description"`  // 描述
}

employment for a person

func (*Staff) GetCommonName

func (u *Staff) GetCommonName() string

func (*Staff) Name

func (u *Staff) Name() string

type StaffStore

type StaffStore interface {
	// All browse from store, like LDAP
	All() []*Staff
	// Get with uid
	Get(uid string) (*Staff, error)
	// Delete with uid
	Delete(uid string) error
	// Save add or update
	Save(staff *Staff) (isNew bool, err error)
	// ModifyBySelf update by self
	ModifyBySelf(uid, password string, staff *Staff) error
}

Storage for Staff

type Verify

type Verify struct {
	Id          int              `db:"id" json:"id"`
	Uid         string           `db:"uid" json:"uid"`
	Target      string           `db:"target" json:"target"`
	Type        common.AliasType `db:"type_id" json:"type"`
	CodeHash    int64            `db:"code_hash" json:"-"`
	LifeSeconds int              `db:"life_seconds" json:"life_seconds"`
	Created     time.Time        `db:"created" json:"created"`
	Updated     time.Time        `db:"updated" json:"updated"`

	Code string `db:"-" json:"-"`
}

用户验证,如邮箱、手机等

func NewVerify

func NewVerify(at common.AliasType, target, uid string) *Verify

func (*Verify) CodeHashBytes

func (uv *Verify) CodeHashBytes() []byte

func (*Verify) IsExpired

func (uv *Verify) IsExpired() bool

func (*Verify) Match

func (uv *Verify) Match(code string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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