You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
253 lines
12 KiB
253 lines
12 KiB
package workwechat
|
|
|
|
//通用部分
|
|
type descInfo struct {
|
|
Desc string `json:"desc"`
|
|
}
|
|
type idInfo struct {
|
|
Id string `json:"id"`
|
|
}
|
|
type textInfo struct {
|
|
Text string `json:"text"`
|
|
}
|
|
|
|
type keyInfo struct {
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
type titleInfo struct {
|
|
Title string `json:"title"`
|
|
}
|
|
type typeInfo struct {
|
|
Type int `json:"type"`
|
|
}
|
|
type styleInfo struct {
|
|
Style int `json:"style"`
|
|
}
|
|
type urlInfo struct {
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
type subTitleText struct {
|
|
SubTitleText string `json:"sub_title_text"`
|
|
}
|
|
type keynameInfo struct {
|
|
Keyname string `json:"keyname"`
|
|
}
|
|
type valueInfo struct {
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
type mediaIdInfo struct {
|
|
MediaId string `json:"media_id"`
|
|
}
|
|
|
|
type useridInfo struct {
|
|
UserId string `json:"userid"`
|
|
}
|
|
|
|
type appidInfo struct {
|
|
AppId string `json:"appid"`
|
|
}
|
|
|
|
type pagepathInfo struct {
|
|
PagePath string `json:"pagepath"`
|
|
}
|
|
|
|
type questionkeyInfo struct {
|
|
QuestionKey string `json:"question_key"`
|
|
}
|
|
type selectedidInfo struct {
|
|
SelectedId string `json:"selected_id"`
|
|
}
|
|
|
|
type isCheckedInfo struct {
|
|
IsChecked bool `json:"is_checked"`
|
|
}
|
|
type ReplaceTextInfo struct {
|
|
ReplaceText bool `json:"replace_text"`
|
|
}
|
|
|
|
//模版主体
|
|
type MessageMain struct {
|
|
ToUser string `json:"touser"` //消息接收人 成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
|
|
ToParty string `json:"toparty"` //部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
|
|
ToTag string `json:"totag"` //标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
|
|
MsgType string `json:"msgtype"` //消息类型 template_card(模板卡片消息)
|
|
AgentId int `json:"agentid"` //企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
|
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0
|
|
EnableDuplicateCheck int `json:"enable_duplicate_check"` //表示是否开启重复消息检查,0表示否,1表示是,默认0
|
|
DuplicateCheckInterval int `json:"aduplicate_check_intervalgentid"` //表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
|
|
}
|
|
|
|
//通用模版数据
|
|
type TemplatePublic struct {
|
|
CardType string `json:"card_type"` //模板卡片类型 text_notice:文本卡片;news_notice:图文卡片;button_interaction:按钮卡片,multiple_interaction:多项选择,vote_interaction:投票
|
|
Source SourceCont `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
|
}
|
|
|
|
//模板卡片消息 参数(文本、图文、按钮通用部分)
|
|
type TemplateCardCont struct {
|
|
TemplatePublic
|
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
|
HorizontalContentList []HorizontalContentListCont `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
|
}
|
|
|
|
//卡片来源样式信息,不需要来源样式可不填写
|
|
type SourceCont struct {
|
|
IconUrl string `json:"icon_url"` //来源图片的url,来源图片的尺寸建议为72*72
|
|
descInfo //来源图片的描述,建议不超过20个字,(支持id转译)
|
|
DescColor int `json:"desc_color"` //来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
|
|
}
|
|
|
|
//卡片右上角更多操作按钮
|
|
type ActionMenuCont struct {
|
|
descInfo //更多操作界面的描述
|
|
ActionList []ActionListCont `json:"action_list"` //操作列表,列表长度取值范围为 [1, 3]
|
|
}
|
|
|
|
//操作列表,列表长度取值范围为 [1, 3]
|
|
type ActionListCont struct {
|
|
textInfo //操作的描述文案
|
|
keyInfo //操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复
|
|
}
|
|
|
|
//一级标题
|
|
type MainTitleCont struct {
|
|
titleInfo //一级标题,建议不超过36个字,文本通知型卡片本字段非必填,但不可本字段和sub_title_text都不填,(支持id转译)
|
|
descInfo //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
}
|
|
|
|
//引用文献样式
|
|
type QuoteAreaCont struct {
|
|
typeInfo //引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
|
|
urlInfo //点击跳转的url,quote_area.type是1时必填
|
|
titleInfo //引用文献样式的标题
|
|
QuoteText string `json:"quote_text"` //引用文献样式的引用文案
|
|
}
|
|
|
|
//整体卡片的点击跳转事件,text_notice必填本字段
|
|
type CardActionCont struct {
|
|
typeInfo //跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2]
|
|
urlInfo //跳转事件的url,card_action.type是1时必填
|
|
appidInfo //跳转事件的小程序的appid,必须是与当前应用关联的小程序,card_action.type是2时必填
|
|
pagepathInfo //跳转事件的小程序的pagepath,card_action.type是2时选填
|
|
}
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
|
type HorizontalContentListCont struct {
|
|
typeInfo //链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情
|
|
keynameInfo //二级标题,建议不超过5个字
|
|
valueInfo //二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译)
|
|
urlInfo //链接跳转的url,horizontal_content_list.type是1时必填
|
|
mediaIdInfo //附件的media_id,horizontal_content_list.type是2时必填
|
|
useridInfo //成员详情的userid,horizontal_content_list.type是3时必填
|
|
}
|
|
|
|
//跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
|
type JumpListCont struct {
|
|
typeInfo
|
|
titleInfo
|
|
urlInfo
|
|
appidInfo
|
|
pagepathInfo
|
|
}
|
|
|
|
//左图右文样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
|
type ImageTextAreaCont struct {
|
|
typeInfo //左图右文样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
|
|
urlInfo //点击跳转的url,image_text_area.type是1时必填
|
|
titleInfo //左图右文样式的标题
|
|
descInfo //左图右文样式的描述
|
|
ImageUrl string `json:"image_url"` //左图右文样式的图片url
|
|
}
|
|
|
|
//图片样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
|
type CardImageCont struct {
|
|
urlInfo //图片的url
|
|
AspectRatio float64 `json:"aspect_ratio"` //图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3
|
|
}
|
|
|
|
//卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
|
|
type VerticalContentListCont struct {
|
|
titleInfo //卡片二级标题,建议不超过38个字
|
|
descInfo //二级普通文本,建议不超过160个字
|
|
}
|
|
|
|
//按钮型卡片的下拉框样式
|
|
type ButtonSelectionCont struct {
|
|
questionkeyInfo //下拉式的选择器的key,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节
|
|
titleInfo //下拉式的选择器左边的标题
|
|
OptionList OptionListCont `json:"option_list"` //选项列表,下拉选项不超过 10 个,最少1个
|
|
selectedidInfo //默认选定的id,不填或错填默认第一个
|
|
}
|
|
|
|
//选项列表,下拉选项不超过 10 个,最少1个
|
|
type OptionListCont struct {
|
|
idInfo //下拉式的选择器选项的id,用户提交后,会产生回调事件,回调事件会带上该id值表示该选项,最长支持128字节,不可重复
|
|
textInfo //下拉式的选择器选项的文案,建议不超过16个字
|
|
isCheckedInfo
|
|
}
|
|
|
|
//按钮列表,列表长度不超过6
|
|
type ButtonListCont struct {
|
|
typeInfo //按钮点击事件类型,0 或不填代表回调点击事件,1 代表跳转url
|
|
textInfo //按钮文案,建议不超过10个字
|
|
styleInfo //按钮样式,目前可填1~4,不填或错填默认1
|
|
keyInfo //按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复,button_list.type是0时必填
|
|
urlInfo //跳转事件的url,button_list.type是1时必填
|
|
}
|
|
|
|
//下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器
|
|
type SelectListCont struct {
|
|
questionkeyInfo //下拉式的选择器题目的key,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节,不可重复
|
|
textInfo //下拉式的选择器上面的title
|
|
selectedidInfo //默认选定的id,不填或错填默认第一个
|
|
OptionList OptionListCont `json:"option_list"` //选项列表,下拉选项不超过 10 个,最少1个
|
|
}
|
|
|
|
//提交按钮样式
|
|
type SubmitButtonCont struct {
|
|
textInfo //按钮文案,建议不超过10个字,不填默认为提交
|
|
keyInfo //提交按钮的key,会产生回调事件将本参数作为EventKey返回,最长支持1024字节
|
|
}
|
|
|
|
//
|
|
type CheckBoxCont struct {
|
|
questionkeyInfo
|
|
OptionList OptionListCont `json:"option_list"` //选项列表,下拉选项不超过 10 个,最少1个
|
|
Mode int `json:"mode"` //选择题模式,单选:0,多选:1,不填默认0
|
|
}
|
|
|
|
//关键数据样式
|
|
type EmphasisContentInfo struct {
|
|
titleInfo
|
|
descInfo
|
|
}
|
|
|
|
//更新模板通用
|
|
type UpdatePublic struct {
|
|
UserIds []string `json:"userids"` //企业的成员ID列表(最多支持1000个)
|
|
PartyIds []int `json:"partyids"` //企业的部门ID列表(最多支持100个)
|
|
AgentId int `json:"agentid"` //应用的agentid
|
|
ResponseCode string `json:"response_code"` //更新卡片所需要消费的code,可通过发消息接口和回调接口返回值获取,一个code只能调用一次该接口,且只能在72小时内调用
|
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0,id转译说明
|
|
}
|
|
|
|
//更新模板template_card模块通用
|
|
type UpdateTemplateCardPublic struct {
|
|
CardType string `json:"card_type"` //模板卡片类型 text_notice:文本卡片;news_notice:图文卡片;button_interaction:按钮卡片,multiple_interaction:多项选择,vote_interaction:投票
|
|
Source SourceCont `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
|
}
|
|
|
|
//文本,图文,按钮通用部门
|
|
type UpdateTextImgButton struct {
|
|
ActionMenu ActionMenuCont `json:"action_menu"` //卡片右上角更多操作按钮
|
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
|
HorizontalContentList []HorizontalContentListCont `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
|
}
|
|
|