dgwork

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 13 Imported by: 0

README

专有钉钉-go-sdk

实现

名称 API接口 备注
获取Access_Token /gettoken.json
通过CODE换取用户详情 /rpc/oauth2/dingtalk_app_user.json

Documentation

Index

Constants

View Source
const (
	// DGBaseURL api基础路由
	DGBaseURL = "https://openplatform.dg-work.cn"
)

Variables

This section is empty.

Functions

func ComputeHmac256

func ComputeHmac256(message string, secret string) string

ComputeHmac256 ComputeHmac256

func GetFirstIP

func GetFirstIP() (ip string)

GetFirstIP 获取本机的ip地址

func GetFirstMacAddress

func GetFirstMacAddress() (macAddress string)

GetFirstMacAddress 获取本机的MAC地址

Types

type Cache

type Cache interface {
	Get(key string) interface{}
	GetMulti(keys []string) []interface{}
	Put(key string, val interface{}, timeout time.Duration) error
	Delete(key string) error
	Incr(key string) error
	Decr(key string) error
	IsExist(key string) bool
	ClearAll() error
	StartAndGC(config string) error
}

Cache Cache

type Client

type Client struct {
	AppKey     string
	AppSecret  string
	CacheToken Token
	// contains filtered or unexported fields
}

Client 主要处理Client

func NewClient

func NewClient(AppKey, AppSecret string, cacheProvider Cache) (client *Client)

NewClient NewClient

func (*Client) GetToken

func (c *Client) GetToken() (t Token, err error)

GetToken 获取access_token 应该全局缓存该token,不能频繁刷新 https://openplatform-portal.dg-work.cn/#/docs?apiType=serverapi&docKey=2674862

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(code string) (info UserInfo, err error)

GetUserInfo 获取成员详情

func (*Client) RefreshToken

func (c *Client) RefreshToken() (t Token, err error)

RefreshToken 刷新access_token

type CommonReply

type CommonReply struct {
	RequestId    string   `json:"_RequestId"`
	Success      bool     `json:"success"`
	Content      *Content `json:"content"`
	Message      string   `json:"Message"` //sucess为false返回以下字段
	ErrorCode    string   `json:"errorCode"`
	HostId       string   `json:"HostId"`
	Code         string   `json:"Code"`
	BizErrorCode string   `json:"bizErrorCode"`
	ErrorMsg     string   `json:"errorMsg"`
	ErrorLevel   string   `json:"errorLevel"`
}

CommonReply CommonReply

func (CommonReply) GetData

func (rep CommonReply) GetData() (data interface{}, err error)

GetData GetData

type Content

type Content struct {
	Success         bool        `json:"success"`
	Data            interface{} `json:"data"`
	ResponseMessage string      `json:"responseMessage"`
	ResponseCode    string      `json:"responseCode"`
}

Content Content

type Token

type Token struct {
	ExpiresIn   int    `json:"expiresIn"`   // 过期时间
	AccessToken string `json:"accessToken"` // 获取到的凭证
}

Token Token

type UserInfo

type UserInfo struct {
	Account      string `json:"account"`      // 账号名
	AccountID    int64  `json:"accountId"`    // 账号id
	ClientId     string `json:"clientId"`     // 应用名
	EmployeeCode string `json:"employeeCode"` // 租户下人员编码
	NameSpace    string `json:"namespace"`    // 账号类型
	NickNameCn   string `json:"nickNameCn"`   // 昵称
	RealmId      int64  `json:"realmId"`      // 租户id
	RealmName    string `json:"realmName"`    // 租户名称
	LastName     string `json:"lastName"`     // 姓名
	OpenID       string `json:"openid"`       // 应用+用户唯一标识
	TenantUserId string `json:"tenantUserId"` // 租户+用户唯一标识
}

UserInfo UserInfo

Jump to

Keyboard shortcuts

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