@@ -28,6 +28,11 @@ public interface WxCpChatService { | |||||
*/ | */ | ||||
String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException; | String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException; | ||||
/** | |||||
* chatCreate 同名方法 | |||||
*/ | |||||
String create(String name, String owner, List<String> users, String chatId) throws WxErrorException; | |||||
/** | /** | ||||
* 修改群聊会话. | * 修改群聊会话. | ||||
* | * | ||||
@@ -40,6 +45,11 @@ public interface WxCpChatService { | |||||
*/ | */ | ||||
void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; | void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; | ||||
/** | |||||
* chatUpdate 同名方法 | |||||
*/ | |||||
void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; | |||||
/** | /** | ||||
* 获取群聊会话. | * 获取群聊会话. | ||||
* | * | ||||
@@ -49,6 +59,11 @@ public interface WxCpChatService { | |||||
*/ | */ | ||||
WxCpChat chatGet(String chatId) throws WxErrorException; | WxCpChat chatGet(String chatId) throws WxErrorException; | ||||
/** | |||||
* chatGet 同名方法 | |||||
*/ | |||||
WxCpChat get(String chatId) throws WxErrorException; | |||||
/** | /** | ||||
* 应用支持推送文本、图片、视频、文件、图文等类型. | * 应用支持推送文本、图片、视频、文件、图文等类型. | ||||
* 请求方式: POST(HTTPS) | * 请求方式: POST(HTTPS) | ||||
@@ -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: <pre> | |||||
* 企业微信OA相关接口 | |||||
* | |||||
* </pre> | |||||
*/ | |||||
public interface WxCpOAService { | |||||
/** | |||||
* <pre> | |||||
* 获取打卡数据 | |||||
* API doc : https://work.weixin.qq.com/api/doc#90000/90135/90262 | |||||
* </pre> | |||||
* | |||||
* @param openCheckinDataType 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡 | |||||
* @param starttime 获取打卡记录的开始时间 | |||||
* @param endtime 获取打卡记录的结束时间 | |||||
* @param userIdList 需要获取打卡记录的用户列表 | |||||
*/ | |||||
List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List<String> userIdList) throws WxErrorException; | |||||
/** | |||||
* <pre> | |||||
* 获取打卡规则 | |||||
* API doc : https://work.weixin.qq.com/api/doc#90000/90135/90263 | |||||
* </pre> | |||||
* | |||||
* @param datetime 需要获取规则的当天日期 | |||||
* @param userIdList 需要获取打卡规则的用户列表 | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | |||||
List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException; | |||||
/** | |||||
* <pre> | |||||
* 获取审批数据 | |||||
* 通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取10000个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 | |||||
* API doc : https://work.weixin.qq.com/api/doc#90000/90135/91530 | |||||
* </pre> | |||||
* | |||||
* @param starttime 获取审批记录的开始时间 | |||||
* @param endtime 获取审批记录的结束时间 | |||||
* @param nextSpnum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | |||||
WxCpApprovalDataResult getApprovalData(Date starttime, Date endtime, Long nextSpnum) throws WxErrorException; | |||||
List<WxCpDialRecord> getDialRecord(Date starttime, Date endtime, Integer offset, Integer limit) throws WxErrorException; | |||||
} |
@@ -303,6 +303,8 @@ public interface WxCpService { | |||||
WxCpAgentService getAgentService(); | WxCpAgentService getAgentService(); | ||||
WxCpOAService getOAService(); | |||||
/** | /** | ||||
* http请求对象 | * http请求对象 | ||||
*/ | */ | ||||
@@ -45,6 +45,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||
private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); | private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); | ||||
private WxCpTagService tagService = new WxCpTagServiceImpl(this); | private WxCpTagService tagService = new WxCpTagServiceImpl(this); | ||||
private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); | private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); | ||||
private WxCpOAService oaService = new WxCpOAServiceImpl(this); | |||||
/** | /** | ||||
* 全局的是否正在刷新access token的锁 | * 全局的是否正在刷新access token的锁 | ||||
@@ -386,6 +387,11 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||
return chatService; | return chatService; | ||||
} | } | ||||
@Override | |||||
public WxCpOAService getOAService() { | |||||
return oaService; | |||||
} | |||||
@Override | @Override | ||||
public RequestHttp<?, ?> getRequestHttp() { | public RequestHttp<?, ?> getRequestHttp() { | ||||
return this; | return this; | ||||
@@ -1,11 +1,5 @@ | |||||
package me.chanjar.weixin.cp.api.impl; | 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 com.google.gson.JsonParser; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | 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.WxCpAppChatMessage; | ||||
import me.chanjar.weixin.cp.bean.WxCpChat; | import me.chanjar.weixin.cp.bean.WxCpChat; | ||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | 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(); | return new JsonParser().parse(result).getAsJsonObject().get("chatid").getAsString(); | ||||
} | } | ||||
@Override | |||||
public String create(String name, String owner, List<String> users, String chatId) throws WxErrorException { | |||||
return chatCreate(name, owner, users, chatId); | |||||
} | |||||
@Override | @Override | ||||
public void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) | public void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) | ||||
throws WxErrorException { | throws WxErrorException { | ||||
@@ -75,6 +79,11 @@ public class WxCpChatServiceImpl implements WxCpChatService { | |||||
this.cpService.post(APPCHAT_UPDATE, WxGsonBuilder.create().toJson(data)); | this.cpService.post(APPCHAT_UPDATE, WxGsonBuilder.create().toJson(data)); | ||||
} | } | ||||
@Override | |||||
public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException { | |||||
chatUpdate(chatId, name, owner, usersToAdd, usersToDelete); | |||||
} | |||||
@Override | @Override | ||||
public WxCpChat chatGet(String chatId) throws WxErrorException { | public WxCpChat chatGet(String chatId) throws WxErrorException { | ||||
String result = this.cpService.get(APPCHAT_GET_CHATID + chatId, null); | 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); | .fromJson(JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString(), WxCpChat.class); | ||||
} | } | ||||
@Override | |||||
public WxCpChat get(String chatId) throws WxErrorException { | |||||
return chatGet(chatId); | |||||
} | |||||
@Override | @Override | ||||
public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { | public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { | ||||
this.cpService.post("https://qyapi.weixin.qq.com/cgi-bin/appchat/send", message.toJson()); | this.cpService.post("https://qyapi.weixin.qq.com/cgi-bin/appchat/send", message.toJson()); | ||||
@@ -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<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List<String> 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<List<WxCpCheckinData>>() { | |||||
}.getType() | |||||
); | |||||
} | |||||
@Override | |||||
public List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> 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<List<WxCpCheckinOption>>() { | |||||
}.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<WxCpDialRecord> 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<List<WxCpDialRecord>>() { | |||||
}.getType() | |||||
); | |||||
} | |||||
} |
@@ -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.HttpType; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | ||||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | ||||
import me.chanjar.weixin.cp.api.WxCpOAService; | |||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||
import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||
@@ -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<String,String> comm; | |||||
} | |||||
} |
@@ -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<String> mediaIds; | |||||
} |
@@ -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<Integer> 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> checkinDate; | |||||
@SerializedName("spe_workdays") | |||||
private List<SpeDay> speWorkdays; | |||||
@SerializedName("spe_offdays") | |||||
private List<SpeDay> 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<WifiMACInfo> wifiMACInfos; | |||||
@SerializedName("loc_infos") | |||||
private List<LocInfo> 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> checkinTime; | |||||
} | |||||
} |
@@ -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> 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; | |||||
} | |||||
} |
@@ -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<String> 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<WxCpCheckinData> 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<String> userLists = new ArrayList<>(); | |||||
userLists.add("user@aliyun.com"); | |||||
List<WxCpCheckinOption> results = wxService.getOAService().getCheckinOption(now,userLists); | |||||
System.out.println("results "); | |||||
System.out.println(gson.toJson(results)); | |||||
} | |||||
} |