🎨 #2632【企业微信】完善模板卡片消息接口部分参数
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
* <pre>
|
||||
* 任务卡片管理接口.
|
||||
* Created by Jeff on 2019-05-16.
|
||||
* Updted by HeXiao on 2022-03-09.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/domainname">Jeff</a>
|
||||
@@ -23,9 +24,26 @@ public interface WxCpTaskCardService {
|
||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||
* </pre>
|
||||
*
|
||||
* @param userIds 企业的成员ID列表
|
||||
* @param taskId 任务卡片ID
|
||||
* @param userIds 企业的成员ID列表
|
||||
* @param taskId 任务卡片ID
|
||||
* @param replaceName 替换文案
|
||||
*/
|
||||
void update(List<String> userIds, String taskId, String replaceName) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 更新按钮为不可点击状态
|
||||
* 详情请见https://developer.work.weixin.qq.com/document/path/94888#%E6%9B%B4%E6%96%B0%E6%8C%89%E9%92%AE%E4%B8%BA%E4%B8%8D%E5%8F%AF%E7%82%B9%E5%87%BB%E7%8A%B6%E6%80%81
|
||||
* @param userIds 企业的成员ID列表
|
||||
* @param partyIds 企业的部门ID列表
|
||||
* @param tagIds 企业的标签ID列表
|
||||
* @param atAll 更新整个任务接收人员
|
||||
* @param responseCode 更新卡片所需要消费的code,可通过发消息接口和回调接口返回值获取,一个code只能调用一次该接口,且只能在24小时内调用
|
||||
* @param replaceName 需要更新的按钮的文案
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void updateTemplateCardButton(List<String> userIds, List<Integer> partyIds,
|
||||
List<Integer> tagIds, Integer atAll, String responseCode,
|
||||
String replaceName) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -38,4 +38,25 @@ public class WxCpTaskCardServiceImpl implements WxCpTaskCardService {
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TASK_CARD);
|
||||
this.mainService.post(url, WxGsonBuilder.create().toJson(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTemplateCardButton(List<String> userIds, List<Integer> partyIds,
|
||||
List<Integer> tagIds, Integer atAll,
|
||||
String responseCode, String replaceName) throws WxErrorException {
|
||||
Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
|
||||
Map<String, Object> data = new HashMap<>(7);
|
||||
data.put("userids", userIds);
|
||||
data.put("partyids", partyIds);
|
||||
data.put("tagids", tagIds);
|
||||
data.put("atall", atAll);
|
||||
data.put("agentid", agentId);
|
||||
data.put("response_code", responseCode);
|
||||
Map<String, String> btnMap = new HashMap<>();
|
||||
btnMap.put("replace_name", replaceName);
|
||||
data.put("button", btnMap);
|
||||
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE_CARD);
|
||||
this.mainService.post(url, WxGsonBuilder.create().toJson(data));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,21 @@ public class WxCpMessage implements Serializable {
|
||||
*/
|
||||
private String sourceDesc;
|
||||
|
||||
/**
|
||||
* 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
|
||||
*/
|
||||
private Integer sourceDescColor;
|
||||
|
||||
/**
|
||||
* 更多操作界面的描述
|
||||
*/
|
||||
private String actionMenuDesc;
|
||||
|
||||
/**
|
||||
* 操作列表,列表长度取值范围为 [1, 3]
|
||||
*/
|
||||
private List<ActionMenuItem> actionMenuActionList;
|
||||
|
||||
/**
|
||||
* 一级标题,建议不超过36个字
|
||||
*/
|
||||
@@ -482,9 +497,22 @@ public class WxCpMessage implements Serializable {
|
||||
if (StringUtils.isNotBlank(this.getSourceDesc())) {
|
||||
source.addProperty("desc", this.getSourceDesc());
|
||||
}
|
||||
source.addProperty("desc_color", this.getSourceDescColor());
|
||||
template.add("source", source);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(this.getActionMenuDesc())) {
|
||||
JsonObject action_menu = new JsonObject();
|
||||
action_menu.addProperty("desc", this.getActionMenuDesc());
|
||||
JsonArray actionList = new JsonArray();
|
||||
List<ActionMenuItem> actionMenuItemList = this.getActionMenuActionList();
|
||||
for (ActionMenuItem actionItemI : actionMenuItemList) {
|
||||
actionList.add(actionItemI.toJson());
|
||||
}
|
||||
action_menu.add("action_list", actionList);
|
||||
template.add("action_menu", action_menu);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(this.getMainTitleTitle()) || StringUtils.isNotBlank(this.getMainTitleDesc())) {
|
||||
JsonObject mainTitle = new JsonObject();
|
||||
if (StringUtils.isNotBlank(this.getMainTitleTitle())) {
|
||||
|
||||
@@ -36,6 +36,21 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
|
||||
*/
|
||||
private String sourceDesc;
|
||||
|
||||
/**
|
||||
* 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
|
||||
*/
|
||||
private Integer sourceDescColor;
|
||||
|
||||
/**
|
||||
* 更多操作界面的描述
|
||||
*/
|
||||
private String actionMenuDesc;
|
||||
|
||||
/**
|
||||
* 操作列表,列表长度取值范围为 [1, 3]
|
||||
*/
|
||||
private List<ActionMenuItem> actionMenuActionList;
|
||||
|
||||
/**
|
||||
* 一级标题,建议不超过36个字
|
||||
*/
|
||||
@@ -172,6 +187,16 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCardBuilder actionMenuDesc(String actionMenuDesc) {
|
||||
this.actionMenuDesc = actionMenuDesc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCardBuilder actionMenuActionList(List<ActionMenuItem> actionMenuItemList) {
|
||||
this.actionMenuActionList = actionMenuItemList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCardBuilder sourceIconUrl(String sourceIconUrl) {
|
||||
this.sourceIconUrl = sourceIconUrl;
|
||||
return this;
|
||||
@@ -182,6 +207,11 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCardBuilder sourceDescColor(Integer sourceDescColor) {
|
||||
this.sourceDescColor = sourceDescColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCardBuilder mainTitleTitle(String mainTitleTitle) {
|
||||
this.mainTitleTitle = mainTitleTitle;
|
||||
return this;
|
||||
@@ -294,6 +324,9 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
|
||||
m.setCardType(this.cardType);
|
||||
m.setSourceIconUrl(this.sourceIconUrl);
|
||||
m.setSourceDesc(this.sourceDesc);
|
||||
m.setSourceDescColor(this.sourceDescColor);
|
||||
m.setActionMenuDesc(this.actionMenuDesc);
|
||||
m.setActionMenuActionList(this.actionMenuActionList);
|
||||
m.setMainTitleTitle(this.mainTitleTitle);
|
||||
m.setMainTitleDesc(this.mainTitleDesc);
|
||||
m.setCardImageUrl(this.cardImageUrl);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.chanjar.weixin.cp.bean.templatecard;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 卡片右上角更多操作按钮点击后出现的操作列表,列表长度取值范围为 [1, 3]
|
||||
* @author xiaohe
|
||||
* @date 2022-03-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ActionMenuItem implements Serializable {
|
||||
private static final long serialVersionUID = 400885585614100693L;
|
||||
|
||||
/**
|
||||
* 操作的描述文案
|
||||
*/
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* 按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复
|
||||
*/
|
||||
private String key;
|
||||
|
||||
public JsonObject toJson() {
|
||||
JsonObject btnObject = new JsonObject();
|
||||
btnObject.addProperty("text", this.getText());
|
||||
btnObject.addProperty("key", this.getKey());
|
||||
return btnObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,6 +44,11 @@ public class HorizontalContent implements Serializable {
|
||||
*/
|
||||
private String media_id;
|
||||
|
||||
/**
|
||||
* 成员详情的userid,horizontal_content_list.type是3时必填
|
||||
*/
|
||||
private String userid;
|
||||
|
||||
public JsonObject toJson() {
|
||||
JsonObject hContentJson = new JsonObject();
|
||||
|
||||
@@ -61,6 +66,9 @@ public class HorizontalContent implements Serializable {
|
||||
if (StringUtils.isNotBlank(this.getMedia_id())) {
|
||||
hContentJson.addProperty("media_id", this.getMedia_id());
|
||||
}
|
||||
if (StringUtils.isNotBlank(this.getUserid())) {
|
||||
hContentJson.addProperty("userid", this.getUserid());
|
||||
}
|
||||
return hContentJson;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@ public interface WxCpApiPathConsts {
|
||||
|
||||
interface TaskCard {
|
||||
String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard";
|
||||
String UPDATE_TEMPLATE_CARD = "/cgi-bin/message/update_template_card";
|
||||
}
|
||||
|
||||
interface Tp {
|
||||
|
||||
Reference in New Issue
Block a user