model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	URIPrefixQqcn = "https://p.qlogo.cn"
	URIPrefixWxcn = "https://wework.qpic.cn"
	URIPrefixData = "data:image/jpeg;base64,"
)

consts

Variables

View Source
var (
	EmptyGroup = &Group{"", "", make([]string, 0)}
)

vars

Functions

func SetNameFormat

func SetNameFormat(s string)

SetNameFormat ...

Types

type Authenticator

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

Authenticator for Authenticate

type Group

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

Group ...

func (*Group) Has

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

Has ..

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 People

type People struct {
	UID            string `json:"uid" form:"uid" binding:"required"`        // 登录名
	CommonName     string `json:"cn" 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         string `json:"gender,omitempty" form:"gender"`           // 性别: M F U
	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"`       // 头像
	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"`               // 身份证号

	Organization  string `json:"org,omitempty" form:"org"`   // 所属组织
	OrgDepartment string `json:"dept,omitempty" form:"dept"` // 所属组织的部门

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

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

}

People employment for a person

func NewPeople

func NewPeople(args ...string) *People

NewPeople args: uid, cn, sn, gn, nickname

func (*People) AvatarURI

func (u *People) AvatarURI() string

AvatarURI make uri of avatar

func (*People) GetCommonName

func (u *People) GetCommonName() string

GetCommonName ...

func (*People) GetName

func (u *People) GetName() string

GetName ...

func (*People) GetUID

func (u *People) GetUID() string

GetUID ...

func (*People) Name

func (u *People) Name() string

Name return nickname or commonName or fullname or uid

type PeopleStore

type PeopleStore interface {
	// All browse from store, like LDAP
	All(spec *Spec) Peoples
	// Get with uid
	Get(uid string) (*People, error)
	// GetByDN with dn
	GetByDN(dn string) (*People, error)
	// Delete with uid
	Delete(uid string) error
	// Save add or update
	Save(people *People) (isNew bool, err error)
	// ModifyBySelf update by self
	ModifyBySelf(uid, password string, people *People) error
}

PeopleStore Storage for People

type Peoples

type Peoples []People

Peoples ...

func (Peoples) WithUID

func (arr Peoples) WithUID(uid string) *People

WithUID ...

type Spec

type Spec struct {
	Name   string   `json:"name,omitempty"`
	Email  string   `json:"email"`
	Mobile string   `json:"mobile"`
	UIDs   []string `json:"uids,omitempty"`
	Limit  int      `json:"limit,omitempty"`
}

Spec param of searching

type UIDs

type UIDs []string

UIDs ...

func (UIDs) Has

func (z UIDs) Has(uid string) bool

Has ...

Jump to

Keyboard shortcuts

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