forked from chanjarster/weixin-java-tools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70a7781
commit e9e7f6e
Showing
15 changed files
with
420 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTaskCardUpdateResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package me.chanjar.weixin.cp.bean; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* <pre> | ||
* 更新任务卡片消息状态的返回类 | ||
* 参考文档:https://work.weixin.qq.com/api/doc#90000/90135/91579 | ||
* Created by Jeff on 2019-05-16. | ||
* </pre> | ||
* | ||
* @author <a href="https://github.com/domainname">Jeff</a> | ||
* @date 2019-05-16 | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class WxCpTaskCardUpdateResult implements Serializable { | ||
|
||
@SerializedName("errcode") | ||
private Integer errcode; | ||
|
||
@SerializedName("errmsg") | ||
private String errmsg; | ||
|
||
/** | ||
* 用户列表 | ||
*/ | ||
@SerializedName("invaliduser") | ||
private List<String> invalidUsers; | ||
|
||
public static WxCpTaskCardUpdateResult fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, WxCpTaskCardUpdateResult.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TaskCardBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package me.chanjar.weixin.cp.bean.messagebuilder; | ||
|
||
import me.chanjar.weixin.common.api.WxConsts; | ||
import me.chanjar.weixin.cp.bean.WxCpMessage; | ||
import me.chanjar.weixin.cp.bean.taskcard.TaskCardButton; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* <pre> | ||
* 任务卡片消息Builder | ||
* 用法: WxCustomMessage m = WxCustomMessage.TASKCARD().title(...)....toUser(...).build(); | ||
* </pre> | ||
* | ||
* @author <a href="https://github.com/domainname">Jeff</a> | ||
* @date 2019-05-16 | ||
*/ | ||
public class TaskCardBuilder extends BaseBuilder<TaskCardBuilder> { | ||
private String title; | ||
private String description; | ||
private String url; | ||
private String taskId; | ||
/** | ||
* 按钮个数为1~2个 | ||
*/ | ||
private List<TaskCardButton> buttons; | ||
|
||
public TaskCardBuilder() { | ||
this.msgType = WxConsts.KefuMsgType.TASKCARD; | ||
} | ||
|
||
public TaskCardBuilder title(String title) { | ||
this.title = title; | ||
return this; | ||
} | ||
|
||
public TaskCardBuilder description(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public TaskCardBuilder url(String url) { | ||
this.url = url; | ||
return this; | ||
} | ||
|
||
public TaskCardBuilder taskId(String taskId) { | ||
this.taskId = taskId; | ||
return this; | ||
} | ||
|
||
public TaskCardBuilder buttons(List<TaskCardButton> buttons) { | ||
this.buttons = buttons; | ||
return this; | ||
} | ||
|
||
@Override | ||
public WxCpMessage build() { | ||
WxCpMessage m = super.build(); | ||
m.setSafe(null); | ||
m.setTitle(this.title); | ||
m.setDescription(this.description); | ||
m.setUrl(this.url); | ||
m.setTaskId(this.taskId); | ||
m.setTaskButtons(this.buttons); | ||
return m; | ||
} | ||
} |
Oops, something went wrong.