wecom

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

WeCom User Center

Feature

  • User login via WeCom QRCode

Config

You need to create a WeCom App first, and then get the Corp ID, Agent ID and App Secret from the App.

  • Company ID: WeCom Corp ID
  • App Secret: WeCom App Secret
  • App Agent ID: WeCom App Agent ID

Note: WeCom restricts the ip address of the callback url, so you need to add the ip address of the server where the project is located to the callback url.

Preview

WeCom Config WeCom QRCode WeCom Login

Document

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUserInfoResp

type AuthUserInfoResp struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
	Userid  string `json:"userid"`
	Mobile  string `json:"mobile"`
	Gender  string `json:"gender"`
	Email   string `json:"email"`
	Avatar  string `json:"avatar"`
	QrCode  string `json:"qr_code"`
	Address string `json:"address"`
}

type Company

type Company struct {
	CorpID      string
	CorpSecret  string
	AgentID     string
	CallbackURL string

	Work                  *work.Work
	DepartmentMapping     map[int]*Department
	EmployeeMapping       map[string]*Employee
	UserDetailInfoMapping map[string]*UserDetailInfo
}

func NewCompany

func NewCompany(corpID, corpSecret, agentID string) *Company

func (*Company) AuthUser

func (c *Company) AuthUser(code string) (info *UserInfo, err error)

func (*Company) GetRedirectURL

func (c *Company) GetRedirectURL(callbackURl string) (redirectURL string)

func (*Company) GetUserDetailInfo

func (c *Company) GetUserDetailInfo(userid string) (info *UserDetailInfo, err error)

func (*Company) ListDepartmentAll

func (c *Company) ListDepartmentAll() (err error)

func (*Company) ListUser

func (c *Company) ListUser() (err error)

type Department

type Department struct {
	Id               int      `json:"id"`
	Name             string   `json:"name"`
	ParentID         int      `json:"parentid"`
	Order            int      `json:"order"`
	DepartmentLeader []string `json:"department_leader"`
}

type Employee

type Employee struct {
	Name       string `json:"name"`
	Department []int  `json:"department"`
	Userid     string `json:"userid"`
}

type RespBody

type RespBody struct {
	// http code
	Code int `json:"code"`
	// reason key
	Reason string `json:"reason"`
	// response message
	Message string `json:"msg"`
	// response data
	Data interface{} `json:"data"`
}

RespBody response body.

func NewRespBodyData

func NewRespBodyData(code int, reason string, data interface{}) *RespBody

NewRespBodyData new response body with data

type UserCenter

type UserCenter struct {
	Config          *UserCenterConfig
	Company         *Company
	UserConfigCache *UserConfigCache
	Cache           *cache.Cache
	// contains filtered or unexported fields
}

func (*UserCenter) AfterLogin

func (uc *UserCenter) AfterLogin(externalID, accessToken string)

func (*UserCenter) CheckUserLogin

func (uc *UserCenter) CheckUserLogin(ctx *gin.Context)

func (*UserCenter) ConfigFields

func (uc *UserCenter) ConfigFields() []plugin.ConfigField

func (*UserCenter) ConfigReceiver

func (uc *UserCenter) ConfigReceiver(config []byte) error

func (*UserCenter) ControlCenterItems

func (uc *UserCenter) ControlCenterItems() []plugin.ControlCenter

func (*UserCenter) CronSyncData

func (uc *UserCenter) CronSyncData()

func (*UserCenter) Data

func (uc *UserCenter) Data(ctx *gin.Context)

func (*UserCenter) Description

func (uc *UserCenter) Description() plugin.UserCenterDesc

func (*UserCenter) GetNewQuestionSubscribers

func (uc *UserCenter) GetNewQuestionSubscribers() (userIDs []string)

GetNewQuestionSubscribers returns the subscribers of the new question notification

func (*UserCenter) GetRedirectURL

func (uc *UserCenter) GetRedirectURL(ctx *gin.Context)

func (*UserCenter) Info

func (uc *UserCenter) Info() plugin.Info

func (*UserCenter) LoginCallback

func (uc *UserCenter) LoginCallback(ctx *plugin.GinContext) (userInfo *plugin.UserCenterBasicUserInfo, err error)

func (*UserCenter) Notify

func (uc *UserCenter) Notify(msg plugin.NotificationMessage)

Notify sends a notification to the user

func (*UserCenter) PersonalBranding

func (uc *UserCenter) PersonalBranding(externalID string) (branding []*plugin.PersonalBranding)

func (*UserCenter) RegisterAuthAdminRouter

func (uc *UserCenter) RegisterAuthAdminRouter(r *gin.RouterGroup)

func (*UserCenter) RegisterAuthUserRouter

func (uc *UserCenter) RegisterAuthUserRouter(r *gin.RouterGroup)

func (*UserCenter) RegisterUnAuthRouter

func (uc *UserCenter) RegisterUnAuthRouter(r *gin.RouterGroup)

func (*UserCenter) SignUpCallback

func (uc *UserCenter) SignUpCallback(ctx *plugin.GinContext) (userInfo *plugin.UserCenterBasicUserInfo, err error)

func (*UserCenter) Sync

func (uc *UserCenter) Sync(ctx *gin.Context)

func (*UserCenter) UserConfigFields

func (uc *UserCenter) UserConfigFields() []plugin.ConfigField

func (*UserCenter) UserConfigReceiver

func (uc *UserCenter) UserConfigReceiver(userID string, config []byte) error

func (*UserCenter) UserInfo

func (uc *UserCenter) UserInfo(externalID string) (userInfo *plugin.UserCenterBasicUserInfo, err error)

func (*UserCenter) UserList

func (uc *UserCenter) UserList(externalIDs []string) (userList []*plugin.UserCenterBasicUserInfo, err error)

func (*UserCenter) UserSettings

func (uc *UserCenter) UserSettings(externalID string) (userSettings *plugin.SettingInfo, err error)

func (*UserCenter) UserStatus

func (uc *UserCenter) UserStatus(externalID string) (userStatus plugin.UserStatus)

type UserCenterConfig

type UserCenterConfig struct {
	CorpID       string `json:"corp_id"`
	CorpSecret   string `json:"corp_secret"`
	AgentID      string `json:"agent_id"`
	AutoSync     bool   `json:"auto_sync"`
	Notification bool   `json:"notification"`
}

type UserConfig

type UserConfig struct {
	InboxNotifications           bool `json:"inbox_notifications"`
	AllNewQuestions              bool `json:"all_new_questions"`
	NewQuestionsForFollowingTags bool `json:"new_questions_for_following_tags"`
}

type UserConfigCache

type UserConfigCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewUserConfigCache

func NewUserConfigCache() *UserConfigCache

func (*UserConfigCache) SetUserConfig

func (ucc *UserConfigCache) SetUserConfig(userID string, config *UserConfig)

type UserDetailInfo

type UserDetailInfo struct {
	Errcode        int    `json:"errcode"`
	Errmsg         string `json:"errmsg"`
	Userid         string `json:"userid"`
	Name           string `json:"name"`
	Department     []int  `json:"department"`
	Position       string `json:"position"`
	Status         int    `json:"status"`
	Isleader       int    `json:"isleader"`
	EnglishName    string `json:"english_name"`
	Telephone      string `json:"telephone"`
	Enable         int    `json:"enable"`
	HideMobile     int    `json:"hide_mobile"`
	Order          []int  `json:"order"`
	MainDepartment int    `json:"main_department"`
	Alias          string `json:"alias"`
}

type UserInfo

type UserInfo struct {
	Userid        string `json:"userid"`
	Mobile        string `json:"mobile"`
	Gender        string `json:"gender"`
	Email         string `json:"email"`
	Avatar        string `json:"avatar"`
	QrCode        string `json:"qr_code"`
	Address       string `json:"address"`
	Name          string `json:"name"`
	DepartmentIDs []int  `json:"department"`
	Position      string `json:"position"`
	IsAvailable   bool   `json:"is_available"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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