mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#1046 企业微信增加支持最新添加的任务卡片消息
This commit is contained in:
@@ -301,6 +301,13 @@ public interface WxCpService {
|
||||
*/
|
||||
WxCpChatService getChatService();
|
||||
|
||||
/**
|
||||
* 获取任务卡片服务
|
||||
*
|
||||
* @return 任务卡片服务
|
||||
*/
|
||||
WxCpTaskCardService getTaskCardService();
|
||||
|
||||
WxCpAgentService getAgentService();
|
||||
|
||||
WxCpOAService getOAService();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 任务卡片管理接口.
|
||||
* Created by Jeff on 2019-05-16.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/domainname">Jeff</a>
|
||||
* @date 2019-05-16
|
||||
*/
|
||||
public interface WxCpTaskCardService {
|
||||
/**
|
||||
* <pre>
|
||||
* 更新任务卡片消息状态
|
||||
* 详情请见: https://work.weixin.qq.com/api/doc#90000/90135/91579
|
||||
*
|
||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||
* </pre>
|
||||
*
|
||||
* @param userIds 企业的成员ID列表
|
||||
* @param taskId 任务卡片ID
|
||||
* @param clickedKey 已点击按钮的Key
|
||||
*/
|
||||
void update(List<String> userIds, String taskId, String clickedKey) throws WxErrorException;
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
|
||||
private WxCpTagService tagService = new WxCpTagServiceImpl(this);
|
||||
private WxCpAgentService agentService = new WxCpAgentServiceImpl(this);
|
||||
private WxCpOAService oaService = new WxCpOAServiceImpl(this);
|
||||
private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
|
||||
|
||||
/**
|
||||
* 全局的是否正在刷新access token的锁
|
||||
@@ -392,6 +393,11 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
|
||||
return oaService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTaskCardService getTaskCardService() {
|
||||
return taskCardService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestHttp<?, ?> getRequestHttp() {
|
||||
return this;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.api.WxCpTaskCardService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 任务卡片管理接口.
|
||||
* Created by Jeff on 2019-05-16.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/domainname">Jeff</a>
|
||||
* @date 2019-05-16
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxCpTaskCardServiceImpl implements WxCpTaskCardService {
|
||||
private final WxCpService mainService;
|
||||
|
||||
@Override
|
||||
public void update(List<String> userIds, String taskId, String clickedKey) throws WxErrorException {
|
||||
Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
|
||||
|
||||
Map<String, Object> data = new HashMap<>(4);
|
||||
data.put("userids", userIds);
|
||||
data.put("agentid", agentId);
|
||||
data.put("task_id", taskId);
|
||||
data.put("clicked_key", clickedKey);
|
||||
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/update_taskcard";
|
||||
this.mainService.post(url, WxGsonBuilder.create().toJson(data));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user