models

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown = common.Unknown
	Male    = common.Male
	Female  = common.Female
)

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 (
	// ProfileEditables deprecated
	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 SetNameFormat

func SetNameFormat(s string)

func SplitName

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

SplitName 这个其实没有用

Types

type Authenticator

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

Authenticator for Authenticate

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 Gender

type Gender = common.Gender

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, error)
	GetGroup(name string) (*Group, error)
	SaveGroup(group *Group) error
	EraseGroup(name string) error
}

GroupStore Storage for Group

type PasswordStore

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

PasswordStore Storage for Password

type Staff

type Staff struct {
	Uid            string `json:"uid" form:"uid" binding:"required"`        // 登录名
	CommonName     string `json:"cn,omitempty" form:"cn"`                   // 姓名(全名)
	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 int    `json:"eid,omitempty" form:"eid"`                 // 员工编号
	EmployeeType   string `json:"etype,omitempty" form:"etitle"`            // 员工岗位
	AvatarPath     string `json:"avatarPath,omitempty" form:"avatar"`       // 头像
	JpegPhoto      []byte `json:"-" form:"-"`                               // jpegPhoto data
	Description    string `json:"description,omitempty" form:"description"` // 描述
	JoinDate       string `json:"joinDate,omitempty" form:"joinDate"`       // 加入日期
	IDCN           string `json:"idcn,omitempty" form:"idcn"`               // 身份证号

	Created *time.Time `json:"created,omitempty" form:"created"` // 创建时间
	Updated *time.Time `json:"updated,omitempty" form:"updated"` // 修改时间

	DN string `json:"-" form:"-"` // distinguishedName of LDAP entry

	Leader bool `json:"leader,omitempty" form:"-"` // temporary var
	TeamID int  `json:"teamID,omitempty" form:"-"` // department id

	Watchings []string `json:"watching,omitempty" form:"-"` // watchings
}

employment for a person

func (*Staff) AvatarUri added in v0.8.2

func (u *Staff) AvatarUri() string

func (*Staff) GetCommonName

func (u *Staff) GetCommonName() string

func (*Staff) GetName added in v0.8.4

func (u *Staff) GetName() string

func (*Staff) GetUID added in v0.8.4

func (u *Staff) GetUID() string

func (*Staff) Name

func (u *Staff) Name() string

type StaffStore

type StaffStore interface {
	// All browse from store, like LDAP
	All() Staffs
	// Get with uid
	Get(uid string) (*Staff, error)
	// GetByDN with dn
	GetByDN(dn 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
}

StaffStore Storage for Staff

type Staffs added in v0.8.4

type Staffs []*Staff

func (Staffs) WithUid added in v0.8.4

func (arr Staffs) WithUid(uid string) *Staff

type UIDs added in v0.10.3

type UIDs []string

UIDs ...

func (UIDs) Has added in v0.10.3

func (z UIDs) Has(uid string) bool

Has ...

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