diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java index a9a7cfe7..95f747e3 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java @@ -28,6 +28,11 @@ public interface WxCpChatService { */ String chatCreate(String name, String owner, List users, String chatId) throws WxErrorException; + /** + * chatCreate 同名方法 + */ + String create(String name, String owner, List users, String chatId) throws WxErrorException; + /** * 修改群聊会话. * @@ -40,6 +45,11 @@ public interface WxCpChatService { */ void chatUpdate(String chatId, String name, String owner, List usersToAdd, List usersToDelete) throws WxErrorException; + /** + * chatUpdate 同名方法 + */ + void update(String chatId, String name, String owner, List usersToAdd, List usersToDelete) throws WxErrorException; + /** * 获取群聊会话. * @@ -49,6 +59,11 @@ public interface WxCpChatService { */ WxCpChat chatGet(String chatId) throws WxErrorException; + /** + * chatGet 同名方法 + */ + WxCpChat get(String chatId) throws WxErrorException; + /** * 应用支持推送文本、图片、视频、文件、图文等类型. * 请求方式: POST(HTTPS) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAService.java new file mode 100644 index 00000000..e8cf874e --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAService.java @@ -0,0 +1,66 @@ +package me.chanjar.weixin.cp.api; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; +import me.chanjar.weixin.cp.bean.WxCpCheckinData; +import me.chanjar.weixin.cp.bean.WxCpCheckinOption; +import me.chanjar.weixin.cp.bean.WxCpDialRecord; + +import java.util.Date; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.api + * @date 2019-04-06 10:52 + * @Description:
+ *     企业微信OA相关接口
+ *
+ * 
+ */ +public interface WxCpOAService { + + /** + *
+   *     获取打卡数据
+   *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/90262
+   * 
+ * + * @param openCheckinDataType 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡 + * @param starttime 获取打卡记录的开始时间 + * @param endtime 获取打卡记录的结束时间 + * @param userIdList 需要获取打卡记录的用户列表 + */ + List getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List userIdList) throws WxErrorException; + + /** + *
+   *     获取打卡规则
+   *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/90263
+   * 
+ * + * @param datetime 需要获取规则的当天日期 + * @param userIdList 需要获取打卡规则的用户列表 + * @return + * @throws WxErrorException + */ + List getCheckinOption(Date datetime, List userIdList) throws WxErrorException; + + /** + *
+   *     获取审批数据
+   *     通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取10000个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。
+   *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/91530
+   * 
+ * + * @param starttime 获取审批记录的开始时间 + * @param endtime 获取审批记录的结束时间 + * @param nextSpnum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 + * @return + * @throws WxErrorException + */ + WxCpApprovalDataResult getApprovalData(Date starttime, Date endtime, Long nextSpnum) throws WxErrorException; + + List getDialRecord(Date starttime, Date endtime, Integer offset, Integer limit) throws WxErrorException; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index 927b79cb..732c1449 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -303,6 +303,8 @@ public interface WxCpService { WxCpAgentService getAgentService(); + WxCpOAService getOAService(); + /** * http请求对象 */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java index f9a146e8..161c747c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java @@ -45,6 +45,7 @@ public abstract class BaseWxCpServiceImpl implements WxCpService, RequestH private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); private WxCpTagService tagService = new WxCpTagServiceImpl(this); private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); + private WxCpOAService oaService = new WxCpOAServiceImpl(this); /** * 全局的是否正在刷新access token的锁 @@ -386,6 +387,11 @@ public abstract class BaseWxCpServiceImpl implements WxCpService, RequestH return chatService; } + @Override + public WxCpOAService getOAService() { + return oaService; + } + @Override public RequestHttp getRequestHttp() { return this; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java index 96e842ad..05d298c9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java @@ -1,11 +1,5 @@ package me.chanjar.weixin.cp.api.impl; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; - import com.google.gson.JsonParser; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.WxGsonBuilder; @@ -14,6 +8,11 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpAppChatMessage; import me.chanjar.weixin.cp.bean.WxCpChat; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 群聊服务实现. @@ -52,6 +51,11 @@ public class WxCpChatServiceImpl implements WxCpChatService { return new JsonParser().parse(result).getAsJsonObject().get("chatid").getAsString(); } + @Override + public String create(String name, String owner, List users, String chatId) throws WxErrorException { + return chatCreate(name, owner, users, chatId); + } + @Override public void chatUpdate(String chatId, String name, String owner, List usersToAdd, List usersToDelete) throws WxErrorException { @@ -75,6 +79,11 @@ public class WxCpChatServiceImpl implements WxCpChatService { this.cpService.post(APPCHAT_UPDATE, WxGsonBuilder.create().toJson(data)); } + @Override + public void update(String chatId, String name, String owner, List usersToAdd, List usersToDelete) throws WxErrorException { + chatUpdate(chatId, name, owner, usersToAdd, usersToDelete); + } + @Override public WxCpChat chatGet(String chatId) throws WxErrorException { String result = this.cpService.get(APPCHAT_GET_CHATID + chatId, null); @@ -82,6 +91,11 @@ public class WxCpChatServiceImpl implements WxCpChatService { .fromJson(JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString(), WxCpChat.class); } + @Override + public WxCpChat get(String chatId) throws WxErrorException { + return chatGet(chatId); + } + @Override public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { this.cpService.post("https://qyapi.weixin.qq.com/cgi-bin/appchat/send", message.toJson()); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImpl.java new file mode 100644 index 00000000..2d1ca6ab --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImpl.java @@ -0,0 +1,165 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpOAService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; +import me.chanjar.weixin.cp.bean.WxCpCheckinData; +import me.chanjar.weixin.cp.bean.WxCpCheckinOption; +import me.chanjar.weixin.cp.bean.WxCpDialRecord; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.util.Date; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.api.impl + * @date 2019-04-06 11:20 + * @Description: TODO + */ +public class WxCpOAServiceImpl implements WxCpOAService { + + private WxCpService mainService; + + public WxCpOAServiceImpl(WxCpService mainService) { + this.mainService = mainService; + } + + @Override + public List getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List userIdList) throws WxErrorException { + + if (starttime == null || endtime == null) { + throw new RuntimeException("starttime and endtime can't be null"); + } + + if (userIdList == null || userIdList.size() > 100) { + throw new RuntimeException("用户列表不能为空,不超过100个,若用户超过100个,请分批获取"); + } + + long endtimestamp = endtime.getTime() / 1000L; + long starttimestamp = starttime.getTime() / 1000L; + + if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { + throw new RuntimeException("获取记录时间跨度不超过一个月"); + } + + String url = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata"; + + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + + jsonObject.addProperty("opencheckindatatype", openCheckinDataType); + jsonObject.addProperty("starttime", starttimestamp); + jsonObject.addProperty("endtime", endtimestamp); + + for (String userid : userIdList) { + jsonArray.add(userid); + } + + jsonObject.add("useridlist", jsonArray); + + String responseContent = this.mainService.post(url, jsonObject.toString()); + JsonElement tmpJsonElement = new JsonParser().parse(responseContent); + return WxCpGsonBuilder.create() + .fromJson( + tmpJsonElement.getAsJsonObject().get("checkindata"), + new TypeToken>() { + }.getType() + ); + } + + @Override + public List getCheckinOption(Date datetime, List userIdList) throws WxErrorException { + String url = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckinoption"; + if (datetime == null) { + throw new RuntimeException("datetime can't be null"); + } + + if (userIdList == null || userIdList.size() > 100) { + throw new RuntimeException("用户列表不能为空,不超过100个,若用户超过100个,请分批获取"); + } + + JsonArray jsonArray = new JsonArray(); + for (String userid : userIdList) { + jsonArray.add(userid); + } + + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("datetime", datetime.getTime() / 1000L); + jsonObject.add("useridlist", jsonArray); + + String responseContent = this.mainService.post(url, jsonObject.toString()); + JsonElement tmpJsonElement = new JsonParser().parse(responseContent); + + return WxCpGsonBuilder.create() + .fromJson( + tmpJsonElement.getAsJsonObject().get("info"), + new TypeToken>() { + }.getType() + ); + } + + @Override + public WxCpApprovalDataResult getApprovalData(Date starttime, Date endtime, Long nextSpnum) throws WxErrorException { + + String url = "https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata"; + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("starttime", starttime.getTime() / 1000L); + jsonObject.addProperty("endtime", endtime.getTime() / 1000L); + if (nextSpnum != null) { + jsonObject.addProperty("next_spnum", nextSpnum); + } + + String responseContent = this.mainService.post(url, jsonObject.toString()); + return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class); + } + + @Override + public List getDialRecord(Date starttime, Date endtime, Integer offset, Integer limit) throws WxErrorException { + + String url = "https://qyapi.weixin.qq.com/cgi-bin/dial/get_dial_record"; + JsonObject jsonObject = new JsonObject(); + + if (offset == null) { + offset = 0; + } + + if (limit == null || limit <= 0) { + limit = 100; + } + + jsonObject.addProperty("offset", offset); + jsonObject.addProperty("limit", limit); + + if (starttime != null && endtime != null) { + + long endtimestamp = endtime.getTime() / 1000L; + long starttimestamp = starttime.getTime() / 1000L; + + if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { + throw new RuntimeException("受限于网络传输,起止时间的最大跨度为30天,如超过30天,则以结束时间为基准向前取30天进行查询"); + } + + jsonObject.addProperty("start_time", starttimestamp); + jsonObject.addProperty("end_time", endtimestamp); + + + } + + String responseContent = this.mainService.post(url, jsonObject.toString()); + JsonElement tmpJsonElement = new JsonParser().parse(responseContent); + + return WxCpGsonBuilder.create() + .fromJson( + tmpJsonElement.getAsJsonObject().get("record"), + new TypeToken>() { + }.getType() + ); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java index eedb0419..86e23716 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java @@ -8,6 +8,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.HttpType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; +import me.chanjar.weixin.cp.api.WxCpOAService; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpApprovalDataResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpApprovalDataResult.java new file mode 100644 index 00000000..3e1299e9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpApprovalDataResult.java @@ -0,0 +1,69 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.bean + * @date 2019-04-06 14:36 + * @Description: 企业微信 OA 审批数据 + */ +@Data +public class WxCpApprovalDataResult implements Serializable { + private static final long serialVersionUID = -1046940445840716590L; + + @SerializedName("errcode") + private Integer errCode; + + @SerializedName("errmsg") + private String errMsg; + + private Integer count; + + private Integer total; + + @SerializedName("next_spnum") + private Long nextSpnum; + + private WxCpApprovalData[] data; + + + @Data + public static class WxCpApprovalData implements Serializable{ + + private static final long serialVersionUID = -3051785319608491640L; + + private String spname; + + @SerializedName("apply_name") + private String applyName; + + @SerializedName("apply_org") + private String applyOrg; + + @SerializedName("approval_name") + private String[] approvalName; + + @SerializedName("notify_name") + private String[] notifyName; + + @SerializedName("sp_status") + private Integer spStatus; + + @SerializedName("sp_num") + private Long spNum; + + @SerializedName("apply_time") + private Long applyTime; + + @SerializedName("apply_user_id") + private String applyUserId; + + @SerializedName("comm") + private Map comm; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinData.java new file mode 100644 index 00000000..369c771f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinData.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.bean + * @date 2019-04-06 11:01 + * @Description: 企业微信打卡数据 + */ +@Data +public class WxCpCheckinData implements Serializable { + + private static final long serialVersionUID = 1915820330847799605L; + + @SerializedName("userid") + private String userId; + + @SerializedName("groupname") + private String groupName; + + @SerializedName("checkin_type") + private String checkinType; + + @SerializedName("exception_type") + private String exceptionType; + + @SerializedName("checkin_time") + private Long checkinTime; + + @SerializedName("location_title") + private String locationTitle; + + @SerializedName("location_detail") + private String locationDetail; + + @SerializedName("wifiname") + private String wifiName; + + @SerializedName("wifimac") + private String wifiMAC; + + private String notes; + + @SerializedName("mediaids") + private List mediaIds; +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinOption.java new file mode 100644 index 00000000..9cc3c389 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpCheckinOption.java @@ -0,0 +1,151 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.bean + * @date 2019-04-06 13:22 + * @Description: 企业微信打卡规则 + */ +@Data +public class WxCpCheckinOption implements Serializable { + private static final long serialVersionUID = -1964233697990417482L; + + @SerializedName("userid") + private String userId; + + private Group group; + + + @Data + public static class CheckinDate implements Serializable { + + private static final long serialVersionUID = -5601722383347110974L; + + private List workdays; + + @SerializedName("checkintime") + private CheckinTime[] checkinTime; + + @SerializedName("flex_time") + private Long flexTime; + + @SerializedName("noneed_offwork") + private Boolean noneedOffwork; + + @SerializedName("limit_aheadtime") + private Long limitAheadtime; + } + + @Data + public static class CheckinTime implements Serializable { + + private static final long serialVersionUID = -8579954143265336276L; + + @SerializedName("work_sec") + private Long workSec; + + @SerializedName("off_work_sec") + private Long offWorkSec; + + @SerializedName("remind_work_sec") + private Long remindWorkSec; + + @SerializedName("remind_off_work_sec") + private Long remindOffWorkSec; + } + + @Data + public static class Group implements Serializable { + + private static final long serialVersionUID = -5888406969613403044L; + + @SerializedName("groupid") + private Long id; + + @SerializedName("groupname") + private String name; + + @SerializedName("grouptype") + private Integer type; + + @SerializedName("checkindate") + private List checkinDate; + + @SerializedName("spe_workdays") + private List speWorkdays; + + @SerializedName("spe_offdays") + private List speOffdays; + + @SerializedName("sync_holidays") + private Boolean syncHolidays; + + @SerializedName("need_photo") + private Boolean needPhoto; + + @SerializedName("note_can_use_local_pic") + private Boolean note_can_use_local_pic; + + @SerializedName("allow_checkin_offworkday") + private Boolean allow_checkin_offworkday; + + @SerializedName("allow_apply_offworkday") + private Boolean allow_apply_offworkday; + + @SerializedName("wifimac_infos") + private List wifiMACInfos; + + @SerializedName("loc_infos") + private List locInfos; + + } + + @Data + public static class WifiMACInfo implements Serializable{ + + private static final long serialVersionUID = -4657809185716627368L; + + @SerializedName("wifiname") + private String name; + + @SerializedName("wifimac") + private String mac; + } + + @Data + public static class LocInfo implements Serializable{ + + private static final long serialVersionUID = -618965280668099608L; + + private Long lat; + private Long lng; + + @SerializedName("loc_title") + private String title; + + @SerializedName("loc_detail") + private String detail; + + private Long distance; + } + + @Data + public static class SpeDay implements Serializable{ + + private static final long serialVersionUID = -3538818921359212748L; + + private Long timestamp; + private String notes; + + @SerializedName("checkintime") + private List checkinTime; + + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDialRecord.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDialRecord.java new file mode 100644 index 00000000..d8e40c79 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDialRecord.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.cp.bean; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.bean + * @date 2019-04-06 15:38 + * @Description: 公费电话拨打记录 + */ +@Data +public class WxCpDialRecord implements Serializable { + + private static final long serialVersionUID = 4178886812949929116L; + @SerializedName("call_time") + private Long callTime; + + /** + * 总通话时长,单位为分钟 + */ + @SerializedName("total_duration") + private Integer totalDuration; + + /** + * 通话类型,1-单人通话 2-多人通话 + */ + @SerializedName("call_type") + private Integer callType; + + private Caller caller; + + private List callee; + + /** + * 主叫信息 + */ + @Data + public static class Caller implements Serializable{ + + private static final long serialVersionUID = 4792200404338145607L; + + @SerializedName("userid") + private String userId; + + private Integer duration; + } + + /** + * 被叫信息 + */ + @Data + public static class Callee implements Serializable{ + + private static final long serialVersionUID = 2390963671336179550L; + + /** + * 被叫用户的userid,当被叫用户为企业内用户时返回 + */ + @SerializedName("userid") + private String userId; + + /** + * 被叫用户的号码,当被叫用户为外部用户时返回 + */ + private String phone; + + private Integer duration; + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImplTest.java new file mode 100644 index 00000000..1dff5366 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImplTest.java @@ -0,0 +1,67 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.Gson; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.ApiTestModule; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpCheckinData; +import me.chanjar.weixin.cp.bean.WxCpCheckinOption; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author Element + * @Package me.chanjar.weixin.cp.api.impl + * @date 2019-04-20 13:46 + * @Description: TODO + */ + +@Guice(modules = ApiTestModule.class) +public class WxCpOAServiceImplTest { + + @Inject + protected WxCpService wxService; + + @Inject + protected Gson gson; + + @Test + public void testGetCheckinData() throws ParseException, WxErrorException { + Date starttime,endtime; + List userLists = new ArrayList<>(); + + starttime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-01"); + endtime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-20"); + + userLists.add("1"); + userLists.add("2"); + userLists.add("3"); + + List results = wxService.getOAService().getCheckinData(1, starttime,endtime,userLists); + + System.out.println("results "); + System.out.println(gson.toJson(results)); + + } + + @Test + public void testGetCheckinOption() throws WxErrorException{ + + Date now = new Date(); + List userLists = new ArrayList<>(); + + userLists.add("user@aliyun.com"); + + List results = wxService.getOAService().getCheckinOption(now,userLists); + + System.out.println("results "); + System.out.println(gson.toJson(results)); + } +}