Files
baseapi/platformapi/enterprise_wechat/wechat_model.go
2022-06-21 10:41:08 +08:00

104 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package enterprise_wechat
import (
"git.rosy.net.cn/baseapi/platformapi"
"net/http"
"sync"
)
const (
WeChatBaseApi = "https://qyapi.weixin.qq.com" // 企业微信基础访问链接
// api接口
GetToken = "cgi-bin/gettoken" // 获取token
CreateAppChat = "cgi-bin/appchat/create" // 创建会话群聊
GetAllDepartmentListById = "cgi-bin/department/list" // 获取所有的部门
CreateBoosToJxStaff = "cgi-bin/user/create" // 将京西老板创建为企业员工
GetDepartmentUserDetail = "cgi-bin/user/list" // 获取部门用户详细情况
GetUserByMobileUrl = "cgi-bin/user/getuserid" // 通过手机号获取用户id
EnterpriseTicketInfo = "/suite/receive" // 企业微信服务器会定时每十分钟推送ticket
)
// 注册请求api
type API struct {
corpId string // 企业号
corpSecret string // 秘钥
accessToken string // token
expiresIn int64 // token过期时间
locker sync.RWMutex
client *http.Client
config *platformapi.APIConfig
}
// 创建群聊
type CreateAppChatParamReq struct {
UserList []string `json:"userlist"` // 成员列表(至少两个)
Name string `json:"name"` // 群聊名最多50个utf8字符超过将截断
Owner string `json:"owner"` // 群主id
ChatId string `json:"chatid"` // 群聊的唯一标志,不能与已有的群重复
}
// 获取所有的部门
type Department struct {
ID int `json:"id"` // id
Name string `json:"name"` // 名称
ParentId int `json:"parentid"` // 父部门id
Order int `json:"order"` // 排序
DepartmentLeader []string `json:"department_leader"` // 部门负责人的UserID第三方仅通讯录应用可获取
}
type GetAllDepartmentListRes struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
Department []*Department `json:"department"`
}
// 错误消息
type Err struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
ChatId string `json:"chatid"` // 群聊的唯一标志,不能与已有的群重复
}
// 获取部门全部用户详细信息
type GetEnterpriseStaffInfoRes struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
UserList []*UserList `json:"userlist"`
}
type UserList struct {
Userid string `json:"userid"`
Name string `json:"name"`
Department []int `json:"department"`
Position string `json:"position"`
Mobile string `json:"mobile"`
Gender string `json:"gender"`
Email string `json:"email"`
Avatar string `json:"avatar"`
Status int `json:"status"`
Enable int `json:"enable"`
IsLeader int `json:"isleader"`
ExtAttr Extattr `json:"extattr"`
HideMobile int `json:"hide_mobile"`
Telephone string `json:"telephone"`
Order []int `json:"order"`
ExternalProfile ExternalProfile `json:"external_profile"`
MainDepartment int `json:"main_department"`
QrCode string `json:"qr_code"`
Alias string `json:"alias"`
IsLeaderInDept []int `json:"is_leader_in_dept"`
Address string `json:"address"`
ThumbAvatar string `json:"thumb_avatar"`
DirectLeader []string `json:"direct_leader"`
BizMail string `json:"biz_mail"`
}
// 手机号获取用户信息
type GetUserByMobileRes struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
UserId string `json:"userid"`
}