repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java
package me.chanjar.weixin.cp.util.json; import com.google.gson.*; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.cp.bean.Gender; import me.chanjar.weixin.cp.bean.WxCpUser; import java.lang.reflect.Type; import java.util.Arrays; import java.util.stream.IntStream; import static me.chanjar.weixin.cp.bean.WxCpUser.*; /** * cp user gson adapter. * * @author Daniel Qian */ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSerializer<WxCpUser> { private static final String EXTERNAL_PROFILE = "external_profile"; private static final String EXTERNAL_ATTR = "external_attr"; private static final String EXTRA_ATTR = "extattr"; private static final String EXTERNAL_POSITION = "external_position"; private static final String DEPARTMENT = "department"; private static final String EXTERNAL_CORP_NAME = "external_corp_name"; private static final String WECHAT_CHANNELS = "wechat_channels"; private static final String ORDER = "order"; private static final String POSITIONS = "positions"; private static final String USER_ID = "userid"; private static final String NEW_USER_ID = "new_userid"; private static final String NAME = "name"; private static final String POSITION = "position"; private static final String MOBILE = "mobile"; private static final String GENDER = "gender"; private static final String EMAIL = "email"; private static final String BIZ_MAIL = "biz_mail"; private static final String AVATAR = "avatar"; private static final String THUMB_AVATAR = "thumb_avatar"; private static final String ADDRESS = "address"; private static final String AVATAR_MEDIAID = "avatar_mediaid"; private static final String STATUS = "status"; private static final String ENABLE = "enable"; private static final String ALIAS = "alias"; private static final String IS_LEADER = "isleader"; private static final String IS_LEADER_IN_DEPT = "is_leader_in_dept"; private static final String HIDE_MOBILE = "hide_mobile"; private static final String ENGLISH_NAME = "english_name"; private static final String TELEPHONE = "telephone"; private static final String QR_CODE = "qr_code"; private static final String TO_INVITE = "to_invite"; private static final String OPEN_USER_ID = "open_userid"; private static final String MAIN_DEPARTMENT = "main_department"; private static final String DIRECT_LEADER = "direct_leader"; private static final String TYPE = "type"; private static final String VALUE = "value"; private static final String TEXT = "text"; private static final String WEB = "web"; private static final String MINIPROGRAM = "miniprogram"; private static final String URL = "url"; private static final String TITLE = "title"; private static final String APPID = "appid"; private static final String PAGE_PATH = "pagepath"; private static final String ATTRS = "attrs"; private static final String NICKNAME = "nickname"; @Override public WxCpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject o = json.getAsJsonObject(); WxCpUser user = new WxCpUser(); user.setDepartIds(parseJsonArrayToLongArray(o, DEPARTMENT)); user.setOrders(parseJsonArrayToIntegerArray(o, ORDER)); user.setPositions(parseJsonArrayToStringArray(o, POSITIONS)); user.setUserId(GsonHelper.getString(o, USER_ID)); user.setName(GsonHelper.getString(o, NAME)); user.setPosition(GsonHelper.getString(o, POSITION)); user.setMobile(GsonHelper.getString(o, MOBILE)); user.setGender(Gender.fromCode(GsonHelper.getString(o, GENDER))); user.setEmail(GsonHelper.getString(o, EMAIL)); user.setBizMail(GsonHelper.getString(o, BIZ_MAIL)); user.setAvatar(GsonHelper.getString(o, AVATAR)); user.setThumbAvatar(GsonHelper.getString(o, THUMB_AVATAR)); user.setAddress(GsonHelper.getString(o, ADDRESS)); user.setAvatarMediaId(GsonHelper.getString(o, AVATAR_MEDIAID)); user.setStatus(GsonHelper.getInteger(o, STATUS)); user.setEnable(GsonHelper.getInteger(o, ENABLE)); user.setAlias(GsonHelper.getString(o, ALIAS)); user.setIsLeader(GsonHelper.getInteger(o, IS_LEADER)); user.setIsLeaderInDept(GsonHelper.getIntArray(o, IS_LEADER_IN_DEPT)); user.setHideMobile(GsonHelper.getInteger(o, HIDE_MOBILE)); user.setEnglishName(GsonHelper.getString(o, ENGLISH_NAME)); user.setTelephone(GsonHelper.getString(o, TELEPHONE)); user.setQrCode(GsonHelper.getString(o, QR_CODE)); user.setToInvite(GsonHelper.getBoolean(o, TO_INVITE)); user.setOpenUserId(GsonHelper.getString(o, OPEN_USER_ID)); user.setMainDepartment(GsonHelper.getString(o, MAIN_DEPARTMENT)); user.setDirectLeader(GsonHelper.getStringArray(o, DIRECT_LEADER)); if (GsonHelper.isNotNull(o.get(EXTRA_ATTR))) { this.buildExtraAttrs(o, user); } if (GsonHelper.isNotNull(o.get(EXTERNAL_PROFILE))) { user.setExternalCorpName(GsonHelper.getString(o.getAsJsonObject().get(EXTERNAL_PROFILE).getAsJsonObject(), EXTERNAL_CORP_NAME)); JsonElement jsonElement = o.get(EXTERNAL_PROFILE).getAsJsonObject().get(WECHAT_CHANNELS); if (jsonElement != null) { JsonObject asJsonObject = jsonElement.getAsJsonObject(); user.setWechatChannels(WechatChannels.builder().nickname(GsonHelper.getString(asJsonObject, NICKNAME)).status(GsonHelper.getInteger(asJsonObject, STATUS)).build()); } this.buildExternalAttrs(o, user); } user.setExternalPosition(GsonHelper.getString(o, EXTERNAL_POSITION)); return user; } private Long[] parseJsonArrayToLongArray(JsonObject o, String key) { JsonElement element = o.get(key); if (element == null || !element.isJsonArray()) { return null; } JsonArray jsonArray = element.getAsJsonArray(); return IntStream.range(0, jsonArray.size()) .mapToObj(i -> jsonArray.get(i).getAsLong()) .toArray(Long[]::new); } private Integer[] parseJsonArrayToIntegerArray(JsonObject o, String key) { JsonElement element = o.get(key); if (element == null || !element.isJsonArray()) { return null; } JsonArray jsonArray = element.getAsJsonArray(); return IntStream.range(0, jsonArray.size()) .mapToObj(i -> jsonArray.get(i).getAsInt()) .toArray(Integer[]::new); } private String[] parseJsonArrayToStringArray(JsonObject o, String key) { JsonElement element = o.get(key); if (element == null || !element.isJsonArray()) { return null; } JsonArray jsonArray = element.getAsJsonArray(); return IntStream.range(0, jsonArray.size()) .mapToObj(i -> jsonArray.get(i).getAsString()) .toArray(String[]::new); } private void buildExtraAttrs(JsonObject o, WxCpUser user) { JsonArray attrJsonElements = o.get(EXTRA_ATTR).getAsJsonObject().get(ATTRS).getAsJsonArray(); for (JsonElement attrJsonElement : attrJsonElements) { final Integer type = GsonHelper.getInteger(attrJsonElement.getAsJsonObject(), TYPE); final Attr attr = new Attr().setType(type) .setName(GsonHelper.getString(attrJsonElement.getAsJsonObject(), NAME)); user.getExtAttrs().add(attr); if (type == null) { attr.setTextValue(GsonHelper.getString(attrJsonElement.getAsJsonObject(), VALUE)); continue; } switch (type) { case 0: { JsonElement textJsonElement = attrJsonElement.getAsJsonObject().get(TEXT); if (textJsonElement != null && !textJsonElement.isJsonNull() && textJsonElement.isJsonObject()) { attr.setTextValue(GsonHelper.getString(textJsonElement.getAsJsonObject(), VALUE)); } else { attr.setTextValue(null); // Clear or set a default value to avoid stale data } break; } case 1: { final JsonObject web = attrJsonElement.getAsJsonObject().get(WEB).getAsJsonObject(); attr.setWebTitle(GsonHelper.getString(web, TITLE)) .setWebUrl(GsonHelper.getString(web, URL)); break; } default://ignored } } } private void buildExternalAttrs(JsonObject o, WxCpUser user) { JsonElement jsonElement = o.get(EXTERNAL_PROFILE).getAsJsonObject().get(EXTERNAL_ATTR); if (jsonElement == null) { return; } JsonArray attrJsonElements = jsonElement.getAsJsonArray(); for (JsonElement element : attrJsonElements) { final Integer type = GsonHelper.getInteger(element.getAsJsonObject(), TYPE); final String name = GsonHelper.getString(element.getAsJsonObject(), NAME); if (type == null) { continue; } switch (type) { case 0: { user.getExternalAttrs() .add(ExternalAttribute.builder() .type(type) .name(name) .value(GsonHelper.getString(element.getAsJsonObject().get(TEXT).getAsJsonObject(), VALUE)) .build() ); break; } case 1: { final JsonObject web = element.getAsJsonObject().get(WEB).getAsJsonObject(); user.getExternalAttrs() .add(ExternalAttribute.builder() .type(type) .name(name) .url(GsonHelper.getString(web, URL)) .title(GsonHelper.getString(web, TITLE)) .build() ); break; } case 2: { final JsonObject miniprogram = element.getAsJsonObject().get(MINIPROGRAM).getAsJsonObject(); user.getExternalAttrs() .add(ExternalAttribute.builder() .type(type) .name(name) .appid(GsonHelper.getString(miniprogram, APPID)) .pagePath(GsonHelper.getString(miniprogram, PAGE_PATH)) .title(GsonHelper.getString(miniprogram, TITLE)) .build() ); break; } default://ignored } } } @Override public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationContext context) { JsonObject o = new JsonObject(); addProperty(o, USER_ID, user.getUserId()); addProperty(o, NEW_USER_ID, user.getNewUserId()); addProperty(o, NAME, user.getName()); addArrayProperty(o, DEPARTMENT, user.getDepartIds()); addArrayProperty(o, ORDER, user.getOrders()); addProperty(o, POSITION, user.getPosition()); addArrayProperty(o, POSITIONS, user.getPositions()); addProperty(o, MOBILE, user.getMobile()); if (user.getGender() != null) { o.addProperty(GENDER, user.getGender().getCode()); } addProperty(o, EMAIL, user.getEmail()); addProperty(o, BIZ_MAIL, user.getBizMail()); addProperty(o, AVATAR, user.getAvatar()); addProperty(o, THUMB_AVATAR, user.getThumbAvatar()); addProperty(o, ADDRESS, user.getAddress()); addProperty(o, AVATAR_MEDIAID, user.getAvatarMediaId()); addProperty(o, STATUS, user.getStatus()); addProperty(o, ENABLE, user.getEnable()); addProperty(o, ALIAS, user.getAlias()); addProperty(o, IS_LEADER, user.getIsLeader()); if (user.getIsLeaderInDept() != null && user.getIsLeaderInDept().length > 0) { JsonArray ary = new JsonArray(); Arrays.stream(user.getIsLeaderInDept()).forEach(ary::add); o.add(IS_LEADER_IN_DEPT, ary); } addProperty(o, HIDE_MOBILE, user.getHideMobile()); addProperty(o, ENGLISH_NAME, user.getEnglishName()); addProperty(o, TELEPHONE, user.getTelephone()); addProperty(o, QR_CODE, user.getQrCode()); if (user.getToInvite() != null) { o.addProperty(TO_INVITE, user.getToInvite()); } addProperty(o, MAIN_DEPARTMENT, user.getMainDepartment()); // Special handling for directLeader: include empty arrays to support WeChat Work API reset functionality if (user.getDirectLeader() != null) { JsonArray directLeaderArray = new JsonArray(); Arrays.stream(user.getDirectLeader()).forEach(directLeaderArray::add); o.add(DIRECT_LEADER, directLeaderArray); } if (!user.getExtAttrs().isEmpty()) { JsonArray attrsJsonArray = new JsonArray(); for (Attr attr : user.getExtAttrs()) { JsonObject attrJson = GsonHelper.buildJsonObject(TYPE, attr.getType(), NAME, attr.getName()); attrsJsonArray.add(attrJson); if (attr.getType() == null) { attrJson.addProperty(NAME, attr.getName()); attrJson.addProperty(VALUE, attr.getTextValue()); continue; } switch (attr.getType()) { case 0: attrJson.add(TEXT, GsonHelper.buildJsonObject(VALUE, attr.getTextValue())); break; case 1: attrJson.add(WEB, GsonHelper.buildJsonObject(URL, attr.getWebUrl(), TITLE, attr.getWebTitle())); break; default: //ignored } } JsonObject attrsJson = new JsonObject(); attrsJson.add(ATTRS, attrsJsonArray); o.add(EXTRA_ATTR, attrsJson); } this.addProperty(o, EXTERNAL_POSITION, user.getExternalPosition()); JsonObject attrsJson = new JsonObject(); o.add(EXTERNAL_PROFILE, attrsJson); this.addProperty(attrsJson, EXTERNAL_CORP_NAME, user.getExternalCorpName()); if (user.getWechatChannels() != null) { attrsJson.add(WECHAT_CHANNELS, GsonHelper.buildJsonObject(NICKNAME, user.getWechatChannels().getNickname(), STATUS, user.getWechatChannels().getStatus())); } if (!user.getExternalAttrs().isEmpty()) { JsonArray attrsJsonArray = new JsonArray(); for (ExternalAttribute attr : user.getExternalAttrs()) { JsonObject attrJson = GsonHelper.buildJsonObject(TYPE, attr.getType(), NAME, attr.getName()); attrsJsonArray.add(attrJson); if (attr.getType() == null) { continue; } switch (attr.getType()) { case 0: attrJson.add(TEXT, GsonHelper.buildJsonObject(VALUE, attr.getValue())); break; case 1: attrJson.add(WEB, GsonHelper.buildJsonObject(URL, attr.getUrl(), TITLE, attr.getTitle())); break; case 2: attrJson.add(MINIPROGRAM, GsonHelper.buildJsonObject(APPID, attr.getAppid(), PAGE_PATH, attr.getPagePath(), TITLE, attr.getTitle())); break; default://忽略 } } attrsJson.add(EXTERNAL_ATTR, attrsJsonArray); } return o; } private void addArrayProperty(JsonObject o, String key, Object[] array) { if (array != null && array.length > 0) { JsonArray jsonArray = new JsonArray(); Arrays.stream(array).forEach(item -> { if (item instanceof Number) { jsonArray.add((Number) item); } else { jsonArray.add(item.toString()); } }); o.add(key, jsonArray); } } private void addProperty(JsonObject object, String property, Object value) { if (value != null) { if (value instanceof Number) { object.addProperty(property, (Number) value); } else if (value instanceof Boolean) { object.addProperty(property, (Boolean) value); } else { object.addProperty(property, value.toString()); } } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpCryptUtil.java
package me.chanjar.weixin.cp.util.crypto; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.crypto.WxCryptUtil; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.asn1.pkcs.RSAPrivateKey; import javax.crypto.Cipher; import java.nio.charset.StandardCharsets; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.RSAPrivateCrtKeySpec; import java.util.Base64; import java.util.Objects; /** * The type Wx cp crypt util. * * @author qian */ public class WxCpCryptUtil extends WxCryptUtil { /** * Instantiates a new Wx cp crypt util. * * @param wxCpConfigStorage the wx cp config storage */ public WxCpCryptUtil(WxCpConfigStorage wxCpConfigStorage) { /* * @param token 公众平台上,开发者设置的token * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey * @param appidOrCorpid 公众平台appid */ String encodingAesKey = wxCpConfigStorage.getAesKey(); String token = wxCpConfigStorage.getToken(); String corpId = wxCpConfigStorage.getCorpId(); this.token = token; this.appidOrCorpid = corpId; this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); } /** * 判断使用PKCS8或者PKCS1进行解密 * * @param encryptRandomKey 使用PUBLICKEY_VER指定版本的公钥进行非对称加密后base64加密的内容 * @param msgAuditPriKey 会话存档私钥 * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... * @return string * @throws Exception the exception */ public static String decryptPriKey(String encryptRandomKey, String msgAuditPriKey, Integer pkcs1) throws Exception { if (Objects.isNull(pkcs1)) { throw new WxErrorException("请配置会话存档解密方式"); } if (Objects.equals(pkcs1, 1)) { return decryptPriKeyByPKCS1(encryptRandomKey, msgAuditPriKey); } return decryptPriKeyByPKCS8(encryptRandomKey, msgAuditPriKey); } /** * PKCS8 解密私钥 * * @param encryptRandomKey the encrypt random key * @param msgAuditPriKey the msg audit pri key * @return string * @throws Exception the exception */ public static String decryptPriKeyByPKCS8(String encryptRandomKey, String msgAuditPriKey) throws Exception { String privateKey = msgAuditPriKey.replaceAll("(\r\n|\r|\n|\n\r)", "") .replace("-----BEGIN PRIVATE KEY-----", "") .replace("-----END PRIVATE KEY-----", "") .replace(" ", ""); byte[] keyBytes = Base64.getDecoder().decode(privateKey); PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); PrivateKey priKey = keyFactory.generatePrivate(pkcs8KeySpec); Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm()); cipher.init(Cipher.DECRYPT_MODE, priKey); byte[] utf8 = cipher.doFinal(Base64.getDecoder().decode(encryptRandomKey)); return new String(utf8, StandardCharsets.UTF_8); } /** * 会话存档,PKCS1 解密私钥 * 企业获取的会话内容将用公钥加密,企业用自行保存的私钥解开会话内容数据 * * @param encryptRandomKey 使用PUBLICKEY_VER指定版本的公钥进行非对称加密后base64加密的内容,需要业务方先base64 * decode处理后,再使用指定版本的私钥进行解密,得出内容。String类型 * @param msgAuditPriKey 会话存档私钥 * @return string * @throws Exception the exception */ public static String decryptPriKeyByPKCS1(String encryptRandomKey, String msgAuditPriKey) throws Exception { String privateKey = msgAuditPriKey.replaceAll("(\r\n|\r|\n|\n\r)", "") .replace("-----BEGIN RSA PRIVATE KEY-----", "") .replace("-----END RSA PRIVATE KEY-----", "") .replace(" ", ""); byte[] keyBytes = Base64.getDecoder().decode(privateKey); // Java 8 以后 sun.security.util.DerInputStream 和 sun.security.util.DerValue 无法使用 // 因此改为通过 org.bouncycastle:bcprov-jdk18on 来完成 ASN1 编码数据解析 final RSAPrivateKey key = RSAPrivateKey.getInstance(keyBytes); final RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec( key.getModulus(), key.getPublicExponent(), key.getPrivateExponent(), key.getPrime1(), key.getPrime2(), key.getExponent1(), key.getExponent2(), key.getCoefficient()); PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.DECRYPT_MODE, priKey); byte[] utf8 = cipher.doFinal(Base64.getDecoder().decode(encryptRandomKey)); return new String(utf8, StandardCharsets.UTF_8); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpTpCryptUtil.java
package me.chanjar.weixin.cp.util.crypto; import me.chanjar.weixin.common.util.crypto.WxCryptUtil; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import org.apache.commons.lang3.StringUtils; import java.util.Base64; /** * The type Wx cp tp crypt util. * * @author someone */ public class WxCpTpCryptUtil extends WxCryptUtil { /** * 构造函数. * * @param wxCpTpConfigStorage the wx cp tp config storage */ public WxCpTpCryptUtil(WxCpTpConfigStorage wxCpTpConfigStorage) { /* * @param token 公众平台上,开发者设置的token * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey * @param appidOrCorpid 公众平台corpId */ String encodingAesKey = wxCpTpConfigStorage.getEncodingAESKey(); String token = wxCpTpConfigStorage.getToken(); String corpId = wxCpTpConfigStorage.getCorpId(); this.token = token; this.appidOrCorpid = corpId; this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " ")); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java
package me.chanjar.weixin.cp.constant; /** * <pre> * 企业微信api地址常量类 * Created by BinaryWang on 2019-06-02. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpApiPathConsts { /** * The constant DEFAULT_CP_BASE_URL. */ String DEFAULT_CP_BASE_URL = "https://qyapi.weixin.qq.com"; /** * The constant GET_JSAPI_TICKET. */ String GET_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket"; /** * The constant GET_AGENT_CONFIG_TICKET. */ String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config"; /** * The constant GET_CALLBACK_IP. */ String GET_CALLBACK_IP = "/cgi-bin/getcallbackip"; /** * The constant GET_API_DOMAIN_IP. */ String GET_API_DOMAIN_IP = "/cgi-bin/get_api_domain_ip"; /** * The constant BATCH_REPLACE_PARTY. */ String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty"; /** * The constant BATCH_SYNC_USER. */ String BATCH_SYNC_USER = "/cgi-bin/batch/syncuser"; /** * The constant BATCH_REPLACE_USER. */ String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser"; /** * The constant BATCH_GET_RESULT. */ String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid="; /** * The constant JSCODE_TO_SESSION. */ String JSCODE_TO_SESSION = "/cgi-bin/miniprogram/jscode2session"; /** * The constant GET_TOKEN. */ String GET_TOKEN = "/cgi-bin/gettoken?corpid=%s&corpsecret=%s"; /** * The constant WEBHOOK_SEND. */ String WEBHOOK_SEND = "/cgi-bin/webhook/send?key="; /** * 消息推送相关接口 * https://work.weixin.qq.com/api/doc/90000/90135/90235 */ interface Message { /** * 发送应用消息 */ String MESSAGE_SEND = "/cgi-bin/message/send"; /** * 查询应用消息发送统计 */ String GET_STATISTICS = "/cgi-bin/message/get_statistics"; /** * 发送「学校通知」 * https://developer.work.weixin.qq.com/document/path/92321 */ String EXTERNAL_CONTACT_MESSAGE_SEND = "/cgi-bin/externalcontact/message/send"; /** * 撤回应用消息 * https://developer.work.weixin.qq.com/document/path/94867 */ String MESSAGE_RECALL = "/cgi-bin/message/recall"; /** * 互联企业发送应用消息 * https://developer.work.weixin.qq.com/document/path/90250 */ String LINKEDCORP_MESSAGE_SEND = "/cgi-bin/linkedcorp/message/send"; } /** * The interface Agent. */ interface Agent { /** * The constant AGENT_GET. */ String AGENT_GET = "/cgi-bin/agent/get?agentid=%d"; /** * The constant AGENT_SET. */ String AGENT_SET = "/cgi-bin/agent/set"; /** * The constant AGENT_LIST. */ String AGENT_LIST = "/cgi-bin/agent/list"; /** * The constant AGENT_GET_ADMIN_LIST. */ String AGENT_GET_ADMIN_LIST = "/cgi-bin/agent/get_admin_list"; } /** * The interface Work bench. */ interface WorkBench { /** * The constant WORKBENCH_TEMPLATE_SET. */ String WORKBENCH_TEMPLATE_SET = "/cgi-bin/agent/set_workbench_template"; /** * The constant WORKBENCH_TEMPLATE_GET. */ String WORKBENCH_TEMPLATE_GET = "/cgi-bin/agent/get_workbench_template"; /** * The constant WORKBENCH_DATA_SET. */ String WORKBENCH_DATA_SET = "/cgi-bin/agent/set_workbench_data"; /** * The constant WORKBENCH_BATCH_DATA_SET. */ String WORKBENCH_BATCH_DATA_SET = "/cgi-bin/agent/batch_set_workbench_data"; } /** * The interface O auth 2. */ interface OAuth2 { /** * The constant GET_USER_INFO. */ String GET_USER_INFO = "/cgi-bin/user/getuserinfo?code=%s&agentid=%d"; /** * The constant GET_SCHOOL_USER_INFO. */ String GET_SCHOOL_USER_INFO = "/cgi-bin/school/getuserinfo?code=%s"; /** * The constant GET_USER_DETAIL. */ String GET_USER_DETAIL = "/cgi-bin/auth/getuserdetail"; /** * The constant URL_OAUTH2_AUTHORIZE. */ String URL_OAUTH2_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize"; /** * The constant GET_USER_INFO without agentId. */ String GET_USER_AUTH_INFO = "/cgi-bin/auth/getuserinfo?code=%s"; /** * The constant GET_TFA_INFO. */ String GET_TFA_INFO = "/cgi-bin/auth/get_tfa_info"; } /** * The interface Chat. */ interface Chat { /** * The constant APPCHAT_CREATE. */ String APPCHAT_CREATE = "/cgi-bin/appchat/create"; /** * The constant APPCHAT_UPDATE. */ String APPCHAT_UPDATE = "/cgi-bin/appchat/update"; /** * The constant APPCHAT_GET_CHATID. */ String APPCHAT_GET_CHATID = "/cgi-bin/appchat/get?chatid="; /** * The constant APPCHAT_SEND. */ String APPCHAT_SEND = "/cgi-bin/appchat/send"; } /** * The interface Department. */ interface Department { /** * The constant DEPARTMENT_CREATE. */ String DEPARTMENT_CREATE = "/cgi-bin/department/create"; /** * The constant DEPARTMENT_UPDATE. */ String DEPARTMENT_UPDATE = "/cgi-bin/department/update"; /** * The constant DEPARTMENT_GET. */ String DEPARTMENT_GET = "/cgi-bin/department/get?id=%d"; /** * The constant DEPARTMENT_DELETE. */ String DEPARTMENT_DELETE = "/cgi-bin/department/delete?id=%d"; /** * The constant DEPARTMENT_LIST. */ String DEPARTMENT_LIST = "/cgi-bin/department/list"; /** * The constant DEPARTMENT_SIMPLE_LIST. */ String DEPARTMENT_SIMPLE_LIST = "/cgi-bin/department/simplelist"; } /** * The interface Media. */ interface Media { /** * The constant MEDIA_GET. */ String MEDIA_GET = "/cgi-bin/media/get"; /** * The constant MEDIA_UPLOAD. */ String MEDIA_UPLOAD = "/cgi-bin/media/upload?type="; /** * The constant IMG_UPLOAD. */ String IMG_UPLOAD = "/cgi-bin/media/uploadimg"; /** * The constant JSSDK_MEDIA_GET. */ String JSSDK_MEDIA_GET = "/cgi-bin/media/get/jssdk"; /** The constant GET_UPLOAD_BY_URL_RESULT. */ String GET_UPLOAD_BY_URL_RESULT = "/cgi-bin/media/get_upload_by_url_result"; /** The constant UPLOAD_BY_URL. */ String UPLOAD_BY_URL = "/cgi-bin/media/upload_by_url"; } /** * The interface Menu. */ interface Menu { /** * The constant MENU_CREATE. */ String MENU_CREATE = "/cgi-bin/menu/create?agentid=%d"; /** * The constant MENU_DELETE. */ String MENU_DELETE = "/cgi-bin/menu/delete?agentid=%d"; /** * The constant MENU_GET. */ String MENU_GET = "/cgi-bin/menu/get?agentid=%d"; } /** * The interface Oa. */ interface Oa { /** * 打卡 * https://developer.work.weixin.qq.com/document/path/94204 */ String GET_CORP_CHECKIN_OPTION = "/cgi-bin/checkin/getcorpcheckinoption"; /** * The constant GET_CHECKIN_DATA. */ String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata"; /** * The constant GET_CHECKIN_OPTION. */ String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption"; /** * The constant GET_CHECKIN_DAY_DATA. */ String GET_CHECKIN_DAY_DATA = "/cgi-bin/checkin/getcheckin_daydata"; /** * The constant GET_CHECKIN_MONTH_DATA. */ String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata"; /** * The constant GET_CHECKIN_SCHEDULE_DATA. */ String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist"; /** * The constant SET_CHECKIN_SCHEDULE_DATA. */ String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist"; /** * The constant ADD_CHECK_IN_USER_FACE. */ String ADD_CHECK_IN_USER_FACE = "/cgi-bin/checkin/addcheckinuserface"; /** * 审批 * https://developer.work.weixin.qq.com/document/path/91956 */ String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate"; /** * The constant GET_TEMPLATE_DETAIL. */ String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail"; /** * The constant CREATE_TEMPLATE. */ String CREATE_TEMPLATE = "/cgi-bin/oa/approval/create_template"; /** * The constant CREATE_TEMPLATE. */ String UPDATE_TEMPLATE = "/cgi-bin/oa/approval/update_template"; /** * The constant APPLY_EVENT. */ String APPLY_EVENT = "/cgi-bin/oa/applyevent"; /** * The constant GET_APPROVAL_INFO. */ String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo"; /** * The constant GET_APPROVAL_DETAIL. */ String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail"; /** * The constant GET_APPROVAL_DATA. */ String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata"; /** * The constant GET_CORP_CONF. */ String GET_CORP_CONF = "/cgi-bin/oa/vacation/getcorpconf"; /** * The constant GET_USER_VACATION_QUOTA. */ String GET_USER_VACATION_QUOTA = "/cgi-bin/oa/vacation/getuservacationquota"; /** * The constant SET_ONE_USER_QUOTA. */ String SET_ONE_USER_QUOTA = "/cgi-bin/oa/vacation/setoneuserquota"; /** * 公费电话 * https://developer.work.weixin.qq.com/document/path/93662 */ String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; /** * 日程 * https://developer.work.weixin.qq.com/document/path/93624 */ String CALENDAR_ADD = "/cgi-bin/oa/calendar/add"; /** * The constant CALENDAR_UPDATE. */ String CALENDAR_UPDATE = "/cgi-bin/oa/calendar/update"; /** * The constant CALENDAR_GET. */ String CALENDAR_GET = "/cgi-bin/oa/calendar/get"; /** * The constant CALENDAR_DEL. */ String CALENDAR_DEL = "/cgi-bin/oa/calendar/del"; /** * The constant SCHEDULE_ADD. */ String SCHEDULE_ADD = "/cgi-bin/oa/schedule/add"; /** * The constant SCHEDULE_UPDATE. */ String SCHEDULE_UPDATE = "/cgi-bin/oa/schedule/update"; /** * The constant SCHEDULE_GET. */ String SCHEDULE_GET = "/cgi-bin/oa/schedule/get"; /** * The constant SCHEDULE_DEL. */ String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del"; /** * The constant SCHEDULE_LIST. */ String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar"; /** * 会议 * https://developer.work.weixin.qq.com/document/path/93626 */ String MEETING_ADD = "/cgi-bin/meeting/create"; /** * The constant MEETING_UPDATE. */ String MEETING_UPDATE = "/cgi-bin/meeting/update"; /** * The constant MEETING_CANCEL. */ String MEETING_CANCEL = "/cgi-bin/meeting/cancel"; /** * The constant MEETING_DETAIL. */ String MEETING_DETAIL = "/cgi-bin/meeting/get_info"; /** * The constant GET_USER_MEETING_ID. */ String GET_USER_MEETING_ID = "/cgi-bin/meeting/get_user_meetingid"; /** * 会议室 * https://developer.work.weixin.qq.com/document/path/93624 */ String MEETINGROOM_ADD = "/cgi-bin/oa/meetingroom/add"; /** * The constant MEETINGROOM_LIST. */ String MEETINGROOM_LIST = "/cgi-bin/oa/meetingroom/list"; /** * The constant MEETINGROOM_EDIT. */ String MEETINGROOM_EDIT = "/cgi-bin/oa/meetingroom/edit"; /** * The constant MEETINGROOM_DEL. */ String MEETINGROOM_DEL = "/cgi-bin/oa/meetingroom/del"; /** * The constant MEETINGROOM_GET_BOOKING_INFO. */ String MEETINGROOM_GET_BOOKING_INFO = "/cgi-bin/oa/meetingroom/get_booking_info"; /** * The constant MEETINGROOM_BOOK. */ String MEETINGROOM_BOOK = "/cgi-bin/oa/meetingroom/book"; /** * The constant MEETINGROOM_BOOK_BY_SCHEDULE. */ String MEETINGROOM_BOOK_BY_SCHEDULE = "/cgi-bin/oa/meetingroom/book_by_schedule"; /** * The constant MEETINGROOM_BOOK_BY_MEETING. */ String MEETINGROOM_BOOK_BY_MEETING = "/cgi-bin/oa/meetingroom//book_by_meeting"; /** * The constant MEETINGROOM_CANCEL_BOOK. */ String MEETINGROOM_CANCEL_BOOK = "/cgi-bin/oa/meetingroom/cancel_book"; /** * The constant MEETINGROOM_BOOKINFO_GET. */ String MEETINGROOM_BOOKINFO_GET = "/cgi-bin/oa/meetingroom/bookinfo/get"; /** * 微盘 * https://developer.work.weixin.qq.com/document/path/93654 */ String SPACE_CREATE = "/cgi-bin/wedrive/space_create"; /** * The constant SPACE_RENAME. */ String SPACE_RENAME = "/cgi-bin/wedrive/space_rename"; /** * The constant SPACE_DISMISS. */ String SPACE_DISMISS = "/cgi-bin/wedrive/space_dismiss"; /** * The constant SPACE_INFO. */ String SPACE_INFO = "/cgi-bin/wedrive/space_info"; /** * The constant SPACE_ACL_ADD. */ String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add"; /** * The constant SPACE_ACL_DEL. */ String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del"; /** * The constant SPACE_SETTING. */ String SPACE_SETTING = "/cgi-bin/wedrive/space_setting"; /** * The constant SPACE_SHARE. */ String SPACE_SHARE = "/cgi-bin/wedrive/space_share"; /** * The constant FILE_LIST. */ String FILE_LIST = "/cgi-bin/wedrive/file_list"; /** * The constant FILE_UPLOAD. */ String FILE_UPLOAD = "/cgi-bin/wedrive/file_upload"; /** * The constant FILE_DOWNLOAD. */ String FILE_DOWNLOAD = "/cgi-bin/wedrive/file_download"; /** * The constant FILE_RENAME. */ String FILE_RENAME = "/cgi-bin/wedrive/file_rename"; /** * The constant FILE_CREATE. */ String FILE_CREATE = "/cgi-bin/wedrive/file_create"; /** * The constant FILE_MOVE. */ String FILE_MOVE = "/cgi-bin/wedrive/file_move"; /** * The constant FILE_DELETE. */ String FILE_DELETE = "/cgi-bin/wedrive/file_delete"; /** * The constant FILE_INFO. */ String FILE_INFO = "/cgi-bin/wedrive/file_info"; /** * The constant FILE_ACL_ADD. */ String FILE_ACL_ADD = "/cgi-bin/wedrive/file_acl_add"; /** * The constant FILE_ACL_DEL. */ String FILE_ACL_DEL = "/cgi-bin/wedrive/file_acl_del"; /** * The constant FILE_SETTING. */ String FILE_SETTING = "/cgi-bin/wedrive/file_setting"; /** * The constant FILE_SHARE. */ String FILE_SHARE = "/cgi-bin/wedrive/file_share"; /** * 审批流程引擎 * https://developer.work.weixin.qq.com/document/path/90269 */ String GET_OPEN_APPROVAL_DATA = "/cgi-bin/corp/getopenapprovaldata"; /** * 文档 * https://developer.work.weixin.qq.com/document/path/97392 */ /** * The constant WEDOC_CREATE_DOC. */ String WEDOC_CREATE_DOC = "/cgi-bin/wedoc/create_doc"; /** * The constant WEDOC_RENAME_DOC. */ String WEDOC_RENAME_DOC = "/cgi-bin/wedoc/rename_doc"; /** * The constant WEDOC_DEL_DOC. */ String WEDOC_DEL_DOC = "/cgi-bin/wedoc/del_doc"; /** * The constant WEDOC_GET_DOC_BASE_INFO. */ String WEDOC_GET_DOC_BASE_INFO = "/cgi-bin/wedoc/get_doc_base_info"; /** * The constant WEDOC_DOC_SHARE. */ String WEDOC_DOC_SHARE = "/cgi-bin/wedoc/doc_share"; /** * 邮件 * https://developer.work.weixin.qq.com/document/path/95486 */ /** * The constant EXMAIL_APP_COMPOSE_SEND. */ String EXMAIL_APP_COMPOSE_SEND = "/cgi-bin/exmail/app/compose_send"; } /** * The interface School. */ interface School { /** * The constant GET_HEALTH_REPORT_STAT. */ String GET_HEALTH_REPORT_STAT = "/cgi-bin/health/get_health_report_stat"; /** * The constant GET_REPORT_JOBIDS. */ String GET_REPORT_JOBIDS = "/cgi-bin/health/get_report_jobids"; /** * The constant GET_REPORT_JOB_INFO. */ String GET_REPORT_JOB_INFO = "/cgi-bin/health/get_report_job_info"; /** * The constant GET_REPORT_ANSWER. */ String GET_REPORT_ANSWER = "/cgi-bin/health/get_report_answer"; /** * The constant GET_TEACHER_CUSTOMIZE_HEALTH_INFO. */ String GET_TEACHER_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_teacher_customize_health_info"; /** * The constant GET_STUDENT_CUSTOMIZE_HEALTH_INFO. */ String GET_STUDENT_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_student_customize_health_info"; /** * The constant GET_HEALTH_QRCODE. */ String GET_HEALTH_QRCODE = "/cgi-bin/school/user/get_health_qrcode"; /** * The constant BATCH_CREATE_STUDENT. */ String BATCH_CREATE_STUDENT = "/cgi-bin/school/user/batch_create_student"; /** * The constant BATCH_DELETE_STUDENT. */ String BATCH_DELETE_STUDENT = "/cgi-bin/school/user/batch_delete_student"; /** * The constant BATCH_UPDATE_STUDENT. */ String BATCH_UPDATE_STUDENT = "/cgi-bin/school/user/batch_update_student"; /** * The constant BATCH_CREATE_PARENT. */ String BATCH_CREATE_PARENT = "/cgi-bin/school/user/batch_create_parent"; /** * The constant BATCH_DELETE_PARENT. */ String BATCH_DELETE_PARENT = "/cgi-bin/school/user/batch_delete_parent"; /** * The constant BATCH_UPDATE_PARENT. */ String BATCH_UPDATE_PARENT = "/cgi-bin/school/user/batch_update_parent"; /** * The constant CREATE_STUDENT. */ String CREATE_STUDENT = "/cgi-bin/school/user/create_student"; /** * The constant DELETE_STUDENT. */ String DELETE_STUDENT = "/cgi-bin/school/user/delete_student?userid="; /** * The constant UPDATE_STUDENT. */ String UPDATE_STUDENT = "/cgi-bin/school/user/update_student"; /** * The constant CREATE_PARENT. */ String CREATE_PARENT = "/cgi-bin/school/user/create_parent"; /** * The constant UPDATE_PARENT. */ String UPDATE_PARENT = "/cgi-bin/school/user/update_parent"; /** * The constant DELETE_PARENT. */ String DELETE_PARENT = "/cgi-bin/school/user/delete_parent?userid="; /** * The constant GET_USER. */ String GET_USER = "/cgi-bin/school/user/get?userid="; /** * The constant GET_USER_LIST. */ String GET_USER_LIST = "/cgi-bin/school/user/list?department_id=%s&fetch_child=%d"; /** * The constant GET_USER_LIST_PARENT. */ String GET_USER_LIST_PARENT = "/cgi-bin/school/user/list_parent?department_id="; /** * The constant SET_ARCH_SYNC_MODE. */ String SET_ARCH_SYNC_MODE = "/cgi-bin/school/set_arch_sync_mode"; /** * The constant SET_UPGRADE_INFO. */ String SET_UPGRADE_INFO = "/cgi-bin/school/set_upgrade_info"; /** * The constant DEPARTMENT_CREATE. */ String DEPARTMENT_CREATE = "/cgi-bin/school/department/create"; /** * The constant DEPARTMENT_UPDATE. */ String DEPARTMENT_UPDATE = "/cgi-bin/school/department/update"; /** * The constant DEPARTMENT_DELETE. */ String DEPARTMENT_DELETE = "/cgi-bin/school/department/delete?id="; /** * The constant DEPARTMENT_LIST. */ String DEPARTMENT_LIST = "/cgi-bin/school/department/list"; /** * The constant GET_PAYMENT_RESULT. */ String GET_PAYMENT_RESULT = "/cgi-bin/school/get_payment_result"; /** * The constant GET_TRADE. */ String GET_TRADE = "/cgi-bin/school/get_trade"; /** * The constant GET_ALLOW_SCOPE. */ String GET_ALLOW_SCOPE = "/cgi-bin/school/agent/get_allow_scope?agentid="; /** * 上课直播 */ String GET_LIVING_INFO = "/cgi-bin/school/living/get_living_info?livingid="; /** * The constant GET_WATCH_STAT. */ String GET_WATCH_STAT = "/cgi-bin/school/living/get_watch_stat"; /** * The constant GET_UNWATCH_STAT. */ String GET_UNWATCH_STAT = "/cgi-bin/school/living/get_unwatch_stat"; } /** * The interface Living. */ interface Living { /** * The constant GET_LIVING_CODE. */ String GET_LIVING_CODE = "/cgi-bin/living/get_living_code"; /** * The constant GET_LIVING_INFO. */ String GET_LIVING_INFO = "/cgi-bin/living/get_living_info?livingid="; /** * The constant GET_WATCH_STAT. */ String GET_WATCH_STAT = "/cgi-bin/living/get_watch_stat"; /** * The constant GET_LIVING_SHARE_INFO. */ String GET_LIVING_SHARE_INFO = "/cgi-bin/living/get_living_share_info"; /** * The constant GET_USER_ALL_LIVINGID. */ String GET_USER_ALL_LIVINGID = "/cgi-bin/living/get_user_all_livingid"; /** * The constant CREATE. */ String CREATE = "/cgi-bin/living/create"; /** * The constant MODIFY. */ String MODIFY = "/cgi-bin/living/modify"; /** * The constant CANCEL. */ String CANCEL = "/cgi-bin/living/cancel"; /** * The constant DELETE_REPLAY_DATA. */ String DELETE_REPLAY_DATA = "/cgi-bin/living/delete_replay_data"; } /** * The interface Msg audit. */ interface MsgAudit { /** * The constant GET_PERMIT_USER_LIST. */ String GET_PERMIT_USER_LIST = "/cgi-bin/msgaudit/get_permit_user_list"; /** * The constant GET_GROUP_CHAT. */ String GET_GROUP_CHAT = "/cgi-bin/msgaudit/groupchat/get"; /** * The constant CHECK_SINGLE_AGREE. */ String CHECK_SINGLE_AGREE = "/cgi-bin/msgaudit/check_single_agree"; } /** * The interface Tag. */ interface Tag { /** * The constant TAG_CREATE. */ String TAG_CREATE = "/cgi-bin/tag/create"; /** * The constant TAG_UPDATE. */ String TAG_UPDATE = "/cgi-bin/tag/update"; /** * The constant TAG_DELETE. */ String TAG_DELETE = "/cgi-bin/tag/delete?tagid=%s"; /** * The constant TAG_LIST. */ String TAG_LIST = "/cgi-bin/tag/list"; /** * The constant TAG_GET. */ String TAG_GET = "/cgi-bin/tag/get?tagid=%s"; /** * The constant TAG_ADD_TAG_USERS. */ String TAG_ADD_TAG_USERS = "/cgi-bin/tag/addtagusers"; /** * The constant TAG_DEL_TAG_USERS. */ String TAG_DEL_TAG_USERS = "/cgi-bin/tag/deltagusers"; } /** * The interface Task card. */ interface TaskCard { /** * The constant UPDATE_TASK_CARD. */ String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard"; /** * The constant UPDATE_TEMPLATE_CARD. */ String UPDATE_TEMPLATE_CARD = "/cgi-bin/message/update_template_card"; } /** * The interface Tp. */ interface Tp { /** * The constant JSCODE_TO_SESSION. */ String JSCODE_TO_SESSION = "/cgi-bin/service/miniprogram/jscode2session"; /** * The constant GET_CORP_TOKEN. */ String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token"; /** * The constant GET_PERMANENT_CODE. */ String GET_PERMANENT_CODE = "/cgi-bin/service/get_permanent_code"; /** * The constant GET_V2_PERMANENT_CODE. */ String GET_V2_PERMANENT_CODE = "/cgi-bin/service/v2/get_permanent_code"; /** * The constant GET_SUITE_TOKEN. */ String GET_SUITE_TOKEN = "/cgi-bin/service/get_suite_token"; /** * The constant GET_PROVIDER_TOKEN. */ String GET_PROVIDER_TOKEN = "/cgi-bin/service/get_provider_token"; /** * The constant GET_PREAUTH_CODE. */ String GET_PREAUTH_CODE = "/cgi-bin/service/get_pre_auth_code"; /** * The constant GET_AUTH_INFO. */ String GET_AUTH_INFO = "/cgi-bin/service/get_auth_info"; /** * The constant GET_AUTH_CORP_JSAPI_TICKET. */ String GET_AUTH_CORP_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket"; /** * The constant GET_SUITE_JSAPI_TICKET. */ String GET_SUITE_JSAPI_TICKET = "/cgi-bin/ticket/get"; /** * The constant GET_USERINFO3RD. */ String GET_USERINFO3RD = "/cgi-bin/service/auth/getuserinfo3rd"; /** * The constant GET_USERDETAIL3RD. */ String GET_USERDETAIL3RD = "/cgi-bin/service/auth/getuserdetail3rd"; /** * The constant GET_LOGIN_INFO. */ String GET_LOGIN_INFO = "/cgi-bin/service/get_login_info"; /** * The constant GET_CUSTOMIZED_AUTH_URL. */ String GET_CUSTOMIZED_AUTH_URL = "/cgi-bin/service/get_customized_auth_url"; /** * The constant CONTACT_SEARCH. */ String CONTACT_SEARCH = "/cgi-bin/service/contact/search"; /** * The constant GET_ADMIN_LIST. */ String GET_ADMIN_LIST = "/cgi-bin/service/get_admin_list"; /** * The constant GET_APP_QRCODE. */ String GET_APP_QRCODE = "/cgi-bin/service/get_app_qrcode"; /** * The constant CORPID_TO_OPENCORPID. */ String CORPID_TO_OPENCORPID = "/cgi-bin/service/corpid_to_opencorpid"; /** * The constant GET_ORDER. */ // 获取订单详情 String GET_ORDER = "/cgi-bin/service/get_order"; /** * The constant GET_ORDER_LIST. */ // 获取订单列表 String GET_ORDER_LIST = "/cgi-bin/service/get_order_list"; /** * The constant PROLONG_TRY. */ // 延长试用期 String PROLONG_TRY = "/cgi-bin/service/prolong_try"; } /** * The interface License. */ interface License { /** * The constant CREATE_NEW_ORDER. */ String CREATE_NEW_ORDER = "/cgi-bin/license/create_new_order"; /** * The constant CREATE_RENEW_ORDER_JOB. */ String CREATE_RENEW_ORDER_JOB = "/cgi-bin/license/create_renew_order_job"; /** * The constant SUBMIT_ORDER_JOB. */ String SUBMIT_ORDER_JOB = "/cgi-bin/license/submit_order_job"; /** * The constant LIST_ORDER. */ String LIST_ORDER = "/cgi-bin/license/list_order"; /** * The constant GET_ORDER. */ String GET_ORDER = "/cgi-bin/license/get_order"; /** * The constant LIST_ORDER_ACCOUNT. */ String LIST_ORDER_ACCOUNT = "/cgi-bin/license/list_order_account"; /** * The constant ACTIVE_ACCOUNT. */ String ACTIVE_ACCOUNT = "/cgi-bin/license/active_account"; /** * The constant BATCH_ACTIVE_ACCOUNT. */ String BATCH_ACTIVE_ACCOUNT = "/cgi-bin/license/batch_active_account"; /** * The constant GET_ACTIVE_INFO_BY_CODE. */ String GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/get_active_info_by_code"; /** * The constant BATCH_GET_ACTIVE_INFO_BY_CODE. */ String BATCH_GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/batch_get_active_info_by_code"; /** * The constant LIST_ACTIVED_ACCOUNT. */ String LIST_ACTIVED_ACCOUNT = "/cgi-bin/license/list_actived_account"; /** * The constant GET_ACTIVE_INFO_BY_USER. */ String GET_ACTIVE_INFO_BY_USER = "/cgi-bin/license/get_active_info_by_user"; /** * The constant BATCH_TRANSFER_LICENSE. */ String BATCH_TRANSFER_LICENSE = "/cgi-bin/license/batch_transfer_license"; } /** * The interface User. */ interface User { /** * The constant USER_AUTHENTICATE. */ String USER_AUTHENTICATE = "/cgi-bin/user/authsucc?userid="; /** * The constant USER_CREATE. */ String USER_CREATE = "/cgi-bin/user/create"; /** * The constant USER_UPDATE. */ String USER_UPDATE = "/cgi-bin/user/update"; /** * The constant USER_DELETE. */ String USER_DELETE = "/cgi-bin/user/delete?userid="; /** * The constant USER_BATCH_DELETE. */ String USER_BATCH_DELETE = "/cgi-bin/user/batchdelete"; /** * The constant USER_GET. */ String USER_GET = "/cgi-bin/user/get?userid="; /** * The constant USER_LIST. */ String USER_LIST = "/cgi-bin/user/list?department_id="; /** * The constant USER_SIMPLE_LIST. */ String USER_SIMPLE_LIST = "/cgi-bin/user/simplelist?department_id="; /** * The constant BATCH_INVITE. */ String BATCH_INVITE = "/cgi-bin/batch/invite"; /** * The constant USER_CONVERT_TO_OPENID. */ String USER_CONVERT_TO_OPENID = "/cgi-bin/user/convert_to_openid"; /** * The constant USER_CONVERT_TO_USERID. */ String USER_CONVERT_TO_USERID = "/cgi-bin/user/convert_to_userid"; /** * The constant GET_USER_ID. */ String GET_USER_ID = "/cgi-bin/user/getuserid"; /** * The constant GET_USER_ID_BY_EMAIL. */ String GET_USER_ID_BY_EMAIL = "/cgi-bin/user/get_userid_by_email"; /** * The constant GET_EXTERNAL_CONTACT. */ String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid="; /** * The constant GET_JOIN_QR_CODE. */ String GET_JOIN_QR_CODE = "/cgi-bin/corp/get_join_qrcode?size_type="; /** * The constant GET_ACTIVE_STAT. */ String GET_ACTIVE_STAT = "/cgi-bin/user/get_active_stat"; /** * The constant USERID_TO_OPEN_USERID. */ String USERID_TO_OPEN_USERID = "/cgi-bin/batch/userid_to_openuserid"; /** * The constant OPEN_USERID_TO_USERID. */ String OPEN_USERID_TO_USERID = "/cgi-bin/batch/openuserid_to_userid"; /** * The constant USER_LIST_ID. */ String USER_LIST_ID = "/cgi-bin/user/list_id"; } /** * The interface External contact. */ interface ExternalContact { /** * The constant GET_EXTERNAL_CONTACT. */ @Deprecated String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid="; /** * The constant ADD_CONTACT_WAY. */ String ADD_CONTACT_WAY = "/cgi-bin/externalcontact/add_contact_way"; /** * The constant GET_CONTACT_WAY. */ String GET_CONTACT_WAY = "/cgi-bin/externalcontact/get_contact_way"; /** * The constant LIST_CONTACT_WAY. */ String LIST_CONTACT_WAY = "/cgi-bin/externalcontact/list_contact_way"; /** * The constant UPDATE_CONTACT_WAY. */ String UPDATE_CONTACT_WAY = "/cgi-bin/externalcontact/update_contact_way"; /** * The constant DEL_CONTACT_WAY. */ String DEL_CONTACT_WAY = "/cgi-bin/externalcontact/del_contact_way"; /** * The constant CLOSE_TEMP_CHAT. */ String CLOSE_TEMP_CHAT = "/cgi-bin/externalcontact/close_temp_chat"; /** * The constant GET_FOLLOW_USER_LIST. */ String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list"; /** * The constant GET_CONTACT_DETAIL. */ String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid="; /** * The constant CONVERT_TO_OPENID. */ String CONVERT_TO_OPENID = "/cgi-bin/externalcontact/convert_to_openid"; /** * The constant UNIONID_TO_EXTERNAL_USERID. */ String UNIONID_TO_EXTERNAL_USERID = "/cgi-bin/externalcontact/unionid_to_external_userid"; /** * The constant UNIONID_TO_EXTERNAL_USERID_3RD. */ String UNIONID_TO_EXTERNAL_USERID_3RD = "/cgi-bin/service/externalcontact/unionid_to_external_userid_3rd"; /** * The constant GET_NEW_EXTERNAL_USERID. */ String GET_NEW_EXTERNAL_USERID = "/cgi-bin/externalcontact/get_new_external_userid"; /** * The constant TO_SERVICE_EXTERNAL_USERID. */ String TO_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/to_service_external_userid"; /** * The constant FROM_SERVICE_EXTERNAL_USERID. */ String FROM_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/from_service_external_userid"; /** * The constant FINISH_EXTERNAL_USERID_MIGRATION. */ String FINISH_EXTERNAL_USERID_MIGRATION = "/cgi-bin/externalcontact/finish_external_userid_migration"; /** * The constant GET_CONTACT_DETAIL_BATCH. */ String GET_CONTACT_DETAIL_BATCH = "/cgi-bin/externalcontact/batch/get_by_user?"; String GET_CONTACT_LIST = "/cgi-bin/externalcontact/contact_list?"; /** * The constant UPDATE_REMARK. */ String UPDATE_REMARK = "/cgi-bin/externalcontact/remark"; /** * The constant LIST_EXTERNAL_CONTACT. */ String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid="; /** * The constant LIST_UNASSIGNED_CONTACT. */ String LIST_UNASSIGNED_CONTACT = "/cgi-bin/externalcontact/get_unassigned_list"; /** * The constant TRANSFER_UNASSIGNED_CONTACT. */ @Deprecated String TRANSFER_UNASSIGNED_CONTACT = "/cgi-bin/externalcontact/transfer"; /** * The constant TRANSFER_CUSTOMER. */ String TRANSFER_CUSTOMER = "/cgi-bin/externalcontact/transfer_customer"; /**
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
true
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java
package me.chanjar.weixin.cp.constant; import lombok.experimental.UtilityClass; /** * The type Wx cp tp consts. */ public class WxCpTpConsts { /** * The type Info type. */ @UtilityClass public static class InfoType { /** * 推送更新suite_ticket */ public static final String SUITE_TICKET = "suite_ticket"; /** * 从企业微信应用市场发起授权时,授权成功通知 */ public static final String CREATE_AUTH = "create_auth"; /** * 从企业微信应用市场发起授权时,变更授权通知 */ public static final String CHANGE_AUTH = "change_auth"; /** * 从企业微信应用市场发起授权时,取消授权通知 */ public static final String CANCEL_AUTH = "cancel_auth"; /** * 企业互联共享应用事件回调 */ public static final String SHARE_AGENT_CHANGE = "share_agent_change"; /** * 重置永久授权码通知 */ public static final String RESET_PERMANENT_CODE = "reset_permanent_code"; /** * 应用管理员变更通知 */ public static final String CHANGE_APP_ADMIN = "change_app_admin"; /** * 通讯录变更通知 */ public static final String CHANGE_CONTACT = "change_contact"; /** * 用户进行企业微信的注册,注册完成回调通知 */ public static final String REGISTER_CORP = "register_corp"; /** * 异步任务回调通知 */ public static final String BATCH_JOB_RESULT = "batch_job_result"; /** * 外部联系人变更通知 */ public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact"; /** * 下单成功通知 */ public static final String OPEN_ORDER = "open_order"; /** * 改单通知 */ public static final String CHANGE_ORDER = "change_order"; /** * 支付成功通知 */ public static final String PAY_FOR_APP_SUCCESS = "pay_for_app_success"; /** * 退款通知 */ public static final String REFUND = "refund"; /** * 付费版本变更通知 */ public static final String CHANGE_EDITION = "change_editon"; /** * 接口许可失效通知 */ public static final String UNLICENSED_NOTIFY = "unlicensed_notify"; /** * 支付成功通知 */ public static final String LICENSE_PAY_SUCCESS = "license_pay_success"; /** * 退款结果通知 */ public static final String LICENSE_REFUND = "license_refund"; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java
package me.chanjar.weixin.cp.constant; import lombok.experimental.UtilityClass; /** * <pre> * 企业微信常量 * Created by Binary Wang on 2018/8/25. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @UtilityClass public class WxCpConsts { /** * 企业微信端推送过来的事件类型. * 参考文档:https://work.weixin.qq.com/api/doc#12974 */ @UtilityClass public static class EventType { /** * 成员关注事件. */ public static final String SUBSCRIBE = "subscribe"; /** * 成员取消关注事件. */ public static final String UNSUBSCRIBE = "unsubscribe"; /** * 进入应用事件. */ public static final String ENTER_AGENT = "enter_agent"; /** * 上报地理位置. */ public static final String LOCATION = "LOCATION"; /** * 异步任务完成事件推送. */ public static final String BATCH_JOB_RESULT = "batch_job_result"; /** * 企业微信通讯录变更事件. */ public static final String CHANGE_CONTACT = "change_contact"; /** * 企业微信模板卡片事件推送 */ public static final String TEMPLATE_CARD_EVENT = "template_card_event"; /** * 点击菜单拉取消息的事件推送. */ public static final String CLICK = "click"; /** * 点击菜单跳转链接的事件推送. */ public static final String VIEW = "view"; /** * 扫码推事件的事件推送. */ public static final String SCANCODE_PUSH = "scancode_push"; /** * 扫码推事件且弹出“消息接收中”提示框的事件推送. */ public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; /** * 弹出系统拍照发图的事件推送. */ public static final String PIC_SYSPHOTO = "pic_sysphoto"; /** * 弹出拍照或者相册发图的事件推送. */ public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; /** * 弹出微信相册发图器的事件推送. */ public static final String PIC_WEIXIN = "pic_weixin"; /** * 弹出地理位置选择器的事件推送. */ public static final String LOCATION_SELECT = "location_select"; /** * 任务卡片事件推送. */ public static final String TASKCARD_CLICK = "taskcard_click"; /** * 企业互联共享应用事件回调. */ public static final String SHARE_AGENT_CHANGE = "share_agent_change"; /** * 上下游共享应用事件回调. */ public static final String SHARE_CHAIN_CHANGE = "share_chain_change"; /** * 通用模板卡片右上角菜单事件推送. */ public static final String TEMPLATE_CARD_MENU_EVENT = "template_card_menu_event"; /** * 长期未使用应用临时停用事件. */ public static final String CLOSE_INACTIVE_AGENT = "close_inactive_agent"; /** * 长期未使用应用重新启用事件. */ public static final String REOPEN_INACTIVE_AGENT = "reopen_inactive_agent"; /** * 企业成员添加外部联系人事件推送 & 会话存档客户同意进行聊天内容存档事件回调事件 */ public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact"; /** * 客户群事件推送 */ public static final String CHANGE_EXTERNAL_CHAT = "change_external_chat"; /** * 企业客户标签事件推送 */ public static final String CHANGE_EXTERNAL_TAG = "change_external_tag"; /** * 企业微信审批事件推送(自建应用审批) * https://developer.work.weixin.qq.com/document/path/90269 */ public static final String OPEN_APPROVAL_CHANGE = "open_approval_change"; /** * 企业微信审批事件推送(系统审批) */ public static final String SYS_APPROVAL_CHANGE = "sys_approval_change"; /** * 修改日历事件 */ public static final String MODIFY_CALENDAR = "modify_calendar"; /** * 删除日历事件 */ public static final String DELETE_CALENDAR = "delete_calendar"; /** * 添加日程事件 */ public static final String ADD_SCHEDULE = "add_schedule"; /** * 修改日程事件 */ public static final String MODIFY_SCHEDULE = "modify_schedule"; /** * 删除日程事件 */ public static final String DELETE_SCHEDULE = "delete_schedule"; /** * 日程回执事件 */ public static final String RESPOND_SCHEDULE = "respond_schedule"; /** * 会议室预定事件. */ public static final String BOOK_MEETING_ROOM = "book_meeting_room"; /** * 会议室取消事件. */ public static final String CANCEL_MEETING_ROOM = "cancel_meeting_room"; /** * 家校通讯录事件 */ public static final String CHANGE_SCHOOL_CONTACT = "change_school_contact"; /** * 产生会话回调事件 */ public static final String MSGAUDIT_NOTIFY = "msgaudit_notify"; /** * 直播回调事件 */ public static final String LIVING_STATUS_CHANGE = "living_status_change"; /** * 微信客服消息事件 */ public static final String KF_MSG_OR_EVENT = "kf_msg_or_event"; /** * 客服账号授权变更事件 */ public static final String KF_ACCOUNT_AUTH_CHANGE = "kf_account_auth_change"; /** * 获客助手事件通知 */ public static final String CUSTOMER_ACQUISITION = "customer_acquisition"; /** * <a href="https://developer.work.weixin.qq.com/document/path/96488#%E5%9B%9E%E8%B0%83%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9E%9C">异步上传临时素材结果回调通知</a> */ public static final String UPLOAD_MEDIA_JOB_FINISH = "upload_media_job_finish"; } /** * 获客助手事件通知CHANGE_TYPE * https://developer.work.weixin.qq.com/document/path/97299 */ @UtilityClass public static class CustomerAcquisitionChangeType { /** * 获客额度即将耗尽事件 */ public static final String BALANCE_LOW = "balance_low"; /** * 使用量已经耗尽事件 */ public static final String BALANCE_EXHAUSTED = "balance_exhausted"; /** * 获客链接不可用事件 */ public static final String LINK_UNAVAILABLE = "link_unavailable"; /** * 微信客户发起会话事件 */ public static final String CUSTOMER_START_CHAT = "customer_start_chat"; /** * 删除获客链接事件 */ public static final String DELETE_LINK = "delete_link"; /** * 通过获客链接申请好友事件 */ public static final String friend_request = "friend_request"; } /** * 会话存档事件CHANGE_TYPE * https://developer.work.weixin.qq.com/document/path/92005 */ @UtilityClass public static class MsgAuditChangeType { /** * The constant MSG_AUDIT_APPROVED. */ public static final String MSG_AUDIT_APPROVED = "msg_audit_approved"; } /** * 会话存档媒体类型 * https://developer.work.weixin.qq.com/document/path/91774 */ @UtilityClass public static class MsgAuditMediaType { /** * 图片 */ public static final String IMAGE = "image"; /** * 语音 */ public static final String VOICE = "voice"; /** * 视频 */ public static final String VIDEO = "video"; /** * 表情 */ public static final String EMOTION = "emotion"; /** * 文件 */ public static final String FILE = "file"; /** * 音频存档消息 */ public static final String MEETING_VOICE_CALL = "meeting_voice_call"; /** * 音频共享文档消息 */ public static final String VOIP_DOC_SHARE = "voip_doc_share"; @UtilityClass public static class MsgAuditSuffix { public static final String JPG = ".jpg"; public static final String PNG = ".png"; public static final String GIF = ".gif"; public static final String MP4 = ".mp4"; public static final String AMR = ".amr"; } } /** * 家校通讯录变更事件CHANGE_TYPE */ @UtilityClass public static class SchoolContactChangeType { /** * 部门变更事件 * https://developer.work.weixin.qq.com/document/path/92052 */ public static final String CREATE_DEPARTMENT = "create_department"; /** * The constant UPDATE_DEPARTMENT. */ public static final String UPDATE_DEPARTMENT = "update_department"; /** * The constant DELETE_DEPARTMENT. */ public static final String DELETE_DEPARTMENT = "delete_department"; /** * 成员变更事件 * https://developer.work.weixin.qq.com/document/path/92032 */ public static final String CREATE_STUDENT = "create_student"; /** * The constant UPDATE_STUDENT. */ public static final String UPDATE_STUDENT = "update_student"; /** * The constant DELETE_STUDENT. */ public static final String DELETE_STUDENT = "delete_student"; /** * The constant CREATE_PARENT. */ public static final String CREATE_PARENT = "create_parent"; /** * The constant UPDATE_PARENT. */ public static final String UPDATE_PARENT = "update_parent"; /** * The constant DELETE_PARENT. */ public static final String DELETE_PARENT = "delete_parent"; /** * The constant SUBSCRIBE. */ public static final String SUBSCRIBE = "subscribe"; /** * The constant UNSUBSCRIBE. */ public static final String UNSUBSCRIBE = "unsubscribe"; } /** * 企业外部联系人变更事件的CHANGE_TYPE */ @UtilityClass public static class ExternalContactChangeType { /** * 新增外部联系人 */ public static final String ADD_EXTERNAL_CONTACT = "add_external_contact"; /** * 编辑外部联系人 */ public static final String EDIT_EXTERNAL_CONTACT = "edit_external_contact"; /** * 删除外部联系人 */ public static final String DEL_EXTERNAL_CONTACT = "del_external_contact"; /** * 外部联系人免验证添加成员事件 */ public static final String ADD_HALF_EXTERNAL_CONTACT = "add_half_external_contact"; /** * 删除跟进成员事件 */ public static final String DEL_FOLLOW_USER = "del_follow_user"; /** * 客户接替失败事件 */ public static final String TRANSFER_FAIL = "transfer_fail"; /** * The type External contact transfer fail reason. */ @UtilityClass public static class ExternalContactTransferFailReason { /** * 客户拒绝 */ public static final String CUSTOMER_REFUSED = "customer_refused"; /** * 接替成员的客户数达到上限 */ public static final String CUSTOMER_LIMIT_EXCEED = "customer_limit_exceed"; } } /** * The type External chat change type. */ @UtilityClass public static class ExternalChatChangeType { /** * 客户群变更事件 */ public static final String CREATE = "create"; /** * 客户群变更事件 */ public static final String UPDATE = "update"; /** * 客户群解散事件 */ public static final String DISMISS = "dismiss"; /** * The type External chat update detail. */ @UtilityClass public static class ExternalChatUpdateDetail { /** * 成员入群 */ public static final String ADD_MEMBER = "add_member"; /** * 成员退群 */ public static final String DEL_MEMBER = "del_member"; /** * 群主变更 */ public static final String CHANGE_OWNER = "change_owner"; /** * 群名变更 */ public static final String CHANGE_NAME = "change_name"; /** * 群公告变更 */ public static final String CHANGE_NOTICE = "change_notice"; } } /** * The type External tag change type. */ @UtilityClass public static class ExternalTagChangeType { /** * 创建企业客户标签 */ public static final String CREATE = "create"; /** * 变更企业客户标签 */ public static final String UPDATE = "update"; /** * 删除企业客户标签 */ public static final String DELETE = "delete"; /** * 重排企业客户标签 */ public static final String SHUFFLE = "shuffle"; } /** * The type Tage type. */ @UtilityClass public static class TageType { /** * 标签 */ public static final String TAG = "tag"; /** * 标签组 */ public static final String TAG_GROUP = "tag_group"; } /** * 企业微信通讯录变更事件. */ @UtilityClass public static class ContactChangeType { /** * 新增成员事件. */ public static final String CREATE_USER = "create_user"; /** * 更新成员事件. */ public static final String UPDATE_USER = "update_user"; /** * 删除成员事件. */ public static final String DELETE_USER = "delete_user"; /** * 新增部门事件. */ public static final String CREATE_PARTY = "create_party"; /** * 更新部门事件. */ public static final String UPDATE_PARTY = "update_party"; /** * 删除部门事件. */ public static final String DELETE_PARTY = "delete_party"; /** * 标签成员变更事件. */ public static final String UPDATE_TAG = "update_tag"; } /** * 互联企业发送应用消息的消息类型. */ @UtilityClass public static class LinkedCorpMsgType { /** * 文本消息. */ public static final String TEXT = "text"; /** * 图片消息. */ public static final String IMAGE = "image"; /** * 视频消息. */ public static final String VIDEO = "video"; /** * 图文消息(点击跳转到外链). */ public static final String NEWS = "news"; /** * 图文消息(点击跳转到图文消息页面). */ public static final String MPNEWS = "mpnews"; /** * markdown消息. * (目前仅支持markdown语法的子集,微工作台(原企业号)不支持展示markdown消息) */ public static final String MARKDOWN = "markdown"; /** * 发送文件. */ public static final String FILE = "file"; /** * 文本卡片消息. */ public static final String TEXTCARD = "textcard"; /** * 小程序通知消息. */ public static final String MINIPROGRAM_NOTICE = "miniprogram_notice"; } /** * 群机器人的消息类型. */ @UtilityClass public static class GroupRobotMsgType { /** * 文本消息. */ public static final String TEXT = "text"; /** * 图片消息. */ public static final String IMAGE = "image"; /** * markdown消息. */ public static final String MARKDOWN = "markdown"; /** * markdown_v2消息. */ public static final String MARKDOWN_V2 = "markdown_v2"; /** * 图文消息(点击跳转到外链). */ public static final String NEWS = "news"; /** * 文件类型消息. */ public static final String FILE = "file"; /** * 文件类型消息. */ public static final String VOICE = "voice"; /** * 模版类型消息. */ public static final String TEMPLATE_CARD = "template_card"; } /** * 应用推送消息的消息类型. */ @UtilityClass public static class AppChatMsgType { /** * 文本消息. */ public static final String TEXT = "text"; /** * 图片消息. */ public static final String IMAGE = "image"; /** * 语音消息. */ public static final String VOICE = "voice"; /** * 视频消息. */ public static final String VIDEO = "video"; /** * 发送文件(CP专用). */ public static final String FILE = "file"; /** * 文本卡片消息(CP专用). */ public static final String TEXTCARD = "textcard"; /** * 图文消息(点击跳转到外链). */ public static final String NEWS = "news"; /** * 图文消息(点击跳转到图文消息页面). */ public static final String MPNEWS = "mpnews"; /** * markdown消息. */ public static final String MARKDOWN = "markdown"; } /** * The type Work bench type. */ @UtilityClass public static class WorkBenchType { /** * The constant KEYDATA. */ /* * 关键数据型 * */ public static final String KEYDATA = "keydata"; /** * The constant IMAGE. */ /* * 图片型 * */ public static final String IMAGE = "image"; /** * The constant LIST. */ /* * 列表型 * */ public static final String LIST = "list"; /** * The constant WEBVIEW. */ /* * webview型 * */ public static final String WEBVIEW = "webview"; } /** * The type Welcome msg type. */ @UtilityClass public static class WelcomeMsgType { /** * 图片消息. */ public static final String IMAGE = "image"; /** * 图文消息. */ public static final String LINK = "link"; /** * 视频消息. */ public static final String VIDEO = "video"; /** * 小程序消息. */ public static final String MINIPROGRAM = "miniprogram"; /** * 文件消息. */ public static final String FILE = "file"; } /** * The type Product attachment type. */ @UtilityClass public static class ProductAttachmentType { /** * 图片消息. */ public static final String IMAGE = "image"; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpDepartmentService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpDepart; import java.util.List; /** * <pre> * 部门管理接口 * Created by jamie on 2020/7/22. * </pre> */ public interface WxCpTpDepartmentService { /** * <pre> * 部门管理接口 - 创建部门. * 最多支持创建500个部门 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90205">...</a> * </pre> * * @param depart 部门 * @return 部门id long * @throws WxErrorException 异常 */ Long create(WxCpTpDepart depart) throws WxErrorException; /** * <pre> * 部门管理接口 - 获取部门列表. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90208">...</a> * </pre> * * @param id 部门id。获取指定部门及其下的子部门。非必需,可为null * @param corpId the corp id * @return 获取的部门列表 list * @throws WxErrorException 异常 */ List<WxCpTpDepart> list(Long id, String corpId) throws WxErrorException; /** * <pre> * 部门管理接口 - 更新部门. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90206">...</a> * 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误 * </pre> * * @param group 要更新的group,group的id,name必须设置 * @throws WxErrorException 异常 */ void update(WxCpTpDepart group) throws WxErrorException; /** * <pre> * 部门管理接口 - 删除部门. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90207">...</a> * 应用须拥有指定部门的管理权限 * </pre> * * @param departId 部门id * @throws WxErrorException 异常 */ void delete(Long departId) throws WxErrorException; /** * <pre> * 部门管理接口 - 获取部门列表. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90208">...</a> * </pre> * * @param corpId the corp id * @return 获取所有的部门列表 list * @throws WxErrorException 异常 */ List<WxCpTpDepart> list(String corpId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.cp.bean.*; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import java.util.List; /** * 企业微信第三方应用API的Service. * * @author zhenjun cai */ public interface WxCpTpService { /** * <pre> * 验证推送过来的消息的正确性 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90139/90968/">消息体签名校验</a> * </pre> * * @param msgSignature 消息签名 * @param timestamp 时间戳 * @param nonce 随机数 * @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息 * @return the boolean */ boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); /** * 获取suite_access_token, 不强制刷新suite_access_token * * @return the suite access token * @throws WxErrorException the wx error exception * @see #getSuiteAccessToken(boolean) #getSuiteAccessToken(boolean)#getSuiteAccessToken(boolean) * #getSuiteAccessToken(boolean) */ String getSuiteAccessToken() throws WxErrorException; /** * <pre> * 获取suite_access_token,本方法线程安全 * 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限 * 另:本service的所有方法都会在suite_access_token过期是调用此方法 * 程序员在非必要情况下尽量不要主动调用此方法 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90001/90143/90600">文档</a> * </pre> * * @param forceRefresh 强制刷新 * @return the suite access token * @throws WxErrorException the wx error exception */ String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException; /** * 获取suite_access_token和剩余过期时间, 不强制刷新suite_access_token * * @return suite access token and the remaining expiration time * @throws WxErrorException the wx error exception */ WxAccessToken getSuiteAccessTokenEntity() throws WxErrorException; /** * 获取suite_access_token和剩余过期时间, 支持强制刷新suite_access_token * * @param forceRefresh 是否调用微信服务器强制刷新token * @return suite access token and the remaining expiration time * @throws WxErrorException the wx error exception */ WxAccessToken getSuiteAccessTokenEntity(boolean forceRefresh) throws WxErrorException; /** * 获得suite_ticket,不强制刷新suite_ticket * * @return the suite ticket * @throws WxErrorException the wx error exception * @see #getSuiteTicket(boolean) #getSuiteTicket(boolean)#getSuiteTicket(boolean)#getSuiteTicket(boolean) */ String getSuiteTicket() throws WxErrorException; /** * <pre> * 保存企业微信定时推送的suite_ticket,(每10分钟) * 详情请见:<a href="https://work.weixin.qq.com/api/doc#90001/90143/90628">文档</a> * * 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟 * https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81 * </pre> * * @param suiteTicket the suite ticket */ void setSuiteTicket(String suiteTicket); /** * <pre> * 获得suite_ticket * 由于suite_ticket是微信服务器定时推送(每10分钟),不能主动获取,如果碰到过期只能抛异常 * * 详情请见:<a href="https://work.weixin.qq.com/api/doc#90001/90143/90628">文档</a> * </pre> * * @param forceRefresh 强制刷新 * @return the suite ticket * @throws WxErrorException the wx error exception * @see #setSuiteTicket(String) #setSuiteTicket(String)#setSuiteTicket(String) * @deprecated 由于无法主动刷新 ,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket */ @Deprecated String getSuiteTicket(boolean forceRefresh) throws WxErrorException; /** * <pre> * 保存企业微信定时推送的suite_ticket,(每10分钟) * 详情请见:<a href="https://work.weixin.qq.com/api/doc#90001/90143/90628">文档</a> * * 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟 * https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81 * </pre> * * @param suiteTicket the suite ticket * @param expiresInSeconds the expires in seconds */ void setSuiteTicket(String suiteTicket, int expiresInSeconds); /** * 获取应用的 jsapi ticket * * @param authCorpId 授权企业的cropId * @return jsapi ticket * @throws WxErrorException the wx error exception */ String getSuiteJsApiTicket(String authCorpId) throws WxErrorException; /** * 获取应用的 jsapi ticket, 支持强制刷新 * * @param authCorpId the auth corp id * @param forceRefresh the force refresh * @return suite js api ticket * @throws WxErrorException the wx error exception */ String getSuiteJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException; /** * 小程序登录凭证校验 * * @param jsCode 登录时获取的 code * @return the wx cp ma js code 2 session result * @throws WxErrorException the wx error exception */ WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorException; /** * 获取企业凭证 * * @param authCorpId 授权方corpid * @param permanentCode 永久授权码,通过get_permanent_code获取 * @return the corp token * @throws WxErrorException the wx error exception */ WxAccessToken getCorpToken(String authCorpId, String permanentCode) throws WxErrorException; /** * 获取企业凭证, 支持强制刷新 * * @param authCorpId the auth corp id * @param permanentCode the permanent code * @param forceRefresh the force refresh * @return corp token * @throws WxErrorException the wx error exception */ WxAccessToken getCorpToken(String authCorpId, String permanentCode, boolean forceRefresh) throws WxErrorException; /** * 获取企业永久授权码 . * * @param authCode . * @return . permanent code * @throws WxErrorException the wx error exception */ @Deprecated WxCpTpCorp getPermanentCode(String authCode) throws WxErrorException; WxCpTpCorp getV2PermanentCode(String authCode) throws WxErrorException; /** * 获取企业永久授权码信息 * <pre> * 原来的方法实现不全 * </pre> * * @param authCode the auth code * @return permanent code info * @throws WxErrorException the wx error exception * @author yuan * @since 2020 -03-18 */ WxCpTpPermanentCodeInfo getPermanentCodeInfo(String authCode) throws WxErrorException; WxCpTpPermanentCodeInfo getV2PermanentCodeInfo(String authCode) throws WxErrorException; /** * <pre> * 获取预授权链接 * </pre> * * @param redirectUri 授权完成后的回调网址 * @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击 * @return pre auth url * @throws WxErrorException the wx error exception */ String getPreAuthUrl(String redirectUri, String state) throws WxErrorException; /** * <pre> * 获取预授权链接,测试环境下使用 * </pre> * * @param redirectUri 授权完成后的回调网址 * @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击 * @param authType 授权类型:0 正式授权, 1 测试授权。 * @return pre auth url * @throws WxErrorException the wx error exception * @link https ://work.weixin.qq.com/api/doc/90001/90143/90602 */ String getPreAuthUrl(String redirectUri, String state, int authType) throws WxErrorException; /** * 获取企业的授权信息 * * @param authCorpId 授权企业的corpId * @param permanentCode 授权企业的永久授权码 * @return auth info * @throws WxErrorException the wx error exception */ WxCpTpAuthInfo getAuthInfo(String authCorpId, String permanentCode) throws WxErrorException; /** * 获取授权企业的 jsapi ticket * * @param authCorpId 授权企业的cropId * @return jsapi ticket * @throws WxErrorException the wx error exception */ String getAuthCorpJsApiTicket(String authCorpId) throws WxErrorException; /** * 获取授权企业的 jsapi ticket, 支持强制刷新 * * @param authCorpId the auth corp id * @param forceRefresh the force refresh * @return auth corp js api ticket * @throws WxErrorException the wx error exception */ String getAuthCorpJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求. * * @param url 接口地址 * @param queryParam 请求参数 * @return the string * @throws WxErrorException the wx error exception */ String get(String url, String queryParam) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求. * * @param url 接口地址 * @param queryParam 请求参数 * @param withoutSuiteAccessToken 请求是否忽略SuiteAccessToken 默认不忽略-false * @return the string * @throws WxErrorException the wx error exception */ String get(String url, String queryParam, boolean withoutSuiteAccessToken) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求. * * @param url 接口地址 * @param postData 请求body字符串 * @return the string * @throws WxErrorException the wx error exception */ String post(String url, String postData) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求. * * @param url 接口地址 * @param postData 请求body字符串 * @param withoutSuiteAccessToken 请求是否忽略SuiteAccessToken 默认不忽略-false * @return the string * @throws WxErrorException the wx error exception */ String post(String url, String postData, boolean withoutSuiteAccessToken) throws WxErrorException; /** * <pre> * Service没有实现某个API的时候,可以用这个, * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 * 可以参考,{@link MediaUploadRequestExecutor}的实现方法 * </pre> * * @param <T> 请求值类型 * @param <E> 返回值类型 * @param executor 执行器 * @param uri 请求地址 * @param data 参数 * @return the t * @throws WxErrorException the wx error exception */ <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException; /** * <pre> * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试. * 默认:1000ms * </pre> * * @param retrySleepMillis 重试休息时间 */ void setRetrySleepMillis(int retrySleepMillis); /** * <pre> * 设置当微信系统响应系统繁忙时,最大重试次数. * 默认:5次 * </pre> * * @param maxRetryTimes 最大重试次数 */ void setMaxRetryTimes(int maxRetryTimes); /** * 初始化http请求对象 */ void initHttp(); /** * 获取WxCpTpConfigStorage 对象. * * @return WxCpTpConfigStorage wx cp tp config storage */ WxCpTpConfigStorage getWxCpTpConfigStorage(); /** * 注入 {@link WxCpTpConfigStorage} 的实现. * * @param wxConfigProvider 配置对象 */ void setWxCpTpConfigStorage(WxCpTpConfigStorage wxConfigProvider); /** * http请求对象. * * @return the request http */ RequestHttp<?, ?> getRequestHttp(); /** * 获取WxSessionManager 对象 * * @return WxSessionManager session manager */ WxSessionManager getSessionManager(); /** * <pre> * 获取登录/访问用户身份 * 1、<a href="https://developer.work.weixin.qq.com/document/path/91121">网页授权登录对应的文档</a> * 2、<a href="https://developer.work.weixin.qq.com/document/path/98179">企业微信web登录对应的文档</a> * </pre> * * @param code the code * @return user info 3 rd * @throws WxErrorException the wx error exception */ WxCpTpUserInfo getUserInfo3rd(String code) throws WxErrorException; /** * <pre> * 获取访问用户敏感信息 * <a href="https://developer.work.weixin.qq.com/document/path/95833">文档地址</a> * </pre> * * @param userTicket the user ticket * @return user detail 3 rd * @throws WxErrorException the wx error exception */ WxCpTpUserDetail getUserDetail3rd(String userTicket) throws WxErrorException; /** * 获取登录用户信息 * <p> * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/91125 * * @param authCode the auth code * @return login info * @throws WxErrorException the wx error exception */ WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException; /** * 获取带参授权链接 * <p> * <a href="https://developer.work.weixin.qq.com/document/path/95436">查看文档</a> * * @param state state * @param templateIdList 代开发自建应用模版ID列表,数量不能超过9个 * @return customized auth url * @throws WxErrorException the wx error exception */ WxTpCustomizedAuthUrl getCustomizedAuthUrl(String state, List<String> templateIdList) throws WxErrorException; /** * 获取服务商providerToken * * @return the wx cp provider token * @throws WxErrorException the wx error exception */ String getWxCpProviderToken() throws WxErrorException; /** * 获取服务商providerToken和剩余过期时间 * * @return wx cp provider token entity * @throws WxErrorException the wx error exception */ WxCpProviderToken getWxCpProviderTokenEntity() throws WxErrorException; /** * 获取服务商providerToken和剩余过期时间,支持强制刷新 * * @param forceRefresh the force refresh * @return wx cp provider token entity * @throws WxErrorException the wx error exception */ WxCpProviderToken getWxCpProviderTokenEntity(boolean forceRefresh) throws WxErrorException; /** * get contact service * * @return WxCpTpContactService wx cp tp contact service */ WxCpTpContactService getWxCpTpContactService(); /** * set contact service * * @param wxCpTpContactService the contact service */ void setWxCpTpContactService(WxCpTpContactService wxCpTpContactService); /** * get department service * * @return WxCpTpDepartmentService wx cp tp department service */ WxCpTpDepartmentService getWxCpTpDepartmentService(); /** * set department service * * @param wxCpTpDepartmentService the department service */ void setWxCpTpDepartmentService(WxCpTpDepartmentService wxCpTpDepartmentService); /** * get media service * * @return WxCpTpMediaService wx cp tp media service */ WxCpTpMediaService getWxCpTpMediaService(); /** * set media service * * @param wxCpTpMediaService the media service */ void setWxCpTpMediaService(WxCpTpMediaService wxCpTpMediaService); /** * get oa service * * @return WxCpTpOAService wx cp tp oa service */ WxCpTpOAService getWxCpTpOAService(); /** * set oa service * * @param wxCpTpOAService the oa service */ void setWxCpTpOAService(WxCpTpOAService wxCpTpOAService); /** * get user service * * @return WxCpTpUserService wx cp tp user service */ WxCpTpUserService getWxCpTpUserService(); /** * set user service * * @param wxCpTpUserService the set user service */ void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService); /** * set license service * * @param wxCpTpLicenseService the oa service */ void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService); /** * get license service * * @return getCpTPLicenseService wx cp tp license service */ WxCpTpLicenseService getWxCpTpLicenseService(); WxCpTpXmlMessage fromEncryptedXml(String encryptedXml, String timestamp, String nonce, String msgSignature); String getVerifyDecrypt(String sVerifyEchoStr); /** * 获取应用的管理员列表 * * @param authCorpId the auth corp id * @param agentId the agent id * @return admin list * @throws WxErrorException the wx error exception */ WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException; /** * 获取应用二维码 * @param suiteId 第三方应用id(即ww或wx开头的suiteid) * @param appId 第三方应用id,单应用不需要该参数,多应用旧套件才需要传该参数。若不传默认为1 * @param state state值,用于区分不同的安装渠道 * @param style 二维码样式选项,默认为不带说明外框小尺寸。0:带说明外框的二维码,适合于实体物料,1:带说明外框的二维码,适合于屏幕类,2:不带说明外框(小尺寸),3:不带说明外框(中尺寸),4:不带说明外框(大尺寸)。具体样式与服务商管理端获取到的应用二维码样式一一对应,参见下文二维码样式说明 * @param resultType 结果返回方式,默认为返回二维码图片buffer。1:二维码图片buffer,2:二维码图片url * @return 二维码 * @throws WxErrorException the wx error exception */ WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException ; /** * * 明文corpid转换为加密corpid 为更好地保护企业与用户的数据,第三方应用获取的corpid不再是明文的corpid,将升级为第三方服务商级别的加密corpid。<a href="https://developer.work.weixin.qq.com/document/path/95327">文档说明</a> * 第三方可以将已有的明文corpid转换为第三方的加密corpid。 * @param corpId * @return * @throws WxErrorException */ WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException; /** * 创建机构级jsApiTicket签名 * 详情参见<a href="https://work.weixin.qq.com/api/doc/90001/90144/90539">企业微信第三方应用开发文档</a> * * @param url 调用JS接口页面的完整URL * @param authCorpId the auth corp id * @return wx jsapi signature * @throws WxErrorException the wx error exception */ WxJsapiSignature createAuthCorpJsApiTicketSignature(String url, String authCorpId) throws WxErrorException; /** * 创建应用级jsapiTicket签名 * 详情参见:<a href="https://work.weixin.qq.com/api/doc/90001/90144/90539">企业微信第三方应用开发文档</a> * * @param url 调用JS接口页面的完整URL * @param authCorpId the auth corp id * @return wx jsapi signature * @throws WxErrorException the wx error exception */ WxJsapiSignature createSuiteJsApiTicketSignature(String url, String authCorpId) throws WxErrorException; /** * 使套件accessToken缓存失效 */ void expireSuiteAccessToken(); /** * 使机构accessToken缓存失效 * * @param authCorpId 机构id */ void expireAccessToken(String authCorpId); /** * 使机构jsapiticket缓存失效 * * @param authCorpId 机构id */ void expireAuthCorpJsApiTicket(String authCorpId); /** * 使应用jsapiticket失效 * * @param authCorpId 机构id */ void expireAuthSuiteJsApiTicket(String authCorpId); /** * 使供应商accessToken失效 */ void expireProviderToken(); /** * 获取应用版本付费订单相关接口服务 * * @return the wx cp tp order service */ WxCpTpOrderService getWxCpTpOrderService(); /** * 设置应用版本付费订单相关接口服务 * * @param wxCpTpOrderService the wx cp tp order service */ void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService); /** * 获取应用版本付费版本相关接口服务 * * @return the wx cp tp edition service */ WxCpTpEditionService getWxCpTpEditionService(); /** * 设置应用版本付费版本相关接口服务 * * @param wxCpTpEditionService the wx cp tp edition service */ void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService); WxCpTpIdConvertService getWxCpTpIdConverService(); void setWxCpTpIdConverService(WxCpTpIdConvertService wxCpTpIdConvertService); /** * 构造第三方应用oauth2链接 */ WxCpTpOAuth2Service getWxCpTpOAuth2Service(); void setWxCpTpOAuth2Service(WxCpTpOAuth2Service wxCpTpOAuth2Service); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAService.java
package me.chanjar.weixin.cp.tp.service; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult; import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest; import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult; /** * 企业微信OA相关接口. * * @author Element created on 2019-04-06 10:52 */ public interface WxCpTpOAService { /** * <pre>提交审批申请 * 调试工具 * 企业可通过审批应用或自建应用Secret调用本接口,代应用可见范围内员工在企业微信“审批应用”内提交指定类型的审批申请。 * * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91853 * </pre> * * @param request 请求 * @param corpId the corp id * @return 表单提交成功后 ,返回的表单编号 * @throws WxErrorException . */ String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException; /** * 获取审批模板详情 * * @param templateId 模板ID * @param corpId the corp id * @return . template detail * @throws WxErrorException . */ WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException; /** * 复制/更新模板到企业 * * @param openTemplateId 模板ID * @param corpId the corp id * @return . string * @throws WxErrorException . */ String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException; /** * <pre> * 获取审批申请详情 * * @param spNo 审批单编号。 * @param corpId the corp id * @return WxCpApprovaldetail approval detail * @throws WxErrorException . */ WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpMediaService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import java.io.File; import java.io.IOException; import java.io.InputStream; /** * <pre> * 媒体管理接口. * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpTpMediaService { /** * <pre> * 上传多媒体文件. * 上传的多媒体文件有格式和大小限制,如下: * 图片(image): 1M,支持JPG格式 * 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 * 视频(video):10MB,支持MP4格式 * 缩略图(thumb):64KB,支持JPG格式 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 * </pre> * * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} * @param inputStream 输入流,需要调用方控制关闭该输入流 * @param corpId the corp id * @return the wx media upload result * @throws WxErrorException the wx error exception * @throws IOException the io exception */ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) throws WxErrorException, IOException; /** * 上传多媒体文件. * * @param mediaType 媒体类型 * @param file 文件对象 * @param corpId 授权企业的corpid * @return the wx media upload result * @throws WxErrorException 异常信息 * @see #upload(String, String, InputStream, String) #upload(String, String, InputStream, String) */ WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException; /** * <pre> * 上传图片. * 上传图片得到图片URL,该URL永久有效 * 返回的图片URL,仅能用于图文消息(mpnews)正文中的图片展示;若用于非企业微信域名下的页面,图片将被屏蔽。 * 每个企业每天最多可上传100张图片 * 接口url格式:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN * </pre> * * @param file 上传的文件对象 * @param corpId 授权企业的corpid * @return 返回图片url string * @throws WxErrorException 异常信息 */ String uploadImg(File file, String corpId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpEditionService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpEditionService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult; /** * 应用版本付费版本相关接口 * * @author leiguoqing created on 2022年4月24日 */ public interface WxCpTpEditionService { /** * 延长试用期 * <p> * <a href='https://developer.work.weixin.qq.com/document/path/91913'>文档地址</a> * <p/> * 注意: * <ul> * <li>一个应用可以多次延长试用,但是试用总天数不能超过60天</li> * <li>仅限时试用或试用过期状态下的应用可以延长试用期</li> * </ul> * * @param buyerCorpId 购买方corpId * @param prolongDays 延长天数 * @param appId 仅旧套件需要填此参数 * @return the order * @throws WxErrorException the wx error exception */ WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpLicenseService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpLicenseService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount; import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer; import me.chanjar.weixin.cp.bean.license.account.*; import me.chanjar.weixin.cp.bean.license.order.*; import java.util.Collection; import java.util.Date; import java.util.List; /** * <pre> * 服务商接口调用许可相关接口 * 文档地址:https://developer.work.weixin.qq.com/document/path/95652 * </pre> * * @author Totoro created on 2022/6/27 10:57 */ public interface WxCpTpLicenseService { /** * 下单购买账号 * 服务商下单为企业购买新的账号,可以同时购买基础账号与互通账号。 * 下单之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95644 * * @param licenseNewOrderRequest 订单信息 * @return 订单ID wx cp tp license create order resp * @throws WxErrorException ; */ WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException; /** * 创建下单续期账号任务 * <pre> * 可以下单为一批已激活账号的成员续期,续期下单分为两个步骤: * 传入userid列表创建一个任务,创建之后,可以往同一个任务继续追加待续期的userid列表; * 根据步骤1得到的jobid提交订单。 * </pre> * * @param licenseRenewOrderJobRequest 续费订单信息 * @return 返回JobId wx cp tp license renew order job resp * @throws WxErrorException ; */ WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException; /** * 提交续期订单 * 创建续期任务之后,需要调用该接口,以提交订单任务。 * 注意,提交之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95646 * * @param licenseRenewOrderRequest 订单信息 * @return 订单ID wx cp tp license create order resp * @throws WxErrorException ; */ WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException; /** * 获取订单列表 * 服务商查询自己某段时间内的平台能力服务订单列表 * 文档地址:https://developer.work.weixin.qq.com/document/path/95647 * * @param corpId 企业ID * @param startTime 开始时间,下单时间。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。 * @param endTime 结束时间,下单时间。起始时间跟结束时间不能超过31天。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。 * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 * @param limit 返回的最大记录数,整型,最大值1000,默认值500 * @return 订单列表 order list * @throws WxErrorException ; */ WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, int limit) throws WxErrorException; /** * 获取订单详情 * 查询某个订单的详情,包括订单的状态、基础账号个数、互通账号个数、账号购买时长等。 * 注意,该接口不返回订单中的账号激活码列表或者续期的账号成员列表,请调用获取订单中的账号列表接口以获取账号列表。 * * @param orderId 订单ID * @return 单条订单信息 order info * @throws WxErrorException ; */ WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException; /** * 查询指定订单下的平台能力服务账号列表。 * 若为购买账号的订单或者存量企业的版本付费迁移订单,则返回账号激活码列表; * 若为续期账号的订单,则返回续期账号的成员列表。注意,若是购买账号的订单, * 则仅订单支付完成时,系统才会生成账号,故支付完成之前,该接口不会返回账号激活码。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95649 * * @param orderId 订单ID * @param limit 大小 * @param cursor 分页游标 * @return 订单账号列表 order account list * @throws WxErrorException ; */ WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException; /** * 激活账号 * 下单购买账号并支付完成之后,先调用获取订单中的账号列表接口获取到账号激活码, * 然后可以调用该接口将激活码绑定到某个企业员工,以对其激活相应的平台服务能力。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95553 * * @param code 激活码 * @param corpId 企业ID * @param userId 用户ID * @return 激活结果 wx cp base resp * @throws WxErrorException ; */ WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException; /** * 批量激活账号 * 可在一次请求里为一个企业的多个成员激活许可账号,便于服务商批量化处理。 * 一个userid允许激活一个基础账号以及一个互通账号。 * 单次激活的员工数量不超过1000 * * @param corpId 企业ID * @param activeAccountList 激活列表 * @return 激活结果 wx cp tp license batch active result resp * @throws WxErrorException ; */ WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, List<WxCpTpLicenseActiveAccount> activeAccountList) throws WxErrorException; /** * 获取激活码详情 * 查询某个账号激活码的状态以及激活绑定情况。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95552 * * @param code 激活码 * @param corpId 企业ID * @return 激活码信息 active info by code * @throws WxErrorException ; */ WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException; /** * 获取激活码详情 * 查询某个账号激活码的状态以及激活绑定情况。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95552 * * @param codes 激活码 * @param corpId 企业ID * @return 激活码信息 wx cp tp license batch code info resp * @throws WxErrorException ; */ WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection<String> codes, String corpId) throws WxErrorException; /** * 获取企业的账号列表 * 查询指定企业下的平台能力服务账号列表。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95544 * * @param corpId 企业ID * @param limit 大小 * @param cursor 游标 * @return 已激活列表 corp account list * @throws WxErrorException the wx error exception */ WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException; /** * 获取成员的激活详情 * 查询某个企业成员的激活情况。 * 文档地址:https://developer.work.weixin.qq.com/document/path/95555 * * @param corpId 企业ID * @param userId 用户ID * @return 激活情况 active info by user * @throws WxErrorException ; */ WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException; /** * 账号继承 * 在企业员工离职或者工作范围的有变更时,允许将其许可账号继承给其他员工。 * * @param corpId 企业ID * @param transferList 转移列表 * @return 转移结果 wx cp tp license batch transfer resp * @throws WxErrorException ; */ WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List<WxCpTpLicenseTransfer> transferList) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpContactService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpContactSearch; import me.chanjar.weixin.cp.bean.WxCpTpContactSearchResp; /** * The interface Wx cp tp contact service. * * @author uianz * @since 2020 /12/23 下午 02:39 */ public interface WxCpTpContactService { /** * https://work.weixin.qq.com/api/doc/90001/90143/91844 * 通讯录单个搜索 * * @param wxCpTpContactSearch the wx cp tp contact search * @return wx cp tp contact search resp * @throws WxErrorException the wx error exception */ WxCpTpContactSearchResp contactSearch(WxCpTpContactSearch wxCpTpContactSearch) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConvertService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConvertService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpConvertTmpExternalUserIdResult; import me.chanjar.weixin.cp.bean.WxCpTpOpenKfIdConvertResult; import me.chanjar.weixin.cp.bean.WxCpTpTagIdListConvertResult; import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; /** * <pre> * 企业微信三方应用ID转换接口 * * </pre> * * @author cocoa */ public interface WxCpTpIdConvertService { /** * unionid与external_userid的关联 * <a href="https://developer.work.weixin.qq.com/document/path/95900">查看文档</a> * * @param unionid 微信客户的unionid * @param openid 微信客户的openid * @param subjectType 程序或公众号的主体类型: 0表示主体名称是企业的,1表示主体名称是服务商的 * @throws WxErrorException 。 */ WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId, String unionid, String openid, Integer subjectType) throws WxErrorException; /** * 将企业主体下的客户标签ID转换成服务商主体下的客户标签ID * @param corpId 企业微信 ID * @param externalTagIdList 企业主体下的客户标签ID列表,最多不超过1000个 * @return 客户标签转换结果 * @throws WxErrorException . */ WxCpTpTagIdListConvertResult externalTagId(String corpId, String... externalTagIdList) throws WxErrorException; /** * 将企业主体下的微信客服ID转换成服务商主体下的微信客服ID * @param corpId 企业微信 ID * @param openKfIdList 微信客服ID列表,最多不超过1000个 * @return 微信客服ID转换结果 * @throws WxErrorException . */ WxCpTpOpenKfIdConvertResult ConvertOpenKfId (String corpId, String... openKfIdList ) throws WxErrorException; /** * 将应用获取的外部用户临时idtmp_external_userid,转换为external_userid * @param corpId 企业微信Id * @param businessType 业务类型。1-会议 2-收集表 * @param userType 转换的目标用户类型。1-客户 2-企业互联 3-上下游 4-互联企业(圈子) * @param tmpExternalUserIdList 外部用户临时id,最多不超过100个 * @return 转换成功的结果列表 */ WxCpTpConvertTmpExternalUserIdResult convertTmpExternalUserId(String corpId, int businessType, int userType, String... tmpExternalUserIdList) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAuth2Service.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOAuth2Service.java
package me.chanjar.weixin.cp.tp.service; /** * <pre> * 构造第三方应用oauth2链接 * Created by feidian108 on 2023/3/24. * </pre> * <p> * <a href="https://developer.work.weixin.qq.com/document/path/91120">企业微信服务商文档</a> */ public interface WxCpTpOAuth2Service { /** * <pre> * 构造第三方应用oauth2链接(静默授权) * </pre> * @param redirectUri 授权后重定向的回调链接地址 * @param state 重定向后state参数 * @return url string */ String buildAuthorizeUrl(String redirectUri, String state); /** * <pre> * 构造第三方应用oauth2链接 * </pre> * @param redirectUri 授权后重定向的回调链接地址 * @param state 重定向后state参数 * @param scope 应用授权作用域,snsapi_base:静默授权,snsapi_privateinfo:手动授权 * @return url string */ String buildAuthorizeUrl(String redirectUri, String state, String scope); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails; import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult; import java.util.Date; /** * 应用版本付费订单相关接口 * * @author leiguoqing created on 2022年4月24日 */ public interface WxCpTpOrderService { /** * 获取订单详情 * <p> * <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85'>文档地址</a> * <p/> * * @param orderId 订单号 * @return the order * @throws WxErrorException the wx error exception */ WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException; /** * 获取订单列表 * <p> * <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8'>文档地址</a> * <p/> * * @param startTime 起始时间 * @param endTime 终止时间 * @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。 * @return the order * @throws WxErrorException the wx error exception */ WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpTag; import me.chanjar.weixin.cp.bean.WxCpTpTagAddOrRemoveUsersResult; import me.chanjar.weixin.cp.bean.WxCpTpTagGetResult; import java.util.List; /** * <pre> * 企业微信第三方开发-标签相关接口 * </pre> * * @author zhangq <zhangq002@gmail.com> * @since 2021 -02-14 16:02 */ public interface WxCpTpTagService { /** * 创建标签. * <pre> * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/90346 * </pre> * * @param name 标签名称,长度限制为32个字以内(汉字或英文字母),标签名不可与其他标签重名。 * @param id 标签id,非负整型,指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。 * @return 标签id string * @throws WxErrorException the wx error exception */ String create(String name, Integer id) throws WxErrorException; /** * 更新标签. * * @param tagId 标签id * @param tagName 标签名 * @throws WxErrorException . */ void update(String tagId, String tagName) throws WxErrorException; /** * 删除标签. * * @param tagId 标签id * @throws WxErrorException . */ void delete(String tagId) throws WxErrorException; /** * 获取标签成员 * * @param tagId the tag id * @return wx cp tp tag get result * @throws WxErrorException the wx error exception */ WxCpTpTagGetResult get(String tagId) throws WxErrorException; /** * 增加标签成员. * * @param tagId 标签id * @param userIds 用户ID 列表 * @param partyIds 企业部门ID列表 * @return . wx cp tp tag add or remove users result * @throws WxErrorException . */ WxCpTpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; /** * 移除标签成员. * * @param tagId 标签id * @param userIds 用户id列表 * @param partyIds 企业部门ID列表 * @return . wx cp tp tag add or remove users result * @throws WxErrorException . */ WxCpTpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; /** * 获得标签列表. * * @return 标签列表 list * @throws WxErrorException . */ List<WxCpTpTag> listAll() throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java
package me.chanjar.weixin.cp.tp.service; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpInviteResult; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; import java.util.List; import java.util.Map; /** * <pre> * 用户管理接口 * Created by jamie on 2020/7/22. * </pre> */ public interface WxCpTpUserService { /** * <pre> * 用在二次验证的时候. * 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。 * </pre> * * @param userId 用户id * @throws WxErrorException the wx error exception */ void authenticate(String userId) throws WxErrorException; /** * <pre> * 获取部门成员(详情). * * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98.28.E8.AF.A6.E6.83.85.29 * </pre> * * @param departId 必填。部门id * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 * @param corpId the corp id * @return the list * @throws WxErrorException the wx error exception */ List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status, String corpId) throws WxErrorException; /** * <pre> * 获取部门成员. * * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98 * </pre> * * @param departId 必填。部门id * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 * @return the list * @throws WxErrorException the wx error exception */ List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException; /** * 新建用户. * * @param user 用户对象 * @throws WxErrorException the wx error exception */ void create(WxCpUser user) throws WxErrorException; /** * 更新用户. * * @param user 用户对象 * @throws WxErrorException the wx error exception */ void update(WxCpUser user) throws WxErrorException; /** * <pre> * 删除用户/批量删除成员. * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98 * </pre> * * @param userIds 员工UserID列表。对应管理端的帐号 * @throws WxErrorException the wx error exception */ void delete(String... userIds) throws WxErrorException; /** * 获取用户. * * @param userid 用户id * @param corpId the corp id * @return the by id * @throws WxErrorException the wx error exception */ WxCpUser getById(String userid, String corpId) throws WxErrorException; /** * <pre> * 邀请成员. * 企业可通过接口批量邀请成员使用企业微信,邀请后将通过短信或邮件下发通知。 * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/batch/invite?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc#12543 * </pre> * * @param userIds 成员ID列表, 最多支持1000个。 * @param partyIds 部门ID列表,最多支持100个。 * @param tagIds 标签ID列表,最多支持100个。 * @return the wx cp invite result * @throws WxErrorException the wx error exception */ WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException; /** * <pre> * userid转openid. * 该接口使用场景为微信支付、微信红包和企业转账。 * * 在使用微信支付的功能时,需要自行将企业微信的userid转成openid。 * 在使用微信红包功能时,需要将应用id和userid转成appid和openid才能使用。 * 注:需要成员使用微信登录企业微信或者关注微信插件才能转成openid * * 文档地址:https://work.weixin.qq.com/api/doc#11279 * </pre> * * @param userId 企业内的成员id * @param agentId 非必填,整型,仅用于发红包。其它场景该参数不要填,如微信支付、企业转账、电子发票 * @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid - * appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到 * @throws WxErrorException the wx error exception */ Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException; /** * <pre> * openid转userid. * * 该接口主要应用于使用微信支付、微信红包和企业转账之后的结果查询。 * 开发者需要知道某个结果事件的openid对应企业微信内成员的信息时,可以通过调用该接口进行转换查询。 * 权限说明: * 管理组需对openid对应的企业微信成员有查看权限。 * * 文档地址:https://work.weixin.qq.com/api/doc#11279 * </pre> * * @param openid 在使用微信支付、微信红包和企业转账之后,返回结果的openid * @return userid 该openid在企业微信对应的成员userid * @throws WxErrorException the wx error exception */ String openid2UserId(String openid) throws WxErrorException; /** * <pre> * * 通过手机号获取其所对应的userid。 * * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc#90001/90143/91693 * </pre> * * @param mobile 手机号码。长度为5~32个字节 * @param corpId – the corp id * @return userid mobile对应的成员userid * @throws WxErrorException . */ String getUserId(String mobile, String corpId) throws WxErrorException; /** * 获取外部联系人详情. * <pre> * 企业可通过此接口,根据外部联系人的userid,拉取外部联系人详情。权限说明: * 企业需要使用外部联系人管理secret所获取的accesstoken来调用 * 第三方应用需拥有“企业客户”权限。 * 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * </pre> * * @param userId 外部联系人的userid * @return 联系人详情 external contact * @throws WxErrorException . */ WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.apache.ApacheBasicResponseHandler; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import java.io.IOException; import java.nio.charset.StandardCharsets; /** * The type Wx cp tp service apache http client. * * @author someone */ public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<CloseableHttpClient, HttpHost> { private CloseableHttpClient httpClient; private HttpHost httpProxy; @Override public CloseableHttpClient getRequestHttpClient() { return httpClient; } @Override public HttpHost getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.APACHE_HTTP; } @Override public String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isSuiteAccessTokenExpired() && !forceRefresh) { return this.configStorage.getSuiteAccessToken(); } synchronized (this.globalSuiteAccessTokenRefreshLock) { try { HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN)); if (this.httpProxy != null) { RequestConfig config = RequestConfig.custom() .setProxy(this.httpProxy).build(); httpPost.setConfig(config); } JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("suite_id", this.configStorage.getSuiteId()); jsonObject.addProperty("suite_secret", this.configStorage.getSuiteSecret()); jsonObject.addProperty("suite_ticket", this.getSuiteTicket()); StringEntity entity = new StringEntity(jsonObject.toString(), StandardCharsets.UTF_8); httpPost.setEntity(entity); String resultContent = getRequestHttpClient().execute(httpPost, ApacheBasicResponseHandler.INSTANCE); WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } jsonObject = GsonParser.parse(resultContent); String suiteAccussToken = jsonObject.get("suite_access_token").getAsString(); int expiresIn = jsonObject.get("expires_in").getAsInt(); this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn); } catch (IOException e) { throw new WxRuntimeException(e); } } return this.configStorage.getSuiteAccessToken(); } @Override public void initHttp() { ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage.getApacheHttpClientBuilder(); if (null == apacheHttpClientBuilder) { apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); } apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost()) .httpProxyPort(this.configStorage.getHttpProxyPort()) .httpProxyUsername(this.configStorage.getHttpProxyUsername()) .httpProxyPassword(this.configStorage.getHttpProxyPassword()); if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(this.configStorage.getHttpProxyHost(), this.configStorage.getHttpProxyPort()); } this.httpClient = apacheHttpClientBuilder.build(); } // @Override // public WxCpTpConfigStorage getWxCpTpConfigStorage() { // return this.configStorage; // } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMediaServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.cp.tp.service.WxCpTpMediaService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.UUID; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Media.IMG_UPLOAD; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Media.MEDIA_UPLOAD; /** * <pre> * 媒体管理接口. * Created by Binary Wang on 2017-6-25. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @RequiredArgsConstructor public class WxCpTpMediaServiceImpl implements WxCpTpMediaService { private final WxCpTpService mainService; @Override public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream, String corpId) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType), corpId); } @Override public WxMediaUploadResult upload(String mediaType, File file, String corpId) throws WxErrorException { return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), mainService.getWxCpTpConfigStorage().getApiUrl(MEDIA_UPLOAD + mediaType) + "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId), file); } @Override public String uploadImg(File file, String corpId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(IMG_UPLOAD); url += "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file) .getUrl(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.common.collect.Maps; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.bean.WxCpInviteResult; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import me.chanjar.weixin.cp.tp.service.WxCpTpUserService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.User.*; /** * <pre> * Created by jamie on 2020/7/22. * </pre> */ @RequiredArgsConstructor public class WxCpTpUserServiceImpl implements WxCpTpUserService { private final WxCpTpService mainService; @Override public void authenticate(String userId) throws WxErrorException { this.mainService.get(mainService.getWxCpTpConfigStorage().getApiUrl(USER_AUTHENTICATE + userId), null); } @Override public void create(WxCpUser user) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_CREATE); this.mainService.post(url, user.toJson()); } @Override public void update(WxCpUser user) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_UPDATE); this.mainService.post(url, user.toJson()); } @Override public void delete(String... userIds) throws WxErrorException { if (userIds.length == 1) { String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_DELETE + userIds[0]); this.mainService.get(url, null); return; } JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("useridlist", jsonArray); this.mainService.post(mainService.getWxCpTpConfigStorage().getApiUrl(USER_BATCH_DELETE), jsonObject.toString()); } @Override public WxCpUser getById(String userid, String corpId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_GET + userid); url += "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.get(url, null); return WxCpUser.fromJson(responseContent); } @Override public List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status, String corpId) throws WxErrorException { String params = ""; if (fetchChild != null) { params += "&fetch_child=" + (fetchChild ? "1" : "0"); } if (status != null) { params += "&status=" + status; } else { params += "&status=0"; } params += "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_LIST + departId); String responseContent = this.mainService.get(url, params); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson(tmpJsonElement.getAsJsonObject().get("userlist"), new TypeToken<List<WxCpUser>>() { }.getType() ); } @Override public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { String params = ""; if (fetchChild != null) { params += "&fetch_child=" + (fetchChild ? "1" : "0"); } if (status != null) { params += "&status=" + status; } else { params += "&status=0"; } String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_SIMPLE_LIST + departId); String responseContent = this.mainService.get(url, params); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson( tmpJsonElement.getAsJsonObject().get("userlist"), new TypeToken<List<WxCpUser>>() { }.getType() ); } @Override public WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException { JsonObject jsonObject = new JsonObject(); if (userIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("user", jsonArray); } if (partyIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : partyIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("party", jsonArray); } if (tagIds != null) { JsonArray jsonArray = new JsonArray(); for (String tagId : tagIds) { jsonArray.add(new JsonPrimitive(tagId)); } jsonObject.add("tag", jsonArray); } String url = mainService.getWxCpTpConfigStorage().getApiUrl(BATCH_INVITE); return WxCpInviteResult.fromJson(this.mainService.post(url, jsonObject.toString())); } @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_CONVERT_TO_OPENID); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJsonElement = GsonParser.parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; } @Override public String openid2UserId(String openid) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("openid", openid); String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_CONVERT_TO_USERID); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); } @Override public String getUserId(String mobile, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("mobile", mobile); String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); } @Override public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); String responseContent = this.mainService.get(url, null); return WxCpUserExternalContactInfo.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpContactServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpContactSearch; import me.chanjar.weixin.cp.bean.WxCpTpContactSearchResp; import me.chanjar.weixin.cp.tp.service.WxCpTpContactService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.CONTACT_SEARCH; /** * The type Wx cp tp contact service. * * @author uianz * @since 2020 /12/23 下午 02:39 */ @RequiredArgsConstructor public class WxCpTpContactServiceImpl implements WxCpTpContactService { private final WxCpTpService mainService; @Override public WxCpTpContactSearchResp contactSearch(WxCpTpContactSearch wxCpTpContactSearch) throws WxErrorException { String responseText = mainService.post(mainService.getWxCpTpConfigStorage().getApiUrl(CONTACT_SEARCH) + "?provider_access_token=" + mainService.getWxCpProviderToken(), wxCpTpContactSearch.toJson()); return WxCpTpContactSearchResp.fromJson(responseText); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails; import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult; import me.chanjar.weixin.cp.tp.service.WxCpTpOrderService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import java.util.Date; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER_LIST; /** * 应用版本付费订单相关接口实现 * * @author leigouqing created on 2022年4月24日 */ @RequiredArgsConstructor public class WxCpTpOrderServiceImpl implements WxCpTpOrderService { /** * The Main service. */ private final WxCpTpService mainService; /** * 获取订单详情 * <p> * <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85'>文档地址</a> * <p/> * * @param orderId 订单号 * @return the order * @throws WxErrorException the wx error exception */ @Override public WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("orderid", orderId); String result = this.mainService.post(url, jsonObject.toString()); return WxCpTpOrderDetails.fromJson(result); } /** * 获取订单列表 * <p> * <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8'>文档地址</a> * <p/> * * @param startTime 起始时间 * @param endTime 终止时间 * @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。 * @return the order list * @throws WxErrorException the wx error exception */ @Override public WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER_LIST); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("start_time", startTime.getTime() / 1000); jsonObject.addProperty("end_time", endTime.getTime() / 1000); jsonObject.addProperty("test_mode", testMode); String result = this.mainService.post(url, jsonObject.toString()); return WxCpTpOrderListGetResult.fromJson(result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAuth2ServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAuth2ServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.util.http.URIUtil; import me.chanjar.weixin.cp.tp.service.WxCpTpOAuth2Service; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.SNSAPI_BASE; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.OAuth2.URL_OAUTH2_AUTHORIZE; @RequiredArgsConstructor public class WxCpTpOAuth2ServiceImpl implements WxCpTpOAuth2Service { private final WxCpTpService mainService; @Override public String buildAuthorizeUrl(String redirectUri, String state) { return this.buildAuthorizeUrl(redirectUri, state, SNSAPI_BASE); } @Override public String buildAuthorizeUrl(String redirectUri, String state, String scope) { StringBuilder url = new StringBuilder(URL_OAUTH2_AUTHORIZE); url.append("?appid=").append(this.mainService.getWxCpTpConfigStorage().getSuiteId()); url.append("&redirect_uri=").append(URIUtil.encodeURIComponent(redirectUri)); url.append("&response_type=code"); url.append("&scope=").append(scope); if (state != null) { url.append("&state=").append(state); } url.append("#wechat_redirect"); return url.toString(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceOkHttpImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceOkHttpImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import okhttp3.*; import java.io.IOException; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_TOKEN; /** * The type Wx cp service ok http. * * @author someone */ @Slf4j public class WxCpTpServiceOkHttpImpl extends BaseWxCpTpServiceImpl<OkHttpClient, OkHttpProxyInfo> { private OkHttpClient httpClient; private OkHttpProxyInfo httpProxy; @Override public OkHttpClient getRequestHttpClient() { return httpClient; } @Override public OkHttpProxyInfo getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.OK_HTTP; } @Override public String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isSuiteAccessTokenExpired() && !forceRefresh) { return this.configStorage.getSuiteAccessToken(); } synchronized (this.globalSuiteAccessTokenRefreshLock) { // 得到 httpClient OkHttpClient client = getRequestHttpClient(); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("suite_id", this.configStorage.getSuiteId()); jsonObject.addProperty("suite_secret", this.configStorage.getSuiteSecret()); jsonObject.addProperty("suite_ticket", this.getSuiteTicket()); String jsonBody = jsonObject.toString(); RequestBody requestBody = RequestBody.create( MediaType.get("application/json; charset=utf-8"), jsonBody ); // 构建 POST 请求 Request request = new Request.Builder() .url(this.configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN)) // URL 不包含查询参数 .post(requestBody) // 使用 POST 方法 .build(); String resultContent = null; try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { throw new IOException("Unexpected response code: " + response); } resultContent = response.body().string(); } catch (IOException e) { log.error("获取 suite token 失败: {}", e.getMessage(), e); throw new WxRuntimeException("获取 suite token 失败", e); } WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } jsonObject = GsonParser.parse(resultContent); String suiteAccussToken = jsonObject.get("suite_access_token").getAsString(); int expiresIn = jsonObject.get("expires_in").getAsInt(); this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn); } return this.configStorage.getSuiteAccessToken(); } @Override public void initHttp() { log.debug("WxCpServiceOkHttpImpl initHttp"); //设置代理 if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); //设置授权 clientBuilder.proxyAuthenticator(new Authenticator() { @Override public Request authenticate(Route route, Response response) throws IOException { String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); return response.request().newBuilder() .header("Proxy-Authorization", credential) .build(); } }); httpClient = clientBuilder.build(); } else { httpClient = DefaultOkHttpClientBuilder.get().build(); } } // @Override // public WxCpConfigStorage getWxCpConfigStorage() { // return this.configStorage; // } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConvertServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConvertServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpConvertTmpExternalUserIdResult; import me.chanjar.weixin.cp.bean.WxCpTpOpenKfIdConvertResult; import me.chanjar.weixin.cp.bean.WxCpTpTagIdListConvertResult; import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import me.chanjar.weixin.cp.tp.service.WxCpTpIdConvertService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; /** * @author cocoa */ @RequiredArgsConstructor public class WxCpTpIdConvertServiceImpl implements WxCpTpIdConvertService { private final WxCpTpService mainService; @Override public WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId, String unionid, String openid, Integer subjectType) throws WxErrorException { JsonObject json = new JsonObject(); json.addProperty("unionid", unionid); json.addProperty("openid", openid); if (subjectType != null) { json.addProperty("subject_type", subjectType); } WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); String accessToken = wxCpTpConfigStorage.getAccessToken(cropId); String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.UNION_ID_TO_EXTERNAL_USER_ID); url += "?access_token=" + accessToken; String responseContent = this.mainService.post(url, json.toString()); return WxCpTpUnionidToExternalUseridResult.fromJson(responseContent); } @Override public WxCpTpTagIdListConvertResult externalTagId(String corpId, String... externalTagIdList) throws WxErrorException { WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.EXTERNAL_TAG_ID ) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String tagId : externalTagIdList) { jsonArray.add(new JsonPrimitive(tagId)); } jsonObject.add("external_tagid_list", jsonArray); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpTpTagIdListConvertResult.fromJson(responseContent); } @Override public WxCpTpOpenKfIdConvertResult ConvertOpenKfId(String corpId, String... openKfIdList) throws WxErrorException { WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.OPEN_KF_ID + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId)); JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String kfId : openKfIdList) { jsonArray.add(new JsonPrimitive(kfId)); } jsonObject.add("open_kfid_list", jsonArray); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpTpOpenKfIdConvertResult.fromJson(responseContent); } @Override public WxCpTpConvertTmpExternalUserIdResult convertTmpExternalUserId(String corpId, int businessType, int userType, String... tmpExternalUserIdList) throws WxErrorException { WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); String url = wxCpTpConfigStorage.getApiUrl(WxCpApiPathConsts.IdConvert.CONVERT_TMP_EXTERNAL_USER_ID + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId)); JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonObject.addProperty("business_type", businessType); jsonObject.addProperty("user_type", userType); for (String userId : tmpExternalUserIdList) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("tmp_external_userid_list", jsonArray); String responseContent = mainService.post(url, jsonObject.toString()); return WxCpTpConvertTmpExternalUserIdResult.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.common.base.Joiner; import com.google.gson.Gson; import com.google.gson.JsonObject; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxCpErrorMsgEnum; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.DataUtils; import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.cp.bean.*; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.tp.service.*; import me.chanjar.weixin.cp.util.crypto.WxCpTpCryptUtil; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.IOException; import java.net.URLEncoder; import java.util.HashMap; import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.*; /** * . * * @param <H> the type parameter * @param <P> the type parameter * @author zhenjun cai */ @Slf4j public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, RequestHttp<H, P> { private WxCpTpContactService wxCpTpContactService = new WxCpTpContactServiceImpl(this); private WxCpTpDepartmentService wxCpTpDepartmentService = new WxCpTpDepartmentServiceImpl(this); private WxCpTpMediaService wxCpTpMediaService = new WxCpTpMediaServiceImpl(this); private WxCpTpOAService wxCpTpOAService = new WxCpTpOAServiceImpl(this); private WxCpTpUserService wxCpTpUserService = new WxCpTpUserServiceImpl(this); private WxCpTpOrderService wxCpTpOrderService = new WxCpTpOrderServiceImpl(this); private WxCpTpEditionService wxCpTpEditionService = new WxCpTpEditionServiceImpl(this); private WxCpTpLicenseService wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(this); private WxCpTpIdConvertService wxCpTpIdConvertService = new WxCpTpIdConvertServiceImpl(this); private WxCpTpOAuth2Service wxCpTpOAuth2Service = new WxCpTpOAuth2ServiceImpl(this); /** * 全局的是否正在刷新access token的锁. */ protected final Object globalSuiteAccessTokenRefreshLock = new Object(); /** * 全局刷新suite ticket的锁 */ protected final Object globalSuiteTicketRefreshLock = new Object(); /** * 全局的是否正在刷新jsapi_ticket的锁. */ protected final Object globalJsApiTicketRefreshLock = new Object(); /** * 全局的是否正在刷新auth_corp_jsapi_ticket的锁. */ protected final Object globalAuthCorpJsApiTicketRefreshLock = new Object(); /** * The Global provider token refresh lock. */ protected final Object globalProviderTokenRefreshLock = new Object(); /** * The Config storage. */ protected WxCpTpConfigStorage configStorage; private final WxSessionManager sessionManager = new StandardSessionManager(); /** * 临时文件目录. */ private File tmpDirFile; private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @Override public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data) { try { return SHA1.gen(this.configStorage.getToken(), timestamp, nonce, data) .equals(msgSignature); } catch (Exception e) { log.error("Checking signature failed, and the reason is :{}", e.getMessage()); return false; } } @Override public String getSuiteAccessToken() throws WxErrorException { return getSuiteAccessToken(false); } @Override public WxAccessToken getSuiteAccessTokenEntity() throws WxErrorException { return this.getSuiteAccessTokenEntity(false); } @Override public WxAccessToken getSuiteAccessTokenEntity(boolean forceRefresh) throws WxErrorException { getSuiteAccessToken(forceRefresh); return this.configStorage.getSuiteAccessTokenEntity(); } @Override public String getSuiteTicket() throws WxErrorException { if (this.configStorage.isSuiteTicketExpired()) { // 本地suite ticket 不存在或者过期 WxError wxError = WxError.fromJson("{\"errcode\":40085, \"errmsg\":\"invalid suite ticket\"}", WxType.CP); throw new WxErrorException(wxError); } return this.configStorage.getSuiteTicket(); } @Override public String getSuiteTicket(boolean forceRefresh) throws WxErrorException { // suite ticket由微信服务器推送,不能强制刷新 // if (forceRefresh) { // this.configStorage.expireSuiteTicket(); // } return getSuiteTicket(); } @Override public void setSuiteTicket(String suiteTicket) { setSuiteTicket(suiteTicket, 28 * 60); } @Override public void setSuiteTicket(String suiteTicket, int expiresInSeconds) { synchronized (globalSuiteTicketRefreshLock) { this.configStorage.updateSuiteTicket(suiteTicket, expiresInSeconds); } } @Override public String getSuiteJsApiTicket(String authCorpId) throws WxErrorException { if (this.configStorage.isAuthSuiteJsApiTicketExpired(authCorpId)) { String resp = get(configStorage.getApiUrl(GET_SUITE_JSAPI_TICKET), "type=agent_config&access_token=" + this.configStorage.getAccessToken(authCorpId), true); JsonObject jsonObject = GsonParser.parse(resp); if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) { String jsApiTicket = jsonObject.get("ticket").getAsString(); int expiredInSeconds = jsonObject.get("expires_in").getAsInt(); synchronized (globalJsApiTicketRefreshLock) { configStorage.updateAuthSuiteJsApiTicket(authCorpId, jsApiTicket, expiredInSeconds); } } else { throw new WxErrorException(WxError.fromJson(resp)); } } return configStorage.getAuthSuiteJsApiTicket(authCorpId); } @Override public String getSuiteJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException { if (forceRefresh) { this.configStorage.expireAuthSuiteJsApiTicket(authCorpId); } return this.getSuiteJsApiTicket(authCorpId); } @Override public String getAuthCorpJsApiTicket(String authCorpId) throws WxErrorException { if (this.configStorage.isAuthCorpJsApiTicketExpired(authCorpId)) { String resp = get(configStorage.getApiUrl(GET_AUTH_CORP_JSAPI_TICKET), "access_token=" + this.configStorage.getAccessToken(authCorpId), true); JsonObject jsonObject = GsonParser.parse(resp); if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) { String jsApiTicket = jsonObject.get("ticket").getAsString(); int expiredInSeconds = jsonObject.get("expires_in").getAsInt(); synchronized (globalAuthCorpJsApiTicketRefreshLock) { configStorage.updateAuthCorpJsApiTicket(authCorpId, jsApiTicket, expiredInSeconds); } } else { throw new WxErrorException(WxError.fromJson(resp)); } } return configStorage.getAuthCorpJsApiTicket(authCorpId); } @Override public String getAuthCorpJsApiTicket(String authCorpId, boolean forceRefresh) throws WxErrorException { if (forceRefresh) { this.configStorage.expireAuthCorpJsApiTicket(authCorpId); } return this.getAuthCorpJsApiTicket(authCorpId); } @Override public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorException { Map<String, String> params = new HashMap<>(2); params.put("js_code", jsCode); params.put("grant_type", "authorization_code"); final String url = configStorage.getApiUrl(JSCODE_TO_SESSION); return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params))); } @Override public WxAccessToken getCorpToken(String authCorpId, String permanentCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_corpid", authCorpId); jsonObject.addProperty("permanent_code", permanentCode); String result = post(configStorage.getApiUrl(GET_CORP_TOKEN), jsonObject.toString()); return WxAccessToken.fromJson(result); } @Override public WxAccessToken getCorpToken(String authCorpId, String permanentCode, boolean forceRefresh) throws WxErrorException { if (this.configStorage.isAccessTokenExpired(authCorpId) || forceRefresh) { WxAccessToken corpToken = this.getCorpToken(authCorpId, permanentCode); this.configStorage.updateAccessToken(authCorpId, corpToken.getAccessToken(), corpToken.getExpiresIn()); } return this.configStorage.getAccessTokenEntity(authCorpId); } @Override public WxCpTpCorp getPermanentCode(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String result = post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString()); jsonObject = GsonParser.parse(result); WxCpTpCorp wxCpTpCorp = WxCpTpCorp.fromJson(jsonObject.get("auth_corp_info").getAsJsonObject().toString()); wxCpTpCorp.setPermanentCode(jsonObject.get("permanent_code").getAsString()); return wxCpTpCorp; } @Override public WxCpTpCorp getV2PermanentCode(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String result = post(configStorage.getApiUrl(GET_V2_PERMANENT_CODE), jsonObject.toString()); jsonObject = GsonParser.parse(result); WxCpTpCorp wxCpTpCorp = WxCpTpCorp.fromJson(jsonObject.get("auth_corp_info").getAsJsonObject().toString()); wxCpTpCorp.setPermanentCode(jsonObject.get("permanent_code").getAsString()); return wxCpTpCorp; } @Override public WxCpTpPermanentCodeInfo getPermanentCodeInfo(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String result = post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString()); return WxCpTpPermanentCodeInfo.fromJson(result); } @Override public WxCpTpPermanentCodeInfo getV2PermanentCodeInfo(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String result = post(configStorage.getApiUrl(GET_V2_PERMANENT_CODE), jsonObject.toString()); return WxCpTpPermanentCodeInfo.fromJson(result); } @Override @SneakyThrows public String getPreAuthUrl(String redirectUri, String state) throws WxErrorException { String result = get(configStorage.getApiUrl(GET_PREAUTH_CODE), null); WxCpTpPreauthCode preAuthCode = WxCpTpPreauthCode.fromJson(result); String preAuthUrl = "https://open.work.weixin.qq.com/3rdapp/install?suite_id=" + configStorage.getSuiteId() + "&pre_auth_code=" + preAuthCode.getPreAuthCode() + "&redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8"); if (StringUtils.isNotBlank(state)) { preAuthUrl += "&state=" + state; } return preAuthUrl; } @Override @SneakyThrows public String getPreAuthUrl(String redirectUri, String state, int authType) throws WxErrorException { String result = get(configStorage.getApiUrl(GET_PREAUTH_CODE), null); WxCpTpPreauthCode preAuthCode = WxCpTpPreauthCode.fromJson(result); String setSessionUrl = "https://qyapi.weixin.qq.com/cgi-bin/service/set_session_info"; Map<String, Object> sessionInfo = new HashMap<>(1); sessionInfo.put("auth_type", authType); Map<String, Object> param = new HashMap<>(2); param.put("pre_auth_code", preAuthCode.getPreAuthCode()); param.put("session_info", sessionInfo); String postData = new Gson().toJson(param); post(setSessionUrl, postData); String preAuthUrl = "https://open.work.weixin.qq.com/3rdapp/install?suite_id=" + configStorage.getSuiteId() + "&pre_auth_code=" + preAuthCode.getPreAuthCode() + "&redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8"); if (StringUtils.isNotBlank(state)) { preAuthUrl += "&state=" + state; } return preAuthUrl; } @Override public WxCpTpAuthInfo getAuthInfo(String authCorpId, String permanentCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_corpid", authCorpId); jsonObject.addProperty("permanent_code", permanentCode); String result = post(configStorage.getApiUrl(GET_AUTH_INFO), jsonObject.toString()); return WxCpTpAuthInfo.fromJson(result); } @Override public String get(String url, String queryParam) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam); } @Override public String get(String url, String queryParam, boolean withoutSuiteAccessToken) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam, withoutSuiteAccessToken); } @Override public String post(String url, String postData) throws WxErrorException { return execute(SimplePostRequestExecutor.create(this), url, postData, false); } /** * Post string. * * @param url the url * @param postData the post data * @param withoutSuiteAccessToken the without suite access token * @return the string * @throws WxErrorException the wx error exception */ @Override public String post(String url, String postData, boolean withoutSuiteAccessToken) throws WxErrorException { return execute(SimplePostRequestExecutor.create(this), url, postData, withoutSuiteAccessToken); } /** * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求. */ @Override public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { return execute(executor, uri, data, false); } /** * Execute t. * * @param <T> the type parameter * @param <E> the type parameter * @param executor the executor * @param uri the uri * @param data the data * @param withoutSuiteAccessToken the without suite access token * @return the t * @throws WxErrorException the wx error exception */ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data, boolean withoutSuiteAccessToken) throws WxErrorException { int retryTimes = 0; do { try { return this.executeInternal(executor, uri, data, withoutSuiteAccessToken); } catch (WxErrorException e) { if (retryTimes + 1 > this.maxRetryTimes) { log.warn("重试达到最大次数【{}】", this.maxRetryTimes); //最后一次重试失败后,直接抛出异常,不再等待 throw new WxRuntimeException("微信服务端异常,超出重试次数"); } WxError error = e.getError(); /* * -1 系统繁忙, 1000ms后重试 */ if (error.getErrorCode() == -1) { int sleepMillis = this.retrySleepMillis * (1 << retryTimes); try { log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); Thread.sleep(sleepMillis); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } } else { throw e; } } } while (retryTimes++ < this.maxRetryTimes); log.warn("重试达到最大次数【{}】", this.maxRetryTimes); throw new WxRuntimeException("微信服务端异常,超出重试次数"); } /** * Execute internal t. * * @param <T> the type parameter * @param <E> the type parameter * @param executor the executor * @param uri the uri * @param data the data * @return the t * @throws WxErrorException the wx error exception */ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { return executeInternal(executor, uri, data, false); } /** * Execute internal t. * * @param <T> the type parameter * @param <E> the type parameter * @param executor the executor * @param uri the uri * @param data the data * @param withoutSuiteAccessToken the without suite access token * @return the t * @throws WxErrorException the wx error exception */ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data, boolean withoutSuiteAccessToken) throws WxErrorException { E dataForLog = DataUtils.handleDataWithSecret(data); if (uri.contains("suite_access_token=")) { throw new IllegalArgumentException("uri参数中不允许有suite_access_token: " + uri); } String uriWithAccessToken; if (!withoutSuiteAccessToken) { String suiteAccessToken = getSuiteAccessToken(false); uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "suite_access_token=" + suiteAccessToken; } else { uriWithAccessToken = uri; } try { T result = executor.execute(uriWithAccessToken, data, WxType.CP); log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); return result; } catch (WxErrorException e) { WxError error = e.getError(); /* * 发生以下情况时尝试刷新suite_access_token * 42009 suite_access_token已过期 */ if (error.getErrorCode() == WxCpErrorMsgEnum.CODE_42009.getCode()) { // 强制设置wxCpTpConfigStorage它的suite access token过期了,这样在下一次请求里就会刷新suite access token this.configStorage.expireSuiteAccessToken(); if (this.configStorage.autoRefreshToken()) { log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg()); return this.execute(executor, uri, data); } } if (error.getErrorCode() != 0) { log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); throw new WxRuntimeException(e); } } @Override public void setWxCpTpConfigStorage(WxCpTpConfigStorage wxConfigProvider) { this.configStorage = wxConfigProvider; this.initHttp(); } @Override public void setRetrySleepMillis(int retrySleepMillis) { this.retrySleepMillis = retrySleepMillis; } @Override public void setMaxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; } /** * Gets tmp dir file. * * @return the tmp dir file */ public File getTmpDirFile() { return this.tmpDirFile; } /** * Sets tmp dir file. * * @param tmpDirFile the tmp dir file */ public void setTmpDirFile(File tmpDirFile) { this.tmpDirFile = tmpDirFile; } @Override public RequestHttp<?, ?> getRequestHttp() { return this; } @Override public WxSessionManager getSessionManager() { return this.sessionManager; } @Override public WxCpTpUserInfo getUserInfo3rd(String code) throws WxErrorException { String url = configStorage.getApiUrl(GET_USERINFO3RD); String result = get(url + "?code=" + code, null); return WxCpTpUserInfo.fromJson(result); } @Override public WxCpTpUserDetail getUserDetail3rd(String userTicket) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("user_ticket", userTicket); String result = post(configStorage.getApiUrl(GET_USERDETAIL3RD), jsonObject.toString()); return WxCpTpUserDetail.fromJson(result); } @Override public WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_code", authCode); String access_token = getWxCpProviderToken(); String responseText = post(configStorage.getApiUrl(GET_LOGIN_INFO) + "?access_token=" + access_token, jsonObject.toString(), true); return WxTpLoginInfo.fromJson(responseText); } @Override public WxTpCustomizedAuthUrl getCustomizedAuthUrl(String state, List<String> templateIdList) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("state", state); jsonObject.add("templateid_list", WxGsonBuilder.create().toJsonTree(templateIdList).getAsJsonArray()); String responseText = post(configStorage.getApiUrl(GET_CUSTOMIZED_AUTH_URL) + "?provider_access_token=" + getWxCpProviderToken(), jsonObject.toString(), true); return WxTpCustomizedAuthUrl.fromJson(responseText); } @Override public String getWxCpProviderToken() throws WxErrorException { if (this.configStorage.isProviderTokenExpired()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", configStorage.getCorpId()); jsonObject.addProperty("provider_secret", configStorage.getProviderSecret()); //providerAccessToken 的获取不需要suiteAccessToken ,一不必要,二可以提高效率 WxCpProviderToken wxCpProviderToken = WxCpProviderToken.fromJson(this.post(this.configStorage.getApiUrl(GET_PROVIDER_TOKEN) , jsonObject.toString(), true)); String providerAccessToken = wxCpProviderToken.getProviderAccessToken(); Integer expiresIn = wxCpProviderToken.getExpiresIn(); synchronized (globalProviderTokenRefreshLock) { configStorage.updateProviderToken(providerAccessToken, expiresIn - 200); } } return configStorage.getProviderToken(); } @Override public WxCpProviderToken getWxCpProviderTokenEntity() throws WxErrorException { return this.getWxCpProviderTokenEntity(false); } @Override public WxCpProviderToken getWxCpProviderTokenEntity(boolean forceRefresh) throws WxErrorException { if (forceRefresh) { this.configStorage.expireProviderToken(); } this.getWxCpProviderToken(); return this.configStorage.getProviderTokenEntity(); } @Override public WxCpTpContactService getWxCpTpContactService() { return wxCpTpContactService; } @Override public WxCpTpDepartmentService getWxCpTpDepartmentService() { return wxCpTpDepartmentService; } @Override public WxCpTpMediaService getWxCpTpMediaService() { return wxCpTpMediaService; } @Override public WxCpTpOAService getWxCpTpOAService() { return wxCpTpOAService; } @Override public WxCpTpUserService getWxCpTpUserService() { return wxCpTpUserService; } @Override public void setWxCpTpContactService(WxCpTpContactService wxCpTpContactService) { this.wxCpTpContactService = wxCpTpContactService; } @Override public void setWxCpTpDepartmentService(WxCpTpDepartmentService wxCpTpDepartmentService) { this.wxCpTpDepartmentService = wxCpTpDepartmentService; } @Override public void setWxCpTpMediaService(WxCpTpMediaService wxCpTpMediaService) { this.wxCpTpMediaService = wxCpTpMediaService; } @Override public void setWxCpTpOAService(WxCpTpOAService wxCpTpOAService) { this.wxCpTpOAService = wxCpTpOAService; } @Override public WxCpTpLicenseService getWxCpTpLicenseService() { return wxCpTpLicenseService; } @Override public void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService) { this.wxCpTpLicenseService = wxCpTpLicenseService; } @Override public void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService) { this.wxCpTpUserService = wxCpTpUserService; } /** * * @param encryptedXml the encrypted xml * @param timestamp the timestamp * @param nonce the nonce * @param msgSignature the msg signature * @return the wx cp tp xml message */ @Override public WxCpTpXmlMessage fromEncryptedXml(String encryptedXml, String timestamp, String nonce, String msgSignature) { return WxCpTpXmlMessage.fromEncryptedXml(encryptedXml,this.configStorage,timestamp,nonce,msgSignature); } @Override public String getVerifyDecrypt(String sVerifyEchoStr) { WxCpTpCryptUtil cryptUtil = new WxCpTpCryptUtil(this.configStorage); return cryptUtil.decrypt(sVerifyEchoStr); } @Override public WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("auth_corpid", authCorpId); jsonObject.addProperty("agentid", agentId); String result = post(configStorage.getApiUrl(GET_ADMIN_LIST), jsonObject.toString()); return WxCpTpAdmin.fromJson(result); } public WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("suite_id", suiteId); jsonObject.addProperty("appid", appId); jsonObject.addProperty("state", state); jsonObject.addProperty("style", style); jsonObject.addProperty("result_type", resultType); String result = post(configStorage.getApiUrl(GET_APP_QRCODE), jsonObject.toString()); return WxCpTpAppQrcode.fromJson(result); } public WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", corpId); String result = post(configStorage.getApiUrl(CORPID_TO_OPENCORPID) +"?provider_access_token=" + getWxCpProviderToken(), jsonObject.toString()); return WxCpTpCorpId2OpenCorpId.fromJson(result); } @Override public WxJsapiSignature createAuthCorpJsApiTicketSignature(String url, String authCorpId) throws WxErrorException { return doCreateWxJsapiSignature(url, authCorpId, this.getAuthCorpJsApiTicket(authCorpId)); } @Override public WxJsapiSignature createSuiteJsApiTicketSignature(String url, String authCorpId) throws WxErrorException { return doCreateWxJsapiSignature(url, authCorpId, this.getSuiteJsApiTicket(authCorpId)); } @Override public void expireSuiteAccessToken() { this.configStorage.expireSuiteAccessToken(); } @Override public void expireAccessToken(String authCorpId) { this.configStorage.expireAccessToken(authCorpId); } @Override public void expireAuthCorpJsApiTicket(String authCorpId) { this.configStorage.expireAuthCorpJsApiTicket(authCorpId); } @Override public void expireAuthSuiteJsApiTicket(String authCorpId) { this.configStorage.expireAuthSuiteJsApiTicket(authCorpId); } @Override public void expireProviderToken() { this.configStorage.expireProviderToken(); } @Override public WxCpTpOrderService getWxCpTpOrderService() { return wxCpTpOrderService; } @Override public void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService) { this.wxCpTpOrderService = wxCpTpOrderService; } @Override public WxCpTpEditionService getWxCpTpEditionService() { return wxCpTpEditionService; } @Override public void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService) { this.wxCpTpEditionService = wxCpTpEditionService; } private WxJsapiSignature doCreateWxJsapiSignature(String url, String authCorpId, String jsapiTicket) { long timestamp = System.currentTimeMillis() / 1000; String noncestr = RandomUtils.getRandomStr(); String signature = SHA1 .genWithAmple("jsapi_ticket=" + jsapiTicket, "noncestr=" + noncestr, "timestamp=" + timestamp, "url=" + url); WxJsapiSignature jsapiSignature = new WxJsapiSignature(); jsapiSignature.setTimestamp(timestamp); jsapiSignature.setNonceStr(noncestr); jsapiSignature.setUrl(url); jsapiSignature.setSignature(signature); jsapiSignature.setAppId(authCorpId); return jsapiSignature; } @Override public WxCpTpIdConvertService getWxCpTpIdConverService() { return wxCpTpIdConvertService; } @Override public void setWxCpTpIdConverService(WxCpTpIdConvertService wxCpTpIdConvertService) { this.wxCpTpIdConvertService = wxCpTpIdConvertService; } @Override public WxCpTpOAuth2Service getWxCpTpOAuth2Service() { return wxCpTpOAuth2Service; } @Override public void setWxCpTpOAuth2Service(WxCpTpOAuth2Service wxCpTpOAuth2Service) { this.wxCpTpOAuth2Service = wxCpTpOAuth2Service; } @Override public WxCpTpConfigStorage getWxCpTpConfigStorage() { return this.configStorage; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceJoddHttpImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceJoddHttpImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import jodd.http.HttpConnectionProvider; import jodd.http.HttpRequest; import jodd.http.HttpResponse; import jodd.http.ProxyInfo; import jodd.http.net.SocketHttpConnectionProvider; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; /** * The type Wx cp service jodd http. * * @author someone */ public class WxCpTpServiceJoddHttpImpl extends BaseWxCpTpServiceImpl<HttpConnectionProvider, ProxyInfo> { private HttpConnectionProvider httpClient; private ProxyInfo httpProxy; @Override public HttpConnectionProvider getRequestHttpClient() { return httpClient; } @Override public ProxyInfo getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.JODD_HTTP; } @Override public String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isSuiteAccessTokenExpired() && !forceRefresh) { return this.configStorage.getSuiteAccessToken(); } synchronized (this.globalSuiteAccessTokenRefreshLock) { // 构建请求 URL String url = this.configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("suite_id", this.configStorage.getSuiteId()); jsonObject.addProperty("suite_secret", this.configStorage.getSuiteSecret()); jsonObject.addProperty("suite_ticket", this.getSuiteTicket()); String jsonBody = jsonObject.toString(); if (this.httpProxy != null) { httpClient.useProxy(this.httpProxy); } // 创建 POST 请求 HttpRequest request = HttpRequest .post(url) .contentType("application/json") .body(jsonBody); // 使用 .body() 设置请求体 request.withConnectionProvider(httpClient); // 发送请求 HttpResponse response = request.send(); // 解析响应 String resultContent = response.bodyText(); WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } // 更新 access token jsonObject = GsonParser.parse(resultContent); String suiteAccussToken = jsonObject.get("suite_access_token").getAsString(); int expiresIn = jsonObject.get("expires_in").getAsInt(); this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn); } return this.configStorage.getSuiteAccessToken(); } @Override public void initHttp() { if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); } httpClient = new SocketHttpConnectionProvider(); } // // @Override // public WxCpConfigStorage getWxCpConfigStorage() { // return this.configStorage; // } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult; import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.PROLONG_TRY; /** * 应用版本付费版本相关接口实现 * * @author leigouqing created on 2022年4月24日 */ @RequiredArgsConstructor public class WxCpTpEditionServiceImpl implements WxCpTpEditionService { /** * The Main service. */ private final WxCpTpService mainService; /** * 延长试用期 * <p> * <a href='https://developer.work.weixin.qq.com/document/path/91913'>文档地址</a> * <p/> * <ul> * <li>一个应用可以多次延长试用,但是试用总天数不能超过60天</li> * <li>仅限时试用或试用过期状态下的应用可以延长试用期</li> * </ul> * * @param buyerCorpId 购买方corpId * @param prolongDays 延长天数 * @param appId 仅旧套件需要填此参数 * @return the order * @throws WxErrorException the wx error exception */ @Override public WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(PROLONG_TRY); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("buyer_corpid", buyerCorpId); jsonObject.addProperty("prolong_days", prolongDays); jsonObject.addProperty("appid", appId); String result = mainService.post(url, jsonObject.toString()); return WxCpTpProlongTryResult.fromJson(result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.bean.WxCpTpTag; import me.chanjar.weixin.cp.bean.WxCpTpTagAddOrRemoveUsersResult; import me.chanjar.weixin.cp.bean.WxCpTpTagGetResult; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import me.chanjar.weixin.cp.tp.service.WxCpTpTagService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tag.*; /** * <pre> * 企业微信第三方开发-标签相关接口,部分照搬了WxCpTagServiceImpl * </pre> * * @author zhangq <zhangq002@gmail.com> * @since 2021 -02-14 16:02 */ @RequiredArgsConstructor public class WxCpTpTagServiceImpl implements WxCpTpTagService { private final WxCpTpService mainService; @Override public String create(String name, Integer id) throws WxErrorException { JsonObject o = new JsonObject(); o.addProperty("tagname", name); if (id != null) { o.addProperty("tagid", id); } return this.create(o); } private String create(JsonObject param) throws WxErrorException { String url = getWxCpTpConfigStorage().getApiUrl(TAG_CREATE); String responseContent = this.mainService.post(url, param.toString()); JsonObject jsonObject = GsonParser.parse(responseContent); return jsonObject.get("tagid").getAsString(); } @Override public void update(String tagId, String tagName) throws WxErrorException { String url = getWxCpTpConfigStorage().getApiUrl(TAG_UPDATE); JsonObject o = new JsonObject(); o.addProperty("tagid", tagId); o.addProperty("tagname", tagName); this.mainService.post(url, o.toString()); } @Override public void delete(String tagId) throws WxErrorException { String url = String.format(getWxCpTpConfigStorage().getApiUrl(TAG_DELETE), tagId); this.mainService.get(url, null); } @Override public List<WxCpTpTag> listAll() throws WxErrorException { String url = getWxCpTpConfigStorage().getApiUrl(TAG_LIST); String responseContent = this.mainService.get(url, null); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("taglist"), new TypeToken<List<WxCpTpTag>>() { // do nothing }.getType()); } @Override public WxCpTpTagGetResult get(String tagId) throws WxErrorException { if (tagId == null) { throw new IllegalArgumentException("缺少tagId参数"); } String url = String.format(getWxCpTpConfigStorage().getApiUrl(TAG_GET), tagId); String responseContent = this.mainService.get(url, null); return WxCpTpTagGetResult.deserialize(responseContent); } @Override public WxCpTpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { String url = getWxCpTpConfigStorage().getApiUrl(TAG_ADD_TAG_USERS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("tagid", tagId); this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); return WxCpTpTagAddOrRemoveUsersResult.deserialize(this.mainService.post(url, jsonObject.toString())); } @Override public WxCpTpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { String url = getWxCpTpConfigStorage().getApiUrl(TAG_DEL_TAG_USERS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("tagid", tagId); this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); return WxCpTpTagAddOrRemoveUsersResult.deserialize(this.mainService.post(url, jsonObject.toString())); } private void addUserIdsAndPartyIdsToJson(List<String> userIds, List<String> partyIds, JsonObject jsonObject) { if (userIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("userlist", jsonArray); } if (partyIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : partyIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("partylist", jsonArray); } } @SuppressWarnings("deprecation") private WxCpTpConfigStorage getWxCpTpConfigStorage() { return this.mainService.getWxCpTpConfigStorage(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOAServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import lombok.NonNull; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult; import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest; import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult; import me.chanjar.weixin.cp.tp.service.WxCpTpOAService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信 OA 接口实现 * * @author Element created on 2019-04-06 11:20 */ @RequiredArgsConstructor public class WxCpTpOAServiceImpl implements WxCpTpOAService { private final WxCpTpService mainService; @Override public String apply(WxCpOaApplyEventRequest request, String corpId) throws WxErrorException { String url = mainService.getWxCpTpConfigStorage().getApiUrl(APPLY_EVENT) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, request.toJson()); return GsonParser.parse(responseContent).get("sp_no").getAsString(); } @Override public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id", templateId); String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class); } @Override public String copyTemplate(@NonNull String openTemplateId, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("open_template_id", openTemplateId); String url = mainService.getWxCpTpConfigStorage().getApiUrl(COPY_TEMPLATE) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); return GsonParser.parse(responseContent).get("template_id").getAsString(); } @Override public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("sp_no", spNo); final String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_APPROVAL_DETAIL) + "?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount; import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer; import me.chanjar.weixin.cp.bean.license.account.*; import me.chanjar.weixin.cp.bean.license.order.*; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import java.util.*; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.License.*; /** * The type Wx cp tp license service. * * @author Totoro created on 2022/6/27 11:03 */ @RequiredArgsConstructor public class WxCpTpLicenseServiceImpl implements WxCpTpLicenseService { private final WxCpTpService mainService; @Override public WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException { String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_NEW_ORDER) + getProviderAccessToken(), licenseNewOrderRequest.toJson()); return WxCpTpLicenseCreateOrderResp.fromJson(resultText); } @Override public WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException { String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_RENEW_ORDER_JOB) + getProviderAccessToken(), licenseRenewOrderJobRequest.toJson()); return WxCpTpLicenseRenewOrderJobResp.fromJson(resultText); } @Override public WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException { String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(SUBMIT_ORDER_JOB) + getProviderAccessToken(), licenseRenewOrderRequest.toJson()); return WxCpTpLicenseCreateOrderResp.fromJson(resultText); } @Override public WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, int limit) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("cursor", cursor); jsonObject.addProperty("limit", limit); if (startTime != null) { jsonObject.addProperty("start_time", startTime.getTime() / 1000); } if (endTime != null) { jsonObject.addProperty("end_time", endTime.getTime() / 1000); } String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseOrderListResp.fromJson(resultText); } @Override public WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("order_id", orderId); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ORDER) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseOrderInfoResp.fromJson(resultText); } @Override public WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("order_id", orderId); jsonObject.addProperty("cursor", cursor); jsonObject.addProperty("limit", limit); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER_ACCOUNT) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseOrderAccountListResp.fromJson(resultText); } @Override public WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("active_code", code); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("userid", userId); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(ACTIVE_ACCOUNT) + getProviderAccessToken(), jsonObject.toString()); return WxCpBaseResp.fromJson(resultText); } @Override public WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, List<WxCpTpLicenseActiveAccount> activeAccountList) throws WxErrorException { Map<String, Object> map = new HashMap<>(2); map.put("corpid", corpId); map.put("active_list", activeAccountList); GsonBuilder gsonBuilder = new GsonBuilder(); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_ACTIVE_ACCOUNT) + getProviderAccessToken(), gsonBuilder.create().toJson(map)); return WxCpTpLicenseBatchActiveResultResp.fromJson(resultText); } @Override public WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("active_code", code); jsonObject.addProperty("corpid", corpId); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_CODE) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseCodeInfoResp.fromJson(resultText); } @Override public WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection<String> codes, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); JsonArray list = new JsonArray(); for (String code : codes) { list.add(new JsonPrimitive(code)); } jsonObject.add("active_code_list", list); jsonObject.addProperty("corpid", corpId); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_GET_ACTIVE_INFO_BY_CODE) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseBatchCodeInfoResp.fromJson(resultText); } @Override public WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("cursor", cursor); jsonObject.addProperty("limit", limit); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ACTIVED_ACCOUNT) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseCorpAccountListResp.fromJson(resultText); } @Override public WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("userid", userId); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_USER) + getProviderAccessToken(), jsonObject.toString()); return WxCpTpLicenseActiveInfoByUserResp.fromJson(resultText); } @Override public WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List<WxCpTpLicenseTransfer> transferList) throws WxErrorException { Map<String, Object> map = new HashMap<>(2); map.put("corpid", corpId); map.put("transfer_list", transferList); GsonBuilder gsonBuilder = new GsonBuilder(); String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_TRANSFER_LICENSE) + getProviderAccessToken(), gsonBuilder.create().toJson(map)); return WxCpTpLicenseBatchTransferResp.fromJson(resultText); } /** * 获取服务商token的拼接参数 * * @return url * @throws WxErrorException / */ private String getProviderAccessToken() throws WxErrorException { return "?provider_access_token=" + mainService.getWxCpProviderToken(); } /** * 获取tp参数配置 * * @return config */ private WxCpTpConfigStorage getWxCpTpConfigStorage() { return mainService.getWxCpTpConfigStorage(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; /** * <pre> * 默认接口实现类,使用apache httpclient实现 * Created by zhenjun cai. * </pre> * * @author zhenjun cai */ public class WxCpTpServiceImpl extends WxCpTpServiceApacheHttpClientImpl { }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.hc.BasicResponseHandler; import me.chanjar.weixin.common.util.http.hc.DefaultHttpComponentsClientBuilder; import me.chanjar.weixin.common.util.http.hc.HttpComponentsClientBuilder; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.io.entity.StringEntity; import java.io.IOException; import java.nio.charset.StandardCharsets; /** * The type Wx cp tp service apache http client. * * @author altusea */ public class WxCpTpServiceHttpComponentsImpl extends BaseWxCpTpServiceImpl<CloseableHttpClient, HttpHost> { private CloseableHttpClient httpClient; private HttpHost httpProxy; @Override public CloseableHttpClient getRequestHttpClient() { return httpClient; } @Override public HttpHost getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.HTTP_COMPONENTS; } @Override public String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isSuiteAccessTokenExpired() && !forceRefresh) { return this.configStorage.getSuiteAccessToken(); } synchronized (this.globalSuiteAccessTokenRefreshLock) { try { HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN)); if (this.httpProxy != null) { RequestConfig config = RequestConfig.custom() .setProxy(this.httpProxy).build(); httpPost.setConfig(config); } JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("suite_id", this.configStorage.getSuiteId()); jsonObject.addProperty("suite_secret", this.configStorage.getSuiteSecret()); jsonObject.addProperty("suite_ticket", this.getSuiteTicket()); StringEntity entity = new StringEntity(jsonObject.toString(), StandardCharsets.UTF_8); httpPost.setEntity(entity); String resultContent = getRequestHttpClient().execute(httpPost, BasicResponseHandler.INSTANCE); WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } jsonObject = GsonParser.parse(resultContent); String suiteAccussToken = jsonObject.get("suite_access_token").getAsString(); int expiresIn = jsonObject.get("expires_in").getAsInt(); this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn); } catch (IOException e) { throw new WxRuntimeException(e); } } return this.configStorage.getSuiteAccessToken(); } @Override public void initHttp() { HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get(); apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost()) .httpProxyPort(this.configStorage.getHttpProxyPort()) .httpProxyUsername(this.configStorage.getHttpProxyUsername()) .httpProxyPassword(this.configStorage.getHttpProxyPassword().toCharArray()); if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(this.configStorage.getHttpProxyHost(), this.configStorage.getHttpProxyPort()); } this.httpClient = apacheHttpClientBuilder.build(); } // @Override // public WxCpTpConfigStorage getWxCpTpConfigStorage() { // return this.configStorage; // } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpDepartmentServiceImpl.java
package me.chanjar.weixin.cp.tp.service.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.impl.WxCpDepartmentServiceImpl; import me.chanjar.weixin.cp.bean.WxCpTpDepart; import me.chanjar.weixin.cp.tp.service.WxCpTpDepartmentService; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Department.*; /** * The type Wx cp tp department service. * * @author uianz * copy from {@link WxCpDepartmentServiceImpl )} 唯一不同在于获取部门列表时需要传对应企业的accessToken * @since 2020 /12/23 下午 02:39 */ @RequiredArgsConstructor public class WxCpTpDepartmentServiceImpl implements WxCpTpDepartmentService { private final WxCpTpService mainService; @Override public Long create(WxCpTpDepart depart) throws WxErrorException { String url = this.mainService.getWxCpTpConfigStorage().getApiUrl(DEPARTMENT_CREATE); String responseContent = this.mainService.post(url, depart.toJson()); JsonObject tmpJsonObject = GsonParser.parse(responseContent); return GsonHelper.getAsLong(tmpJsonObject.get("id")); } @Override public void update(WxCpTpDepart group) throws WxErrorException { String url = this.mainService.getWxCpTpConfigStorage().getApiUrl(DEPARTMENT_UPDATE); this.mainService.post(url, group.toJson()); } @Override public void delete(Long departId) throws WxErrorException { String url = String.format(this.mainService.getWxCpTpConfigStorage().getApiUrl(DEPARTMENT_DELETE), departId); this.mainService.get(url, null); } @Override public List<WxCpTpDepart> list(Long id, String corpId) throws WxErrorException { String url = this.mainService.getWxCpTpConfigStorage().getApiUrl(DEPARTMENT_LIST); url += "?access_token=" + this.mainService.getWxCpTpConfigStorage().getAccessToken(corpId); if (id != null) { url += "&id=" + id; } String responseContent = this.mainService.get(url, null); JsonObject tmpJsonObject = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson(tmpJsonObject.get("department"), new TypeToken<List<WxCpTpDepart>>() { }.getType() ); } @Override public List<WxCpTpDepart> list(String corpId) throws WxErrorException { return list(null, corpId); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageMatcher.java
package me.chanjar.weixin.cp.tp.message; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; /** * 消息匹配器,用在消息路由的时候 * * @author Daniel Qian */ public interface WxCpTpMessageMatcher { /** * 消息是否匹配某种模式 * * @param message the message * @return the boolean */ boolean match(WxCpTpXmlMessage message); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouter.java
package me.chanjar.weixin.cp.tp.message; import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.LogExceptionHandler; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.*; /** * <pre> * 微信消息路由器,通过代码化的配置,把来自微信的消息交给handler处理 * 和WxCpMessageRouter的rule相比,多了infoType和changeType维度的匹配 * * 说明: * 1. 配置路由规则时要按照从细到粗的原则,否则可能消息可能会被提前处理 * 2. 默认情况下消息只会被处理一次,除非使用 {@link WxCpTpMessageRouterRule#next()} * 3. 规则的结束必须用{@link WxCpTpMessageRouterRule#end()}或者{@link WxCpTpMessageRouterRule#next()},否则不会生效 * * 使用方法: * WxCpTpMessageRouter router = new WxCpTpMessageRouter(); * router * .rule() * .msgType("MSG_TYPE").event("EVENT").eventKey("EVENT_KEY").content("CONTENT") * .interceptor(interceptor, ...).handler(handler, ...) * .end() * .rule() * .infoType("INFO_TYPE").changeType("CHANGE_TYPE") * // 另外一个匹配规则 * .end() * ; * * // 将WxXmlMessage交给消息路由器 * router.route(message); * * </pre> * * @author Daniel Qian */ @Slf4j public class WxCpTpMessageRouter { private static final int DEFAULT_THREAD_POOL_SIZE = 100; private final List<WxCpTpMessageRouterRule> rules = new ArrayList<>(); private final WxCpTpService wxCpTpService; private ExecutorService executorService; private WxMessageDuplicateChecker messageDuplicateChecker; private WxSessionManager sessionManager; private WxErrorExceptionHandler exceptionHandler; /** * 构造方法. * * @param wxCpTpService the wx cp tp service */ public WxCpTpMessageRouter(WxCpTpService wxCpTpService) { this.wxCpTpService = wxCpTpService; ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxCpTpMessageRouter-pool-%d").build(); this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = wxCpTpService.getSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } /** * 使用自定义的 {@link ExecutorService}. * * @param wxCpTpService the wx cp tp service * @param executorService the executor service */ public WxCpTpMessageRouter(WxCpTpService wxCpTpService, ExecutorService executorService) { this.wxCpTpService = wxCpTpService; this.executorService = executorService; this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); this.sessionManager = wxCpTpService.getSessionManager(); this.exceptionHandler = new LogExceptionHandler(); } /** * 系统退出前,应该调用该方法 */ public void shutDownExecutorService() { this.executorService.shutdown(); } /** * 系统退出前,应该调用该方法,增加了超时时间检测 * * @param second the second */ public void shutDownExecutorService(Integer second) { this.executorService.shutdown(); try { if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { this.executorService.shutdownNow(); if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) log.error("线程池未关闭!"); } } catch (InterruptedException ie) { this.executorService.shutdownNow(); Thread.currentThread().interrupt(); } } /** * <pre> * 设置自定义的 {@link ExecutorService} * 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100) * </pre> * * @param executorService the executor service */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; } /** * <pre> * 设置自定义的 {@link WxMessageDuplicateChecker} * 如果不调用该方法,默认使用 {@link WxMessageInMemoryDuplicateChecker} * </pre> * * @param messageDuplicateChecker the message duplicate checker */ public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) { this.messageDuplicateChecker = messageDuplicateChecker; } /** * <pre> * 设置自定义的{@link WxSessionManager} * 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager} * </pre> * * @param sessionManager the session manager */ public void setSessionManager(WxSessionManager sessionManager) { this.sessionManager = sessionManager; } /** * <pre> * 设置自定义的{@link WxErrorExceptionHandler} * 如果不调用该方法,默认使用 {@link LogExceptionHandler} * </pre> * * @param exceptionHandler the exception handler */ public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } /** * Gets rules. * * @return the rules */ List<WxCpTpMessageRouterRule> getRules() { return this.rules; } /** * 开始一个新的Route规则. * * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule rule() { return new WxCpTpMessageRouterRule(this); } /** * 处理微信消息. * * @param suiteId the suiteId * @param wxMessage the wx message * @param context the context * @return the wx cp xml out message */ public WxCpXmlOutMessage route(final String suiteId, final WxCpTpXmlMessage wxMessage, final Map<String, Object> context) { if (isMsgDuplicated(suiteId, wxMessage)) { // 如果是重复消息,那么就不做处理 return null; } final List<WxCpTpMessageRouterRule> matchRules = new ArrayList<>(); // 收集匹配的规则 for (final WxCpTpMessageRouterRule rule : this.rules) { if (rule.test(wxMessage)) { matchRules.add(rule); if (!rule.isReEnter()) { break; } } } if (matchRules.isEmpty()) { return null; } WxCpXmlOutMessage res = null; final List<Future<?>> futures = new ArrayList<>(); for (final WxCpTpMessageRouterRule rule : matchRules) { // 返回最后一个非异步的rule的执行结果 if (rule.isAsync()) { futures.add( this.executorService.submit(() -> { rule.service(wxMessage, context, WxCpTpMessageRouter.this.wxCpTpService, WxCpTpMessageRouter.this.sessionManager, WxCpTpMessageRouter.this.exceptionHandler); }) ); } else { res = rule.service(wxMessage, context, this.wxCpTpService, this.sessionManager, this.exceptionHandler); // 在同步操作结束,session访问结束 log.debug("End session access: async=false, sessionId={}", wxMessage.getSuiteId()); sessionEndAccess(wxMessage); } } if (!futures.isEmpty()) { this.executorService.submit(() -> { for (Future<?> future : futures) { try { future.get(); log.debug("End session access: async=true, sessionId={}", wxMessage.getSuiteId()); // 异步操作结束,session访问结束 sessionEndAccess(wxMessage); } catch (InterruptedException e) { log.error("Error happened when wait task finish", e); Thread.currentThread().interrupt(); } catch (ExecutionException e) { log.error("Error happened when wait task finish", e); } } }); } return res; } /** * 处理微信消息. * * @param wxMessage the wx message * @param context the context * @return the wx cp xml out message */ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage, final Map<String, Object> context) { return this.route(null, wxMessage, context); } /** * 处理微信消息. * * @param wxMessage the wx message * @return the wx cp xml out message */ public WxCpXmlOutMessage route(final WxCpTpXmlMessage wxMessage) { return this.route(wxMessage, new HashMap<>(2)); } protected boolean isMsgDuplicated(final String suiteId, WxCpTpXmlMessage wxMessage) { StringBuilder messageId = new StringBuilder(); messageId.append(wxMessage.getToUserName()); if (wxMessage.getInfoType() != null) { messageId.append(wxMessage.getInfoType()) .append("-").append(StringUtils.trimToEmpty(wxMessage.getSuiteId())) .append("-").append(wxMessage.getTimeStamp()) .append("-").append(StringUtils.trimToEmpty(wxMessage.getAuthCorpId())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getUserID())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getChangeType())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getServiceCorpId())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getExternalUserID())); } else { if (StringUtils.isNotBlank(suiteId)) { messageId.append(suiteId); } } if (wxMessage.getMsgType() != null) { if (wxMessage.getMsgId() != null) { messageId.append(wxMessage.getMsgId()) .append("-").append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUserName()); } else { messageId.append(wxMessage.getMsgType()) .append("-").append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUserName()) .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey())) .append("-").append(StringUtils.trimToEmpty(wxMessage.getExternalUserID())); } } return this.messageDuplicateChecker.isDuplicate(messageId.toString()); } /** * 对session的访问结束. */ private void sessionEndAccess(WxCpTpXmlMessage wxMessage) { InternalSession session = ((InternalSessionManager) this.sessionManager).findSession(wxMessage.getSuiteId()); if (session != null) { session.endAccess(); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageInterceptor.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageInterceptor.java
package me.chanjar.weixin.cp.tp.message; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import java.util.Map; /** * 微信消息拦截器,可以用来做验证 * * @author Daniel Qian */ public interface WxCpTpMessageInterceptor { /** * 拦截微信消息 * * @param wxMessage the wx message * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 * @param wxCpService the wx cp service * @param sessionManager the session manager * @return true代表OK ,false代表不OK * @throws WxErrorException the wx error exception */ boolean intercept(WxCpTpXmlMessage wxMessage, Map<String, Object> context, WxCpTpService wxCpService, WxSessionManager sessionManager) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageHandler.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageHandler.java
package me.chanjar.weixin.cp.tp.message; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import java.util.Map; /** * 处理微信推送消息的处理器接口 * * @author Daniel Qian */ public interface WxCpTpMessageHandler { /** * Handle wx cp xml out message. * * @param wxMessage the wx message * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 * @param wxCpService the wx cp service * @param sessionManager the session manager * @return xml格式的消息 ,如果在异步规则里处理的话,可以返回null * @throws WxErrorException the wx error exception */ WxCpXmlOutMessage handle(WxCpTpXmlMessage wxMessage, Map<String, Object> context, WxCpTpService wxCpService, WxSessionManager sessionManager) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/message/WxCpTpMessageRouterRule.java
package me.chanjar.weixin.cp.tp.message; import lombok.Data; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage; import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage; import me.chanjar.weixin.cp.tp.service.WxCpTpService; import org.apache.commons.lang3.StringUtils; import java.util.*; import java.util.regex.Pattern; /** * The type Wx cp message router rule. * * @author Daniel Qian */ @Data public class WxCpTpMessageRouterRule { private final WxCpTpMessageRouter routerBuilder; private boolean async = true; private String fromUser; private String msgType; private String event; private String eventKey; private String eventKeyRegex; private String content; private String rContent; private WxCpTpMessageMatcher matcher; private boolean reEnter = false; private Integer agentId; private String infoType; private String changeType; private List<WxCpTpMessageHandler> handlers = new ArrayList<>(); private List<WxCpTpMessageInterceptor> interceptors = new ArrayList<>(); private String suiteId; private String authCode; private String suiteTicket; /** * Instantiates a new Wx cp message router rule. * * @param routerBuilder the router builder */ protected WxCpTpMessageRouterRule(WxCpTpMessageRouter routerBuilder) { this.routerBuilder = routerBuilder; } /** * 设置是否异步执行,默认是true * * @param async the async * @return the wx cp message router rule */ public WxCpTpMessageRouterRule async(boolean async) { this.async = async; return this; } /** * 如果msgType等于某值 * * @param msgType the msg type * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule msgType(String msgType) { this.msgType = msgType; return this; } /** * 如果event等于某值 * * @param event the event * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule event(String event) { this.event = event; return this; } /** * 匹配 Message infoType * * @param infoType info * @return the wx cp tp message router rule */ public WxCpTpMessageRouterRule infoType(String infoType) { this.infoType = infoType; return this; } /** * 如果changeType等于这个type,符合rule的条件之一 * * @param changeType the change type * @return wx cp tp message router rule */ public WxCpTpMessageRouterRule changeType(String changeType) { this.changeType = changeType; return this; } /** * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 * * @param matcher the matcher * @return the wx cp message router rule */ public WxCpTpMessageRouterRule matcher(WxCpTpMessageMatcher matcher) { this.matcher = matcher; return this; } /** * 设置微信消息拦截器 * * @param interceptor the interceptor * @return the wx cp message router rule */ public WxCpTpMessageRouterRule interceptor(WxCpTpMessageInterceptor interceptor) { return interceptor(interceptor, (WxCpTpMessageInterceptor[]) null); } /** * 设置微信消息拦截器 * * @param interceptor the interceptor * @param otherInterceptors the other interceptors * @return the wx cp message router rule */ public WxCpTpMessageRouterRule interceptor(WxCpTpMessageInterceptor interceptor, WxCpTpMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); if (otherInterceptors != null && otherInterceptors.length > 0) { Collections.addAll(this.interceptors, otherInterceptors); } return this; } /** * 设置微信消息处理器 * * @param handler the handler * @return the wx cp message router rule */ public WxCpTpMessageRouterRule handler(WxCpTpMessageHandler handler) { return handler(handler, (WxCpTpMessageHandler[]) null); } /** * 设置微信消息处理器 * * @param handler the handler * @param otherHandlers the other handlers * @return the wx cp message router rule */ public WxCpTpMessageRouterRule handler(WxCpTpMessageHandler handler, WxCpTpMessageHandler... otherHandlers) { this.handlers.add(handler); if (otherHandlers != null && otherHandlers.length > 0) { Collections.addAll(this.handlers, otherHandlers); } return this; } /** * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 * * @return the wx cp message router */ public WxCpTpMessageRouter end() { this.routerBuilder.getRules().add(this); return this.routerBuilder; } /** * 规则结束,但是消息还会进入其他规则 * * @return the wx cp message router */ public WxCpTpMessageRouter next() { this.reEnter = true; return end(); } /** * Test boolean. * * @param wxMessage the wx message * @return the boolean */ protected boolean test(WxCpTpXmlMessage wxMessage) { return (this.suiteId == null || this.suiteId.equals(wxMessage.getSuiteId())) && (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUserName())) && (this.agentId == null || this.agentId.equals(wxMessage.getAgentID())) && (this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType())) && (this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent())) && (this.infoType == null || this.infoType.equals(wxMessage.getInfoType())) && (this.suiteTicket == null || this.suiteTicket.equalsIgnoreCase(wxMessage.getSuiteTicket())) && (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey()))) && (this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent()))) && (this.rContent == null || Pattern.matches(this.rContent, StringUtils.trimToEmpty(wxMessage.getContent()))) && (this.infoType == null || this.infoType.equals(wxMessage.getInfoType())) && (this.changeType == null || this.changeType.equals(wxMessage.getChangeType())) && (this.matcher == null || this.matcher.match(wxMessage)) && (this.authCode == null || this.authCode.equalsIgnoreCase(wxMessage.getAuthCode())); } /** * 处理微信推送过来的消息 * * @param wxMessage the wx message * @param context the context * @param wxCpService the wx cp service * @param sessionManager the session manager * @param exceptionHandler the exception handler * @return true 代表继续执行别的router,false 代表停止执行别的router */ protected WxCpXmlOutMessage service(WxCpTpXmlMessage wxMessage, Map<String, Object> context, WxCpTpService wxCpService, WxSessionManager sessionManager, WxErrorExceptionHandler exceptionHandler) { if (context == null) { context = new HashMap<>(2); } try { // 如果拦截器不通过 for (WxCpTpMessageInterceptor interceptor : this.interceptors) { if (!interceptor.intercept(wxMessage, context, wxCpService, sessionManager)) { return null; } } // 交给handler处理 WxCpXmlOutMessage res = null; for (WxCpTpMessageHandler handler : this.handlers) { // 返回最后handler的结果 res = handler.handle(wxMessage, context, wxCpService, sessionManager); } return res; } catch (WxErrorException e) { exceptionHandler.handle(e); } return null; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; /** * 企业微信自建应用接口. * https://developer.work.weixin.qq.com/document/path/90269 * * @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a> created on 2022-04-06 */ public interface WxCpOaAgentService { /** * 查询第三方应用审批申请当前状态 * 开发者也可主动查询审批单的当前审批状态。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata?access_token=ACCESS_TOKEN * * @param thirdNo the third no * @return open approval data * @throws WxErrorException the wx error exception */ WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.bean.menu.WxMenu; import me.chanjar.weixin.common.error.WxErrorException; /** * <pre> * 菜单管理相关接口 * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpMenuService { /** * <pre> * 自定义菜单创建接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口 * * 注意: 这个方法使用WxCpConfigStorage里的agentId * </pre> * * @param menu 菜单对象 * @throws WxErrorException the wx error exception * @see #create(Integer, WxMenu) #create(Integer, WxMenu) */ void create(WxMenu menu) throws WxErrorException; /** * <pre> * 自定义菜单创建接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口 * * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 * </pre> * * @param agentId 企业号应用的id * @param menu 菜单对象 * @throws WxErrorException the wx error exception * @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) #create(me.chanjar.weixin.common.bean.menu.WxMenu) */ void create(Integer agentId, WxMenu menu) throws WxErrorException; /** * <pre> * 自定义菜单删除接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口 * * 注意: 这个方法使用WxCpConfigStorage里的agentId * </pre> * * @throws WxErrorException the wx error exception * @see #delete(Integer) #delete(Integer) */ void delete() throws WxErrorException; /** * <pre> * 自定义菜单删除接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口 * * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 * </pre> * * @param agentId 企业号应用的id * @throws WxErrorException the wx error exception * @see #delete() #delete() */ void delete(Integer agentId) throws WxErrorException; /** * <pre> * 自定义菜单查询接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口 * * 注意: 这个方法使用WxCpConfigStorage里的agentId * </pre> * * @return the wx menu * @throws WxErrorException the wx error exception * @see #get(Integer) #get(Integer) */ WxMenu get() throws WxErrorException; /** * <pre> * 自定义菜单查询接口 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口 * * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 * </pre> * * @param agentId 企业号应用的id * @return the wx menu * @throws WxErrorException the wx error exception * @see #get() #get() */ WxMenu get(Integer agentId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlReq; import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlResult; import java.io.File; import java.io.IOException; import java.io.InputStream; /** * <pre> * 媒体管理接口. * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpMediaService { /** * <pre> * 上传多媒体文件. * 上传的多媒体文件有格式和大小限制,如下: * 图片(image): 1M,支持JPG格式 * 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 * 视频(video):10MB,支持MP4格式 * 缩略图(thumb):64KB,支持JPG格式 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 * </pre> * * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} * @param inputStream 输入流,需要调用方控制关闭该输入流 * @return the wx media upload result * @throws WxErrorException the wx error exception * @throws IOException the io exception */ WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException; /** * <pre> * 上传多媒体文件. * </pre> * * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param filename 文件名.例如:wework.txt * @param url 远程链接 * @return wx media upload result * @throws WxErrorException the wx error exception * @throws IOException the io exception */ WxMediaUploadResult upload(String mediaType, String filename, String url) throws WxErrorException, IOException; /** * <pre> * 上传多媒体文件. * </pre> * * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param file 文件对象, 上传的文件内容 * @param filename 上传内容的实际文件名.例如:wework.txt * @return wx media upload result * @throws WxErrorException the wx error exception */ WxMediaUploadResult upload(String mediaType, File file, String filename) throws WxErrorException; /** * <pre> * 上传多媒体文件. * </pre> * * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} * @param inputStream 上传的文件内容 * @param filename 上传内容的实际文件名.例如:wework.txt * @return wx media upload result * @throws WxErrorException the wx error exception */ WxMediaUploadResult upload(String mediaType, InputStream inputStream, String filename) throws WxErrorException; /** * 上传多媒体文件. * * @param mediaType 媒体类型 * @param file 文件对象 * @return the wx media upload result * @throws WxErrorException the wx error exception * @see #upload(String, String, InputStream) #upload(String, String, InputStream) */ WxMediaUploadResult upload(String mediaType, File file) throws WxErrorException; /** * <pre> * 下载多媒体文件. * 根据微信文档,视频文件下载不了,会返回null * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 * </pre> * * @param mediaId 媒体id * @return 保存到本地的临时文件 file * @throws WxErrorException the wx error exception */ File download(String mediaId) throws WxErrorException; /** * <pre> * 获取高清语音素材. * 可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K采样率。该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音识别等对音质要求较高的业务。 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID * 仅企业微信2.4及以上版本支持。 * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90255 * </pre> * * @param mediaId 媒体id * @return 保存到本地的临时文件 jssdk file * @throws WxErrorException the wx error exception */ File getJssdkFile(String mediaId) throws WxErrorException; /** * <pre> * 上传图片. * 上传图片得到图片URL,该URL永久有效 * 返回的图片URL,仅能用于图文消息(mpnews)正文中的图片展示;若用于非企业微信域名下的页面,图片将被屏蔽。 * 每个企业每天最多可上传100张图片 * 接口url格式:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN * </pre> * * @param file 上传的文件对象 * @return 返回图片url string * @throws WxErrorException the wx error exception */ String uploadImg(File file) throws WxErrorException; /** * 生成异步上传任务 * 跟上传临时素材拿到的media_id使用场景是不通用的,目前适配的接口如下:https://developer.work.weixin.qq.com/document/path/96488#%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E8%AF%B4%E6%98%8E * @param req 请求参数 * @return 返回异步任务id * @throws WxErrorException the wx error exception */ String uploadByUrl(MediaUploadByUrlReq req) throws WxErrorException; /** * 查询异步任务结果 * @param jobId 任务id。最长为128字节,60分钟内有效 * @return 返回异步任务结果 * @throws WxErrorException the wx error exception */ MediaUploadByUrlResult uploadByUrl(String jobId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentWorkBenchService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpAgentWorkBench; /** * The interface Wx cp agent work bench service. * <a href="https://work.weixin.qq.com/api/doc/90000/90135/92535">工作台自定义展示</a> * * @author songshiyu * created on 16:16 2020/9/27 */ public interface WxCpAgentWorkBenchService { /** * Sets work bench template. * * @param wxCpAgentWorkBench the wx cp agent work bench * @throws WxErrorException the wx error exception */ void setWorkBenchTemplate(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException; /** * Gets work bench template. * * @param agentid the agentid * @return the work bench template * @throws WxErrorException the wx error exception */ String getWorkBenchTemplate(Long agentid) throws WxErrorException; /** * Sets work bench data. * * @param wxCpAgentWorkBench the wx cp agent work bench * @throws WxErrorException the wx error exception */ void setWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException; /** * Batch sets work bench data. * * @param wxCpAgentWorkBench the wx cp agent work bench * @throws WxErrorException the wx error exception */ void batchSetWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaCalendarService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.calendar.WxCpOaCalendar; import java.util.List; /** * 企业微信日历接口. * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020-09-20 */ public interface WxCpOaCalendarService { /** * 创建日历. * <pre> * 该接口用于通过应用在企业内创建一个日历。 * 注: 企业微信需要更新到3.0.2及以上版本 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/add?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92618 * </pre> * * @param calendar 日历对象 * @return 日历ID string * @throws WxErrorException . */ String add(WxCpOaCalendar calendar) throws WxErrorException; /** * 更新日历. * <pre> * 该接口用于修改指定日历的信息。 * 注意,更新操作是覆盖式,而不是增量式 * 企业微信需要更新到3.0.2及以上版本 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/update?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92619 * </pre> * * @param calendar 日历对象 * @throws WxErrorException . */ void update(WxCpOaCalendar calendar) throws WxErrorException; /** * 获取日历. * <pre> * 该接口用于获取应用在企业内创建的日历信息。 * * 注: 企业微信需要更新到3.0.2及以上版本 * * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/get?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92621 * </pre> * * @param calIds 日历id列表 * @return 日历对象列表 list * @throws WxErrorException . */ List<WxCpOaCalendar> get(List<String> calIds) throws WxErrorException; /** * 删除日历. * <pre> * 该接口用于删除指定日历。 * 注: 企业微信需要更新到3.0.2及以上版本 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/del?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92620 * </pre> * * @param calId 日历id * @throws WxErrorException . */ void delete(String calId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTagService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpTag; import me.chanjar.weixin.cp.bean.WxCpTagAddOrRemoveUsersResult; import me.chanjar.weixin.cp.bean.WxCpTagGetResult; import me.chanjar.weixin.cp.bean.WxCpUser; import java.util.List; /** * <pre> * 标签管理接口. * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpTagService { /** * 创建标签. * <pre> * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90210 * </pre> * * @param name 标签名称,长度限制为32个字以内(汉字或英文字母),标签名不可与其他标签重名。 * @param id 标签id,非负整型,指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。 * @return 标签id string * @throws WxErrorException . */ String create(String name, Integer id) throws WxErrorException; /** * 更新标签. * * @param tagId 标签id * @param tagName 标签名 * @throws WxErrorException . */ void update(String tagId, String tagName) throws WxErrorException; /** * 删除标签. * * @param tagId 标签id * @throws WxErrorException . */ void delete(String tagId) throws WxErrorException; /** * 获得标签列表. * * @return 标签列表 list * @throws WxErrorException . */ List<WxCpTag> listAll() throws WxErrorException; /** * 获取标签成员. * * @param tagId 标签ID * @return 成员列表 list * @throws WxErrorException . */ List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException; /** * 获取标签成员. * 对应: http://qydev.weixin.qq.com/wiki/index.php?title=管理标签 中的get接口 * * @param tagId 标签id * @return . wx cp tag get result * @throws WxErrorException . */ WxCpTagGetResult get(String tagId) throws WxErrorException; /** * 增加标签成员. * * @param tagId 标签id * @param userIds 用户ID 列表 * @param partyIds 企业部门ID列表 * @return . wx cp tag add or remove users result * @throws WxErrorException . */ WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; /** * 移除标签成员. * * @param tagId 标签id * @param userIds 用户id列表 * @param partyIds 企业部门ID列表 * @return . wx cp tag add or remove users result * @throws WxErrorException . */ WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java
package me.chanjar.weixin.cp.api; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.List; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.external.*; import me.chanjar.weixin.cp.bean.external.acquisition.*; import me.chanjar.weixin.cp.bean.external.contact.*; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleInfo; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleList; /** * <pre> * 外部联系人管理接口,企业微信的外部联系人的接口和通讯录接口已经拆离 * Created by Joe Cao on 2019/6/14 * </pre> * * @author <a href="https://github.com/JoeCao">JoeCao</a> */ public interface WxCpExternalContactService { /** * 配置客户联系「联系我」方式 * <pre> * 企业可以在管理后台-客户联系中配置成员的「联系我」的二维码或者小程序按钮,客户通过扫描二维码或点击小程序上的按钮,即可获取成员联系方式,主动联系到成员。 * 企业可通过此接口为具有客户联系功能的成员生成专属的「联系我」二维码或者「联系我」按钮。 * 如果配置的是「联系我」按钮,需要开发者的小程序接入小程序插件。 * * 注意: * 通过API添加的「联系我」不会在管理端进行展示,每个企业可通过API最多配置50万个「联系我」。 * 用户需要妥善存储返回的config_id,config_id丢失可能导致用户无法编辑或删除「联系我」。 * 临时会话模式不占用「联系我」数量,但每日最多添加10万个,并且仅支持单人。 * 临时会话模式的二维码,添加好友完成后该二维码即刻失效。 * <a href="https://developer.work.weixin.qq.com/document/path/92228">文档地址</a> * </pre> * * @param info 客户联系「联系我」方式 * @return wx cp contact way result * @throws WxErrorException the wx error exception */ WxCpContactWayResult addContactWay(WxCpContactWayInfo info) throws WxErrorException; /** * 获取企业已配置的「联系我」方式 * * <pre> * <b>批量</b>获取企业配置的「联系我」二维码和「联系我」小程序按钮。 * </pre> * * @param configId 联系方式的配置id,必填 * @return contact way * @throws WxErrorException the wx error exception */ WxCpContactWayInfo getContactWay(String configId) throws WxErrorException; /** * 获取企业已配置的「联系我」列表 * * <pre> * 获取企业配置的「联系我」二维码和「联系我」小程序插件列表。不包含临时会话。 * 注意,<b>该接口仅可获取2021年7月10日以后创建的「联系我」</b> * </pre> * * 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/92228#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E5%88%97%E8%A1%A8">获取企业已配置的「联系我」列表</a> * * @param startTime 「联系我」创建起始时间戳, 默认为90天前 * @param endTime 「联系我」创建结束时间戳, 默认为当前时间 * @param cursor 分页查询使用的游标,为上次请求返回的 next_cursor * @param limit 每次查询的分页大小,默认为100条,最多支持1000条 * @return contact way configId * @throws WxErrorException the wx error exception */ WxCpContactWayList listContactWay(Long startTime, Long endTime, String cursor, Long limit) throws WxErrorException; /** * 更新企业已配置的「联系我」方式 * * <pre> * 更新企业配置的「联系我」二维码和「联系我」小程序按钮中的信息,如使用人员和备注等。 * </pre> * * @param info 客户联系「联系我」方式 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException; /** * 删除企业已配置的「联系我」方式 * * <pre> * 删除一个已配置的「联系我」二维码或者「联系我」小程序按钮。 * </pre> * * @param configId 企业联系方式的配置id,必填 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp deleteContactWay(String configId) throws WxErrorException; /** * 结束临时会话 * * <pre> * 将指定的企业成员和客户之前的临时会话断开,断开前会自动下发已配置的结束语。 * * 注意:请保证传入的企业成员和客户之间有仍然有效的临时会话, 通过<b>其他方式的添加外部联系人无法通过此接口关闭会话</b>。 * </pre> * * @param userId the user id * @param externalUserId the external user id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp closeTempChat(String userId, String externalUserId) throws WxErrorException; /** * 获取外部联系人详情. * <pre> * 企业可通过此接口,根据外部联系人的userid,拉取外部联系人详情。权限说明: * 企业需要使用外部联系人管理secret所获取的accesstoken来调用 * 第三方应用需拥有“企业客户”权限。 * 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * </pre> * * @param externalUserId 外部联系人的userid * @return . external contact * @throws WxErrorException the wx error exception * @deprecated 建议使用 {@link #getContactDetail(String, String)} */ @Deprecated WxCpExternalContactInfo getExternalContact(String externalUserId) throws WxErrorException; /** * 获取客户详情. * <pre> * * 企业可通过此接口,根据外部联系人的userid(如何获取?),拉取客户详情。 * * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID * * 权限说明: * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?); * 第三方/自建应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * </pre> * * @param externalUserId 外部联系人的userid,注意不是企业成员的帐号 * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 * @return . contact detail * @throws WxErrorException . */ WxCpExternalContactInfo getContactDetail(String externalUserId, String cursor) throws WxErrorException; /** * 企业和服务商可通过此接口,将微信外部联系人的userid转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。 * * @param externalUserid 微信外部联系人的userid * @return 该企业的外部联系人openid string * @throws WxErrorException . */ String convertToOpenid(String externalUserid) throws WxErrorException; /** * 服务商为企业代开发微信小程序的场景,服务商可通过此接口,将微信客户的unionid转为external_userid。 * <pre> * * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/93274 * * 服务商代开发小程序指企业使用的小程序为企业主体的,非服务商主体的小程序。 * 场景:企业客户在微信端从企业主体的小程序(非服务商应用)登录,同时企业在企业微信安装了服务商的第三方应用,服务商可以调用该接口将登录用户的unionid转换为服务商全局唯一的外部联系人id * * 权限说明: * * 仅认证企业可调用 * unionid必须是企业主体下的unionid。即unionid的主体(为绑定了该小程序的微信开放平台账号主体)需与当前企业的主体一致。 * unionid的主体(即微信开放平台账号主体)需认证 * 该客户的跟进人必须在应用的可见范围之内 * </pre> * * @param unionid 微信客户的unionid * @param openid the openid * @return 该企业的外部联系人ID string * @throws WxErrorException . */ String unionidToExternalUserid(String unionid, String openid) throws WxErrorException; /** * 配置客户群进群方式 * 企业可以在管理后台-客户联系中配置「加入群聊」的二维码或者小程序按钮,客户通过扫描二维码或点击小程序上的按钮,即可加入特定的客户群。 * 企业可通过此接口为具有客户联系功能的成员生成专属的二维码或者小程序按钮。 * 如果配置的是小程序按钮,需要开发者的小程序接入小程序插件。 * 注意: * 通过API添加的配置不会在管理端进行展示,每个企业可通过API最多配置50万个「加入群聊」(与「联系我」共用50万的额度)。 * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 * * @param wxCpGroupJoinWayInfo the wx cp group join way info * @return {@link WxCpGroupJoinWayResult} * @throws WxErrorException the wx error exception */ WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException; /** * 更新客户群进群方式配置 * 更新进群方式配置信息。注意:使用覆盖的方式更新。 * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 * * @param wxCpGroupJoinWayInfo the wx cp group join way info * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp updateJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException; /** * 获取客户群进群方式配置 * 获取企业配置的群二维码或小程序按钮。 * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 * * @param configId the config id * @return join way * @throws WxErrorException the wx error exception */ WxCpGroupJoinWayInfo getJoinWay(String configId) throws WxErrorException; /** * 删除客户群进群方式配置 * 文档地址:https://developer.work.weixin.qq.com/document/path/92229 * * @param configId the config id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp delJoinWay(String configId) throws WxErrorException; /** * 代开发应用external_userid转换 * <pre> * * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/95195 * * 企业同时安装服务商第三方应用以及授权代开发自建应用的时,服务商可使用该接口将代开发应用获取到的外部联系人id跟第三方应用的id进行关联, * 该接口可将代开发自建应用获取到的external_userid转换为服务商第三方应用的external_userid。 * * 权限说明: * * 该企业授权了该服务商第三方应用,且授权的第三方应用具备“企业客户权限->客户基础信息”权限 * 该客户的跟进人必须在应用的可见范围之内 * 应用需具备“企业客户权限->客户基础信息”权限 * </pre> * * @param externalUserid 代开发自建应用获取到的外部联系人ID * @return 该服务商第三方应用下的企业的外部联系人ID string * @throws WxErrorException . */ String toServiceExternalUserid(String externalUserid) throws WxErrorException; /** * 将代开发应用或第三方应用获取的externaluserid转换成自建应用的externaluserid * <pre> * 文档地址:https://developer.work.weixin.qq.com/document/path/95884#external-userid%E8%BD%AC%E6%8D%A2 * * 权限说明: * * 需要使用自建应用或基础应用的access_token * 客户的跟进人,或者用户所在客户群的群主,需要同时在access_token和source_agentid所对应应用的可见范围内 * </pre> * * @param externalUserid 服务商主体的external_userid,必须是source_agentid对应的应用所获取 * @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid * @return * @throws WxErrorException */ String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException; /** * 企业客户微信unionid的升级 - unionid查询external_userid * <pre> * * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid * * 当微信用户在微信中使用第三方应用的小程序或公众号时,第三方可将获取到的unionid与openid,调用此接口转换为企业客户external_userid。 * 该接口调用频次有限,每个服务商每小时仅可调用1万次,仅用于微信用户主动使用第三方应用的场景来调用,服务商切不可滥用。 * 同时建议服务商的小程序路径或公众号页面链接带上corpid参数,如此可明确地转换出该企业对应的external_userid,以获得更好的性能。 * * 权限说明: * * 该企业授权了该服务商第三方应用 * 调用频率最大为10000次/小时 * unionid和openid的主体需与服务商的主体一致 * openid与unionid必须是在同一个小程序或同一个公众号获取到的 * </pre> * * @param unionid 微信客户的unionid * @param openid 微信客户的openid * @param corpid 需要换取的企业corpid,不填则拉取所有企业 * @return 该服务商第三方应用下的企业的外部联系人ID wx cp external user id list * @throws WxErrorException . */ WxCpExternalUserIdList unionidToExternalUserid3rd(String unionid, String openid, String corpid) throws WxErrorException; /** * 转换external_userid * <pre> * * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#转换external_userid * * 对于历史已授权的企业,在2022年3月1号之前,所有接口与回调返回的external_userid仍然为旧的external_userid, * 从2022年3月1号0点开始,所有输入与返回的external_userid字段,将启用升级后的external_userid。 * 所以服务商需要在此之前完成历史数据的迁移整改 * * 权限说明: * * 该企业授权了该服务商第三方应用 * external_userid对应的跟进人需要在应用可见范围内 * </pre> * * @param externalUserIdList 微信客户的unionid * @return List<String> 新外部联系人id * @throws WxErrorException . */ WxCpNewExternalUserIdList getNewExternalUserId(String[] externalUserIdList) throws WxErrorException; /** * 设置迁移完成 * <pre> * * 文档地址:https://open.work.weixin.qq.com/api/doc/35863#转换external_userid * * 企业授权确认之后,且服务商完成了新旧external_userid的迁移,即可主动将该企业设置为“迁移完成”, * 设置之后,从该企业获取到的将是新的external_userid。注意,该接口需要使用provider_access_token来调用, * 对于有多个应用的服务商,可逐个应用进行external_userid的转换,最后再使用provider_access_token调用该接口完成设置。 * * 权限说明: * * 该企业授权了该服务商第三方应用 * </pre> * * @param corpid 企业corpid * @return wx cp base resp * @throws WxErrorException . */ WxCpBaseResp finishExternalUserIdMigration(String corpid) throws WxErrorException; /** * 客户群opengid转换 * <pre> * * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/94822 * * 用户在微信里的客户群里打开小程序时,某些场景下可以获取到群的opengid,如果该群是企业微信的客户群, * 则企业或第三方可以调用此接口将一个opengid转换为客户群chat_id * * 权限说明: * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?) * 第三方应用需具有“企业客户权限->客户基础信息”权限 * 对于第三方/自建应用,群主必须在应用的可见范围 * 仅支持企业服务人员创建的客户群 * 仅可转换出自己企业下的客户群chat_id * </pre> * * @param opengid 小程序在微信获取到的群ID,参见wx.getGroupEnterInfo(https://developers.weixin.qq * .com/miniprogram/dev/api/open-api/group/wx.getGroupEnterInfo.html) * @return 客户群ID ,可以用来调用获取客户群详情 * @throws WxErrorException . */ String opengidToChatid(String opengid) throws WxErrorException; /** * 批量获取客户详情. * <pre> * * 企业/第三方可通过此接口获取指定成员添加的客户信息列表。 * * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=ACCESS_TOKEN * * 权限说明: * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?); * 第三方/自建应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * </pre> * * @param userIdList 企业成员的userid列表,注意不是外部联系人的帐号 * @param cursor the cursor * @param limit the limit * @return wx cp user external contact batch info * @throws WxErrorException . */ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String cursor, Integer limit) throws WxErrorException; /** * 获取已服务的外部联系人 * <pre> * 企业可通过此接口获取所有已服务的外部联系人,及其添加人和加入的群聊。 * 外部联系人分为客户和其他外部联系人,如果是客户,接口将返回外部联系人临时ID和externaluserid;如果是其他外部联系人,接口将只返回外部联系人临时ID。 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/contact_list?access_token=ACCESS_TOKEN * 文档地址: https://developer.work.weixin.qq.com/document/path/99434 * </pre> * * @param cursor the cursor * @param limit the limit * @return 已服务的外部联系人列表 * @throws WxErrorException . * @apiNote 企业可通过外部联系人临时ID排除重复数据,外部联系人临时ID有效期为4小时。 */ WxCpExternalContactListInfo getContactList(String cursor, Integer limit) throws WxErrorException; /** * 修改客户备注信息. * <pre> * 企业可通过此接口修改指定用户添加的客户的备注信息。 * 请求方式: POST(HTTP) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92115 * </pre> * * @param request 备注信息请求 * @throws WxErrorException . */ void updateRemark(WxCpUpdateRemarkRequest request) throws WxErrorException; /** * 获取客户列表. * <pre> * 企业可通过此接口获取指定成员添加的客户列表。客户是指配置了客户联系功能的成员所添加的外部联系人。没有配置客户联系功能的成员,所添加的外部联系人将不会作为客户返回。 * * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=ACCESS_TOKEN&userid=USERID * * 权限说明: * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?); * 第三方应用需拥有“企业客户”权限。 * 第三方/自建应用只能获取到可见范围内的配置了客户联系功能的成员。 * </pre> * * @param userId 企业成员的userid * @return List of External wx id * @throws WxErrorException . */ List<String> listExternalContacts(String userId) throws WxErrorException; /** * 企业和第三方服务商可通过此接口获取配置了客户联系功能的成员(Customer Contact)列表。 * <pre> * 企业需要使用外部联系人管理secret所获取的accesstoken来调用(accesstoken如何获取?); * 第三方应用需拥有“企业客户”权限。 * 第三方应用只能获取到可见范围内的配置了客户联系功能的成员 * </pre> * * @return List of CpUser id * @throws WxErrorException . */ List<String> listFollowers() throws WxErrorException; /** * 获取待分配的离职成员列表 * 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用分配离职成员的客户接口将这些客户重新分配给其他企业成员。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_unassigned_list?access_token=ACCESS_TOKEN * * @param pageId 分页查询,要查询页号,从0开始 * @param cursor 分页查询游标,字符串类型,适用于数据量较大的情况,如果使用该参数则无需填写page_id,该参数由上一次调用返回 * @param pageSize 每次返回的最大记录数,默认为1000,最大值为1000 * @return wx cp user external unassign list * @throws WxErrorException the wx error exception */ WxCpUserExternalUnassignList listUnassignedList(Integer pageId, String cursor, Integer pageSize) throws WxErrorException; /** * 企业可通过此接口,将已离职成员的外部联系人分配给另一个成员接替联系。 * * @param externalUserid the external userid * @param handOverUserid the hand over userid * @param takeOverUserid the take over userid * @return wx cp base resp * @throws WxErrorException the wx error exception * @deprecated 此后续将不再更新维护, 建议使用 {@link #transferCustomer(WxCpUserTransferCustomerReq)} */ @Deprecated WxCpBaseResp transferExternalContact(String externalUserid, String handOverUserid, String takeOverUserid) throws WxErrorException; /** * 企业可通过此接口,转接在职成员的客户给其他成员。 * <per> * external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。 * 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。 * <p> * 权限说明: * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限 * 接替成员必须在此第三方应用或自建应用的可见范围内。 * 接替成员需要配置了客户联系功能。 * 接替成员需要在企业微信激活且已经过实名认证。 * </per> * * @param req 转接在职成员的客户给其他成员请求实体 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpUserTransferCustomerResp transferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException; /** * 企业和第三方可通过此接口查询在职成员的客户转接情况。 * <per> * 权限说明: * <p> * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限 * 接替成员必须在此第三方应用或自建应用的可见范围内。 * </per> * * @param handOverUserid 原添加成员的userid * @param takeOverUserid 接替成员的userid * @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页; * @return 客户转接接口实体 wx cp user transfer result resp * @throws WxErrorException the wx error exception */ WxCpUserTransferResultResp transferResult(String handOverUserid, String takeOverUserid, String cursor) throws WxErrorException; /** * 企业可通过此接口,分配离职成员的客户给其他成员。 * <per> * handover_userid必须是已离职用户。 * external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。 * 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。 * <p> * 权限说明: * <p> * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 第三方应用需拥有“企业客户权限->客户联系->离职分配”权限 * 接替成员必须在此第三方应用或自建应用的可见范围内。 * 接替成员需要配置了客户联系功能。 * 接替成员需要在企业微信激活且已经过实名认证。 * </per> * * @param req 转接在职成员的客户给其他成员请求实体 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException; /** * 企业和第三方可通过此接口查询离职成员的客户分配情况。 * <per> * 权限说明: * <p> * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限 * 接替成员必须在此第三方应用或自建应用的可见范围内。 * </per> * * @param handOverUserid 原添加成员的userid * @param takeOverUserid 接替成员的userid * @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页; * @return 客户转接接口实体 wx cp user transfer result resp * @throws WxErrorException the wx error exception */ WxCpUserTransferResultResp resignedTransferResult(String handOverUserid, String takeOverUserid, String cursor) throws WxErrorException; /** * <pre> * 该接口用于获取配置过客户群管理的客户群列表。 * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 暂不支持第三方调用。 * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92119 * </pre> * * @param pageIndex the page index * @param pageSize the page size * @param status the status * @param userIds the user ids * @param partyIds the party ids * @return the wx cp user external group chat list * @throws WxErrorException the wx error exception * @deprecated 请使用 {@link WxCpExternalContactService#listGroupChat(Integer, String, int, String[])} */ @Deprecated WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException; /** * <pre> * 该接口用于获取配置过客户群管理的客户群列表。 * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 暂不支持第三方调用。 * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92119 * </pre> * * @param limit 分页,预期请求的数据量,取值范围 1 ~ 1000 * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用不填 * @param status 客户群跟进状态过滤。0 - 所有列表(即不过滤) 1 - 离职待继承 2 - 离职继承中 3 - 离职继承完成 默认为0 * @param userIds 群主过滤。如果不填,表示获取应用可见范围内全部群主的数据(但是不建议这么用,如果可见范围人数超过1000人,为了防止数据包过大,会报错 81017);用户ID列表。最多100个 * @return the wx cp user external group chat list * @throws WxErrorException the wx error exception */ WxCpUserExternalGroupChatList listGroupChat(Integer limit, String cursor, int status, String[] userIds) throws WxErrorException; /** * <pre> * 通过客户群ID,获取详情。包括群名、群成员列表、群成员入群时间、入群方式。(客户群是由具有客户群使用权限的成员创建的外部群) * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 暂不支持第三方调用。 * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92122 * </pre> * * @param chatId the chat id * @param needName the need name * @return group chat * @throws WxErrorException the wx error exception */ WxCpUserExternalGroupChatInfo getGroupChat(String chatId, Integer needName) throws WxErrorException; /** * 企业可通过此接口,将已离职成员为群主的群,分配给另一个客服成员。 * * <per> * 注意:: * <p> * 群主离职了的客户群,才可继承 * 继承给的新群主,必须是配置了客户联系功能的成员 * 继承给的新群主,必须有设置实名 * 继承给的新群主,必须有激活企业微信 * 同一个人的群,限制每天最多分配300个给新群主 * <p> * 权限说明: * <p> * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。 * 第三方应用需拥有“企业客户权限->客户联系->分配离职成员的客户群”权限 * 对于第三方/自建应用,群主必须在应用的可见范围。 * </per> * * @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100 * @param newOwner 新群主ID * @return 分配结果 ,主要是分配失败的群列表 * @throws WxErrorException the wx error exception */ WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) throws WxErrorException; /** * 企业可通过此接口,将在职成员为群主的群,分配给另一个客服成员。 * <per> * 注意: * 继承给的新群主,必须是配置了客户联系功能的成员 * 继承给的新群主,必须有设置实名 * 继承给的新群主,必须有激活企业微信 * 同一个人的群,限制每天最多分配300个给新群主 * 为保障客户服务体验,90个自然日内,在职成员的每个客户群仅可被转接2次。 * </pre> * * @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100 * @param newOwner 新群主ID * @return 分配结果 ,主要是分配失败的群列表 * @throws WxErrorException the wx error exception */ WxCpUserExternalGroupChatTransferResp onjobTransferGroupChat(String[] chatIds, String newOwner) throws WxErrorException;
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
true
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaScheduleService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.WxCpOaSchedule; import java.util.List; /** * 企业微信日程接口. * 官方文档:https://work.weixin.qq.com/api/doc/90000/90135/93648 * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020 -12-25 */ public interface WxCpOaScheduleService { /** * 创建日程 * <p> * 该接口用于在日历中创建一个日程。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add?access_token=ACCESS_TOKEN * * @param schedule the schedule * @param agentId 授权方安装的应用agentid。仅旧的第三方多应用套件需要填此参数 * @return 日程ID string * @throws WxErrorException the wx error exception */ String add(WxCpOaSchedule schedule, Integer agentId) throws WxErrorException; /** * 更新日程 * <p> * 该接口用于在日历中更新指定的日程。 * <p> * 注意,更新操作是覆盖式,而不是增量式 * 不可更新组织者和日程所属日历ID * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/update?access_token=ACCESS_TOKEN * * @param schedule the schedule * @throws WxErrorException the wx error exception */ void update(WxCpOaSchedule schedule) throws WxErrorException; /** * 获取日程详情 * <p> * 该接口用于获取指定的日程详情。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/get?access_token=ACCESS_TOKEN * * @param scheduleIds the schedule ids * @return the details * @throws WxErrorException the wx error exception */ List<WxCpOaSchedule> getDetails(List<String> scheduleIds) throws WxErrorException; /** * 取消日程 * 该接口用于取消指定的日程。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/del?access_token=ACCESS_TOKEN * * @param scheduleId 日程id * @throws WxErrorException the wx error exception */ void delete(String scheduleId) throws WxErrorException; /** * 获取日历下的日程列表 * 该接口用于获取指定的日历下的日程列表。 * 仅可获取应用自己创建的日历下的日程。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/get_by_calendar?access_token=ACCESS_TOKEN * * @param calId 日历ID * @param offset 分页,偏移量, 默认为0 * @param limit 分页,预期请求的数据量,默认为500,取值范围 1 ~ 1000 * @return the string * @throws WxErrorException the wx error exception */ List<WxCpOaSchedule> listByCalendar(String calId, Integer offset, Integer limit) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.export.WxCpExportRequest; import me.chanjar.weixin.cp.bean.export.WxCpExportResult; /** * 异步导出接口 * * @author <a href="https://github.com/zhongjun96">zhongjun</a> created on 2022/4/21 */ public interface WxCpExportService { /** * <pre> * * 导出成员 * * 请求方式:POST(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/export/simple_user?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/export/simple_user?access_token=ACCESS_TOKEN</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/94849">https://developer.work.weixin.qq.com/document/path/94849</a> * </pre> * * @param params 导出参数 * @return jobId 异步任务id * @throws WxErrorException . */ String simpleUser(WxCpExportRequest params) throws WxErrorException; /** * <pre> * * 导出成员详情 * * 请求方式:POST(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/export/user?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/export/user?access_token=ACCESS_TOKEN</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/94851">https://developer.work.weixin.qq.com/document/path/94851</a> * </pre> * * @param params 导出参数 * @return jobId 异步任务id * @throws WxErrorException . */ String user(WxCpExportRequest params) throws WxErrorException; /** * <pre> * * 导出部门 * * 请求方式:POST(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/export/department?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/export/department?access_token=ACCESS_TOKEN</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/94852">https://developer.work.weixin.qq.com/document/path/94852</a> * </pre> * * @param params 导出参数 * @return jobId 异步任务id * @throws WxErrorException . */ String department(WxCpExportRequest params) throws WxErrorException; /** * <pre> * * 导出标签成员 * * 请求方式:POST(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/export/taguser?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/export/taguser?access_token=ACCESS_TOKEN</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/94853">https://developer.work.weixin.qq.com/document/path/94853</a> * </pre> * * @param params 导出参数 * @return jobId 异步任务id * @throws WxErrorException . */ String tagUser(WxCpExportRequest params) throws WxErrorException; /** * <pre> * * 获取导出结果 * * 请求方式:GET(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/export/get_result?access_token=ACCESS_TOKEN&jobid=jobid_xxxxxxxxxxxxxxx">https://qyapi.weixin.qq.com/cgi-bin/export/get_result?access_token=ACCESS_TOKEN&jobid=jobid_xxxxxxxxxxxxxxx</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/94854">https://developer.work.weixin.qq.com/document/path/94854</a> * 返回的url文件下载解密可参考 <a href="https://blog.csdn.net/a201692/article/details/123530529">CSDN</a> * </pre> * * @param jobId 异步任务id * @return 导出结果 result * @throws WxErrorException . */ WxCpExportResult getResult(String jobId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.intelligentrobot.*; /** * 企业微信智能机器人接口 * 官方文档: https://developer.work.weixin.qq.com/document/path/101039 * * @author Binary Wang */ public interface WxCpIntelligentRobotService { /** * 创建智能机器人 * * @param request 创建请求参数 * @return 创建结果 * @throws WxErrorException 微信接口异常 */ WxCpIntelligentRobotCreateResponse createRobot(WxCpIntelligentRobotCreateRequest request) throws WxErrorException; /** * 删除智能机器人 * * @param robotId 机器人ID * @throws WxErrorException 微信接口异常 */ void deleteRobot(String robotId) throws WxErrorException; /** * 更新智能机器人 * * @param request 更新请求参数 * @throws WxErrorException 微信接口异常 */ void updateRobot(WxCpIntelligentRobotUpdateRequest request) throws WxErrorException; /** * 查询智能机器人 * * @param robotId 机器人ID * @return 机器人信息 * @throws WxErrorException 微信接口异常 */ WxCpIntelligentRobot getRobot(String robotId) throws WxErrorException; /** * 智能机器人会话 * * @param request 聊天请求参数 * @return 聊天响应 * @throws WxErrorException 微信接口异常 */ WxCpIntelligentRobotChatResponse chat(WxCpIntelligentRobotChatRequest request) throws WxErrorException; /** * 重置智能机器人会话 * * @param robotId 机器人ID * @param userid 用户ID * @param sessionId 会话ID * @throws WxErrorException 微信接口异常 */ void resetSession(String robotId, String userid, String sessionId) throws WxErrorException; /** * 智能机器人主动发送消息 * 官方文档: https://developer.work.weixin.qq.com/document/path/100719 * * @param request 发送消息请求参数 * @return 发送消息响应 * @throws WxErrorException 微信接口异常 */ WxCpIntelligentRobotSendMessageResponse sendMessage(WxCpIntelligentRobotSendMessageRequest request) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.wedrive.*; import java.util.List; /** * 企业微信微盘相关接口. * <a href="https://developer.work.weixin.qq.com/document/path/93654">...</a> * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on 2022-04-22 */ public interface WxCpOaWeDriveService { /** * 新建空间 * 该接口用于在微盘内新建空间,可以指定人创建空间。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=ACCESS_TOKEN">...</a> * * @param request 新建空间对应请求参数 * @return spaceid (空间id) * @throws WxErrorException the wx error exception */ WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException; /** * 重命名空间 * 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN">...</a> * * @param request 重命名空间的请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp spaceRename(@NonNull WxCpSpaceRenameRequest request) throws WxErrorException; /** * 解散空间 * 该接口用于解散已有空间,需要以空间管理员身份来解散。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN">...</a> * * @param spaceId the space id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp spaceDismiss(@NonNull String spaceId) throws WxErrorException; /** * 获取空间信息 * 该接口用于获取空间成员列表、信息、权限等信息。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN">...</a> * * @param spaceId the space id * @return wx cp space info * @throws WxErrorException the wx error exception */ WxCpSpaceInfo spaceInfo(@NonNull String spaceId) throws WxErrorException; /** * 添加成员/部门 * 该接口用于对指定空间添加成员/部门,可一次性添加多个。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN">...</a> * * @param request 添加成员/部门请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException; /** * 移除成员/部门 * 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN">...</a> * * @param request 移除成员/部门请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException; /** * 权限管理 * 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN">...</a> * * @param request 权限管理请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp spaceSetting(@NonNull WxCpSpaceSettingRequest request) throws WxErrorException; /** * 获取邀请链接 * 该接口用于获取空间邀请分享链接。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN">...</a> * * @param spaceId the space id * @return wx cp space share * @throws WxErrorException the wx error exception */ WxCpSpaceShare spaceShare(@NonNull String spaceId) throws WxErrorException; /** * 获取文件列表 * 该接口用于获取指定地址下的文件列表。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=ACCESS_TOKEN">...</a> * * @param request 获取文件列表请求参数 * @return wx cp file list * @throws WxErrorException the wx error exception */ WxCpFileList fileList(@NonNull WxCpFileListRequest request) throws WxErrorException; /** * 上传文件 * 该接口用于向微盘中的指定位置上传文件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=ACCESS_TOKEN">...</a> * * @param request 上传文件请求参数 * @return wx cp file upload * @throws WxErrorException the wx error exception */ WxCpFileUpload fileUpload(@NonNull WxCpFileUploadRequest request) throws WxErrorException; /** * 下载文件 * 该接口用于下载文件,请求的userid需有下载权限。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN">...</a> * * @param fileId 文件fileid(只支持下载普通文件,不支持下载文件夹或微文档) * @param selectedTicket 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填fileid。 * @return { * "errcode": 0, * "errmsg": "ok", * "download_url": "DOWNLOAD_URL", * "cookie_name": "COOKIE_NAME", * "cookie_value": "COOKIE_VALUE" * } * @throws WxErrorException the wx error exception */ WxCpFileDownload fileDownload(String fileId, String selectedTicket) throws WxErrorException; /** * 重命名文件 * 该接口用于对指定文件进行重命名。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=ACCESS_TOKEN">...</a> * * @param fileId the file id * @param newName the new name * @return wx cp file rename * @throws WxErrorException the wx error exception */ WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException; /** * 新建文件夹/文档 * 该接口用于在微盘指定位置新建文件夹、文档(更多文档接口能力可见文档API接口说明)。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=ACCESS_TOKEN">...</a> * * @param spaceId 空间spaceid * @param fatherId 父目录fileid, 在根目录时为空间spaceid * @param fileType 文件类型, 1:文件夹 3:文档(文档) 4:文档(表格) * @param fileName 文件名字(注意:文件名最多填255个字符, 英文算1个, 汉字算2个) * @return wx cp file create * @throws WxErrorException the wx error exception */ WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException; /** * 移动文件 * 该接口用于将文件移动到指定位置。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=ACCESS_TOKEN">...</a> * * @param request 移动文件的请求参数 * @return wx cp file move * @throws WxErrorException the wx error exception */ WxCpFileMove fileMove(@NonNull WxCpFileMoveRequest request) throws WxErrorException; /** * 删除文件 * 该接口用于删除指定文件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=ACCESS_TOKEN">...</a> * * @param fileIds 文件fileid列表 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp fileDelete(@NonNull List<String> fileIds) throws WxErrorException; /** * 文件信息 * 该接口用于获取指定文件的信息。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=ACCESS_TOKEN">...</a> * * @param fileId the file id * @return wx cp file info * @throws WxErrorException the wx error exception */ WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException; /** * 新增指定人 * 该接口用于对指定文件添加指定人/部门。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN">...</a> * * @param request 新增指定人请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException; /** * 删除指定人 * 该接口用于删除指定文件的指定人/部门。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN">...</a> * * @param request 请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException; /** * 分享设置 * 该接口用于文件的分享设置。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN">...</a> * * @param fileId the file id * @param authScope the auth scope * @param auth the auth * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp fileSetting(@NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException; /** * 获取分享链接 * 该接口用于获取文件的分享链接。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN">...</a> * * @param fileId the file id * @return wx cp file share * @throws WxErrorException the wx error exception */ WxCpFileShare fileShare(@NonNull String fileId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpInviteResult; import me.chanjar.weixin.cp.bean.WxCpOpenUseridToUseridResult; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; /** * <pre> * 用户管理接口 * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpUserService { /** * <pre> * 用在二次验证的时候. * 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。 * </pre> * * @param userId 用户id * @throws WxErrorException the wx error exception */ void authenticate(String userId) throws WxErrorException; /** * <pre> * 获取部门成员详情 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/90201 * </pre> * * @param departId 必填。部门id * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 * @return the list * @throws WxErrorException the wx error exception */ List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException; /** * <pre> * 获取部门成员. * * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98 * </pre> * * @param departId 必填。部门id * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 * @return the list * @throws WxErrorException the wx error exception */ List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException; /** * 新建用户. * * @param user 用户对象 * @throws WxErrorException the wx error exception */ void create(WxCpUser user) throws WxErrorException; /** * 更新用户. * * @param user 用户对象 * @throws WxErrorException the wx error exception */ void update(WxCpUser user) throws WxErrorException; /** * <pre> * 删除用户/批量删除成员. * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98 * </pre> * * @param userIds 员工UserID列表。对应管理端的帐号 * @throws WxErrorException the wx error exception */ void delete(String... userIds) throws WxErrorException; /** * 获取用户. * * @param userid 用户id * @return the by id * @throws WxErrorException the wx error exception */ WxCpUser getById(String userid) throws WxErrorException; /** * <pre> * 邀请成员. * 企业可通过接口批量邀请成员使用企业微信,邀请后将通过短信或邮件下发通知。 * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/batch/invite?access_token=ACCESS_TOKEN * 文档地址:https://work.weixin.qq.com/api/doc#12543 * </pre> * * @param userIds 成员ID列表, 最多支持1000个。 * @param partyIds 部门ID列表,最多支持100个。 * @param tagIds 标签ID列表,最多支持100个。 * @return the wx cp invite result * @throws WxErrorException the wx error exception */ WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException; /** * <pre> * userid转openid. * 该接口使用场景为微信支付、微信红包和企业转账。 * * 在使用微信支付的功能时,需要自行将企业微信的userid转成openid。 * 在使用微信红包功能时,需要将应用id和userid转成appid和openid才能使用。 * 注:需要成员使用微信登录企业微信或者关注微信插件才能转成openid * * 文档地址:https://work.weixin.qq.com/api/doc#11279 * </pre> * * @param userId 企业内的成员id * @param agentId 非必填,整型,仅用于发红包。其它场景该参数不要填,如微信支付、企业转账、电子发票 * @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid - * appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到 * @throws WxErrorException the wx error exception */ Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException; /** * <pre> * openid转userid. * * 该接口主要应用于使用微信支付、微信红包和企业转账之后的结果查询。 * 开发者需要知道某个结果事件的openid对应企业微信内成员的信息时,可以通过调用该接口进行转换查询。 * 权限说明: * 管理组需对openid对应的企业微信成员有查看权限。 * * 文档地址:https://work.weixin.qq.com/api/doc#11279 * </pre> * * @param openid 在使用微信支付、微信红包和企业转账之后,返回结果的openid * @return userid 该openid在企业微信对应的成员userid * @throws WxErrorException the wx error exception */ String openid2UserId(String openid) throws WxErrorException; /** * <pre> * * 通过手机号获取其所对应的userid。 * * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=ACCESS_TOKEN * * 文档地址:https://work.weixin.qq.com/api/doc#90001/90143/91693 * </pre> * * @param mobile 手机号码。长度为5~32个字节 * @return userid mobile对应的成员userid * @throws WxErrorException . */ String getUserId(String mobile) throws WxErrorException; /** * <pre> * * 通过邮箱获取其所对应的userid。 * * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/95895 * </pre> * * @param email 邮箱 * @param emailType 邮箱类型:1-企业邮箱;2-个人邮箱 * @return userid email对应的成员userid * @throws WxErrorException . */ String getUserIdByEmail(String email,int emailType) throws WxErrorException; /** * 获取外部联系人详情. * <pre> * 企业可通过此接口,根据外部联系人的userid,拉取外部联系人详情。权限说明: * 企业需要使用外部联系人管理secret所获取的accesstoken来调用 * 第三方应用需拥有“企业客户”权限。 * 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。 * </pre> * * @param userId 外部联系人的userid * @return 联系人详情 external contact * @throws WxErrorException . */ WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException; /** * <pre> * * 获取加入企业二维码。 * * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE * * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91714 * </pre> * * @param sizeType qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052 * @return join_qrcode 二维码链接,有效期7天 * @throws WxErrorException . */ String getJoinQrCode(int sizeType) throws WxErrorException; /** * <pre> * * 获取企业活跃成员数。 * * 请求方式:POST(HTTPS) * 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/user/get_active_stat?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/user/get_active_stat?access_token=ACCESS_TOKEN</a> * * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/92714">https://developer.work.weixin.qq.com/document/path/92714</a> * </pre> * * @param date 具体某天的活跃人数,最长支持获取30天前数据 * @return join_qrcode 活跃成员数 * @throws WxErrorException . */ Integer getActiveStat(Date date) throws WxErrorException; /** * userid转换为open_userid * 将自建应用或代开发应用获取的userid转换为第三方应用的userid * https://developer.work.weixin.qq.com/document/path/95603 * * @param useridList the userid list * @return the WxCpUseridToOpenUseridResult * @throws WxErrorException the wx error exception */ WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException; /** * open_userid转换为userid * 将代开发应用或第三方应用获取的密文open_userid转换为明文userid * <pre> * 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/95884#userid%E8%BD%AC%E6%8D%A2">https://developer.work.weixin.qq.com/document/path/95884#userid%E8%BD%AC%E6%8D%A2</a> * * 权限说明: * * 需要使用自建应用或基础应用的access_token * 成员需要同时在access_token和source_agentid所对应应用的可见范围内 * </pre> * @param openUseridList open_userid列表,最多不超过1000个。必须是source_agentid对应的应用所获取 * @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid * @return the WxCpOpenUseridToUseridResult * @throws WxErrorException the wx error exception */ WxCpOpenUseridToUseridResult openUseridToUserid(List<String> openUseridList, String sourceAgentId) throws WxErrorException; /** * 获取成员ID列表 * 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=ACCESS_TOKEN * * @param cursor the cursor * @param limit the limit * @return user list id * @throws WxErrorException the wx error exception */ WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolHealthService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportAnswer; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo; /** * 企业微信家校应用 健康上报接口. * https://developer.work.weixin.qq.com/document/path/93676 * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on : 2022/5/31 9:10 */ public interface WxCpSchoolHealthService { /** * 获取健康上报使用统计 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_health_report_stat?access_token=ACCESS_TOKEN * * @param date 具体某天的使用统计,最长支持获取30天前数据 * @return health report stat * @throws WxErrorException the wx error exception */ WxCpGetHealthReportStat getHealthReportStat(@NonNull String date) throws WxErrorException; /** * 获取健康上报任务ID列表 * 通过此接口可以获取企业当前正在运行的上报任务ID列表。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_jobids?access_token=ACCESS_TOKEN * * @param offset 否 分页,偏移量, 默认为0 * @param limit 否 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100 * @return report job ids * @throws WxErrorException the wx error exception */ WxCpGetReportJobIds getReportJobIds(Integer offset, Integer limit) throws WxErrorException; /** * 获取健康上报任务详情 * 通过此接口可以获取指定的健康上报任务详情。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_job_info?access_token=ACCESS_TOKEN * * @param jobId 是 任务ID * @param date 是 具体某天任务详情,仅支持获取最近14天数据 * @return report job info * @throws WxErrorException the wx error exception */ WxCpGetReportJobInfo getReportJobInfo(@NonNull String jobId, @NonNull String date) throws WxErrorException; /** * 获取用户填写答案 * 通过此接口可以获取指定的健康上报任务详情。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/health/get_report_answer?access_token=ACCESS_TOKEN * * @param jobId the job id * @param date the date * @param offset the offset * @param limit the limit * @return report answer * @throws WxErrorException the wx error exception */ WxCpGetReportAnswer getReportAnswer(@NonNull String jobId, @NonNull String date, Integer offset, Integer limit) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMeetingService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMeetingService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; /** * 企业微信日程接口. * 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。 * 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。 * 官方文档:https://developer.work.weixin.qq.com/document/path/93626 * * @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31 */ public interface WxCpMeetingService { /** * 创建预约会议 * <p> * 该接口用于创建一个预约会议。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/create?access_token=ACCESS_TOKEN * * @param meeting the meeting * @return 会议ID string * @throws WxErrorException the wx error exception */ String create(WxCpMeeting meeting) throws WxErrorException; /** * 修改预约会议 * <p> * 该接口用于修改一个指定的预约会议。。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/update?access_token=ACCESS_TOKEN * * @param meeting the meeting * @return wx cp meeting update result * @throws WxErrorException the wx error exception */ WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException; /** * 取消预约会议 * 该接口用于取消一个指定的预约会议。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/cancel?access_token=ACCESS_TOKEN * * @param meetingId 会议ID * @throws WxErrorException the wx error exception */ void cancel(String meetingId) throws WxErrorException; /** * 获取会议详情 * <p> * 该接口用于获取指定会议的详情内容。 * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meeting/get?access_token=ACCESS_TOKEN * * @param meetingId the meeting ids * @return the details * @throws WxErrorException the wx error exception */ WxCpMeeting getDetail(String meetingId) throws WxErrorException; /** * 获取成员会议ID列表 * 该接口用于获取指定成员指定时间内的会议ID列表。 * <p> * 权限说明: * 只能拉取该应用创建的会议ID * 自建应用需要配置在“可调用接口的应用”列表 * 第三方服务商创建应用的时候,需要开启“会议接口权限” * 代开发自建应用需要授权“会议接口权限” * <p> * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/get_user_meetingid?access_token=ACCESS_TOKEN * * @param userId 企业成员的userid * @param cursor 上一次调用时返回的cursor,初次调用可以填"0" * @param limit 每次拉取的数据量,默认值和最大值都为100 * @param beginTime 开始时间 * @param endTime 结束时间,时间跨度不超过180天。如果begin_time和end_time都没填的话,默认end_time为当前时间 * @return result of listUserMeetingIds * @throws WxErrorException the wx error exception */ WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit, Long beginTime, Long endTime) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; import me.chanjar.weixin.cp.bean.WxCpUserDetail; import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo; /** * <pre> * OAuth2相关管理接口. * Created by BinaryWang on 2017/6/24. * </pre> * <p> * 文档1:https://developer.work.weixin.qq.com/document/path/91856 * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpOAuth2Service { /** * <pre> * 构造oauth2授权的url连接. * </pre> * * @param state 状态码 * @return url string */ String buildAuthorizationUrl(String state); /** * <pre> * 构造oauth2授权的url连接. * 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code * </pre> * * @param redirectUri 跳转链接地址 * @param state 状态码 * @return url string */ String buildAuthorizationUrl(String redirectUri, String state); /** * <pre> * 构造oauth2授权的url连接 * 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code * </pre> * * @param redirectUri 跳转链接地址 * @param state 状态码 * @param scope 取值参考me.chanjar.weixin.common.api.WxConsts.OAuth2Scope类 * @return url string */ String buildAuthorizationUrl(String redirectUri, String state, String scope); /** * <pre> * 用oauth2获取用户信息 * http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 * 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 * * 注意: 这个方法使用WxCpConfigStorage里的agentId * </pre> * * @param code 微信oauth授权返回的代码 * @return WxCpOauth2UserInfo user info * @throws WxErrorException 异常 * @see #getUserInfo(Integer, String) #getUserInfo(Integer, String) */ WxCpOauth2UserInfo getUserInfo(String code) throws WxErrorException; /** * <pre> * 根据code获取成员信息 * http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 * https://work.weixin.qq.com/api/doc#10028/根据code获取成员信息 * https://work.weixin.qq.com/api/doc#90000/90135/91023 获取访问用户身份 * 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 * * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 * </pre> * * @param agentId 企业号应用的id * @param code 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。 * @return WxCpOauth2UserInfo user info * @throws WxErrorException 异常 * @see #getUserInfo(String) #getUserInfo(String) */ WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException; /** * 获取家校访问用户身份 * 该接口用于根据code获取家长或者学生信息 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE * * @param code the code * @return school user info * @throws WxErrorException the wx error exception */ WxCpOauth2UserInfo getSchoolUserInfo(String code) throws WxErrorException; /** * <pre> * 使用user_ticket获取成员详情 * * 文档地址:https://developer.work.weixin.qq.com/document/path/95833 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/auth/getuserdetail?access_token=ACCESS_TOKEN * * 注意: 原/cgi-bin/user/getuserdetail接口的url已变更为/cgi-bin/auth/getuserdetail,旧接口暂时还可以使用,但建议使用新接口 * * 权限说明:需要有对应应用的使用权限,且成员必须在授权应用的可见范围内。 * 适用范围:企业内部开发、服务商代开发 * </pre> * * @param userTicket 成员票据 * @return WxCpUserDetail user detail * @throws WxErrorException 异常 */ WxCpUserDetail getUserDetail(String userTicket) throws WxErrorException; /** * <pre> * 获取用户登录身份 * https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=ACCESS_TOKEN&code=CODE * 该接口可使用用户登录成功颁发的code来获取成员信息,适用于自建应用与代开发应用 * * 注意: 旧的/user/getuserinfo 接口的url已变更为auth/getuserinfo,不过旧接口依旧可以使用,建议是关注新接口即可 * * 适用范围:身份验证中网页授权开发和企业微信Web登录的获取用户登录身份 * </pre> * * @param code 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。 * @return WxCpOauth2UserInfo user info * @throws WxErrorException 异常 * @see #getUserInfo(Integer, String) #getUserInfo(Integer, String) */ WxCpOauth2UserInfo getAuthUserInfo(String code) throws WxErrorException; /** * 获取用户二次验证信息 * <p> * api: https://qyapi.weixin.qq.com/cgi-bin/auth/get_tfa_info?access_token=ACCESS_TOKEN * 权限说明:仅『通讯录同步』或者自建应用可调用,如用自建应用调用,用户需要在二次验证范围和应用可见范围内。 * 并发限制:20 * * @param code 用户进入二次验证页面时,企业微信颁发的code,每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期 * @return me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo 二次验证授权码,开发者可以调用通过二次验证接口,解锁企业微信终端.tfa_code有效期五分钟,且只能使用一次。 */ WxCpSecondVerificationInfo getTfaInfo(String code) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpTaskCardService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.message.TemplateCardMessage; 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> created on 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 replaceName 替换文案 * @throws WxErrorException the wx error exception */ 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 the wx error exception */ void updateTemplateCardButton(List<String> userIds, List<Integer> partyIds, List<Integer> tagIds, Integer atAll, String responseCode, String replaceName) throws WxErrorException; void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpDepartmentService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpDepart; import java.util.List; /** * <pre> * 部门管理接口 * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxCpDepartmentService { /** * <pre> * 部门管理接口 - 创建部门. * 最多支持创建500个部门 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90205">...</a> * </pre> * * @param depart 部门 * @return 部门id long * @throws WxErrorException 异常 */ Long create(WxCpDepart depart) throws WxErrorException; /** * <pre> * 部门管理接口 - 获取单个部门详情. * 详情请见: <a href="https://developer.work.weixin.qq.com/document/path/95351">...</a> * </pre> * * @param id 部门id * @return 部门信息 wx cp depart * @throws WxErrorException 异常 */ WxCpDepart get(Long id) throws WxErrorException; /** * <pre> * 部门管理接口 - 获取部门列表. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90208">...</a> * </pre> * * @param id 部门id。获取指定部门及其下的子部门。非必需,可为null * @return 获取的部门列表 list * @throws WxErrorException 异常 */ List<WxCpDepart> list(Long id) throws WxErrorException; /** * <pre> * 部门管理接口 - 获取子部门ID列表. * 详情请见: <a href="https://developer.work.weixin.qq.com/document/path/95350">...</a> * </pre> * * @param id 部门id。获取指定部门及其下的子部门(以及子部门的子部门等等,递归)。 如果不填,默认获取全量组织架构 * @return 子部门ID列表 list * @throws WxErrorException 异常 */ List<WxCpDepart> simpleList(Long id) throws WxErrorException; /** * <pre> * 部门管理接口 - 更新部门. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90206">...</a> * 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误 * </pre> * * @param group 要更新的group,group的id,name必须设置 * @throws WxErrorException 异常 */ void update(WxCpDepart group) throws WxErrorException; /** * <pre> * 部门管理接口 - 删除部门. * 详情请见: <a href="https://work.weixin.qq.com/api/doc#90000/90135/90207">...</a> * 应用须拥有指定部门的管理权限 * </pre> * * @param departId 部门id * @throws WxErrorException 异常 */ void delete(Long departId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.living.*; /** * 企业微信直播接口. * 官方文档:https://work.weixin.qq.com/api/doc/90000/90135/93633 * * @author Wang_Wong created on 2021-12-21 */ public interface WxCpLivingService { /** * 获取微信观看直播凭证 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/get_living_code?access_token=ACCESS_TOKEN * * @param openId 用户openid * @param livingId 直播id * @return living_code 微信观看直播凭证 * @throws WxErrorException the wx error exception */ String getLivingCode(@NonNull String openId, @NonNull String livingId) throws WxErrorException; /** * 获取直播详情 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID * * @param livingId 直播id * @return 获取的直播详情 living info * @throws WxErrorException the wx error exception */ WxCpLivingInfo getLivingInfo(@NonNull String livingId) throws WxErrorException; /** * 获取直播观看明细 * 通过该接口可以获取所有观看直播的人员统计 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_watch_stat?access_token=ACCESS_TOKEN * * @param livingId 直播id * @param nextKey 上一次调用时返回的next_key,初次调用可以填”0” * @return watch stat * @throws WxErrorException the wx error exception */ WxCpWatchStat getWatchStat(@NonNull String livingId, String nextKey) throws WxErrorException; /** * 获取成员直播ID列表 * 通过此接口可以获取指定成员的所有直播ID * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=ACCESS_TOKEN * * @param userId 企业成员的userid * @param cursor 上一次调用时返回的next_cursor,第一次拉取可以不填 * @param limit 每次拉取的数据量,默认值和最大值都为100 * @return user all living id * @throws WxErrorException the wx error exception */ WxCpLivingResult.LivingIdResult getUserAllLivingId(@NonNull String userId, String cursor, Integer limit) throws WxErrorException; /** * 获取跳转小程序商城的直播观众信息 * 通过此接口,开发者可获取跳转小程序商城的直播间(“推广产品”直播)观众id、邀请人id及对应直播间id,以打通卖货直播的“人货场”信息闭环。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_share_info?access_token=ACCESS_TOKEN * * @param wwShareCode "推广产品"直播观众跳转小程序商城时会在小程序path中带上ww_share_code=xxxxx参数 * @return living share info * @throws WxErrorException the wx error exception */ WxCpLivingShareInfo getLivingShareInfo(@NonNull String wwShareCode) throws WxErrorException; /** * 创建预约直播 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/create?access_token=ACCESS_TOKEN * * @param request 创建预约直播请求参数. * @return livingId (直播id) * @throws WxErrorException the wx error exception */ String livingCreate(WxCpLivingCreateRequest request) throws WxErrorException; /** * 修改预约直播 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/modify?access_token=ACCESS_TOKEN * * @param request 修改预约直播请求参数. * @return wx cp living result * @throws WxErrorException the wx error exception */ WxCpLivingResult livingModify(WxCpLivingModifyRequest request) throws WxErrorException; /** * 取消预约直播 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/cancel?access_token=ACCESS_TOKEN * * @param livingId 直播id,仅允许取消预约状态下的直播id * @return wx cp living result * @throws WxErrorException the wx error exception */ WxCpLivingResult livingCancel(@NonNull String livingId) throws WxErrorException; /** * 删除直播回放 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=ACCESS_TOKEN * * @param livingId 直播id * @return wx cp living result * @throws WxErrorException the wx error exception */ WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.oa.meetingroom.*; import java.util.List; /** * 企业微信会议室接口. * * @author <a href="https://github.com/lm93129">lm93129</a> created on 2022年8月12日22:33:36 */ public interface WxCpOaMeetingRoomService { /** * 创建会议室. * <pre> * 该接口用于通过应用在企业内创建一个会议室。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/add?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93619 * </pre> * * @param meetingRoom 会议室对象 * @return 会议室ID string * @throws WxErrorException . */ String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException; /** * 查询会议室. * <pre> * 该接口用于通过应用在企业内查询会议室列表。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/list?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93619 * </pre> * * @param meetingRoomRequest 会议室查询对象 * @return 会议室ID list * @throws WxErrorException . */ List<WxCpOaMeetingRoom> listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException; /** * 编辑会议室. * <pre> * 该接口用于通过应用在企业内编辑会议室。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/edit?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93619 * </pre> * * @param meetingRoom 会议室对象 * @throws WxErrorException . */ void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException; /** * 删除会议室. * <pre> * 企业可通过此接口删除指定的会议室。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/del?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93619 * </pre> * * @param meetingRoomId 会议室ID * @throws WxErrorException . */ void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException; /** * 查询会议室的预定信息. * <pre> * 企业可通过此接口查询相关会议室在指定时间段的预定情况,如是否已被预定,预定者的userid等信息,不支持跨天查询。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/get_booking_info?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomBookingInfoRequest 会议室预定信息查询对象 * @throws WxErrorException . */ WxCpOaMeetingRoomBookingInfoResult getMeetingRoomBookingInfo(WxCpOaMeetingRoomBookingInfoRequest wxCpOaMeetingRoomBookingInfoRequest) throws WxErrorException; /** * 预定会议室. * <pre> * 企业可通过此接口预定会议室并自动关联日程。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/book?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomBookRequest 会议室预定对象 * @throws WxErrorException . */ WxCpOaMeetingRoomBookResult bookingMeetingRoom(WxCpOaMeetingRoomBookRequest wxCpOaMeetingRoomBookRequest) throws WxErrorException; /** * 通过日程预定会议室. * <pre> * 企业可通过此接口为指定日程预定会议室,支持重复日程预定。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/book_by_schedule?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomBookByScheduleRequest 会议室预定对象 * @throws WxErrorException . */ WxCpOaMeetingRoomBookResult bookingMeetingRoomBySchedule(WxCpOaMeetingRoomBookByScheduleRequest wxCpOaMeetingRoomBookByScheduleRequest) throws WxErrorException; /** * 通过会议预定会议室. * <pre> * 企业可通过此接口为指定会议预定会议室,支持重复会议预定。 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/book_by_meeting?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomBookByMeetingRequest 会议室预定对象 * @throws WxErrorException . */ WxCpOaMeetingRoomBookResult bookingMeetingRoomByMeeting(WxCpOaMeetingRoomBookByMeetingRequest wxCpOaMeetingRoomBookByMeetingRequest) throws WxErrorException; /** * 取消预定会议室. * <pre> * 企业可通过此接口取消会议室的预定 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/cancel_book?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomCancelBookRequest 取消预定会议室对象 * @throws WxErrorException . */ void cancelBookMeetingRoom(WxCpOaMeetingRoomCancelBookRequest wxCpOaMeetingRoomCancelBookRequest) throws WxErrorException; /** * 根据会议室预定ID查询预定详情. * <pre> * 企业可通过此接口根据预定id查询相关会议室的预定情况 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/bookinfo/get?access_token=ACCESS_TOKEN * * 文档地址:https://developer.work.weixin.qq.com/document/path/93620 * </pre> * * @param wxCpOaMeetingRoomBookingInfoByBookingIdRequest 根据会议室预定ID查询预定详情对象 * @throws WxErrorException . */ WxCpOaMeetingRoomBookingInfoByBookingIdResult getBookingInfoByBookingId(WxCpOaMeetingRoomBookingInfoByBookingIdRequest wxCpOaMeetingRoomBookingInfoByBookingIdRequest) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpAgent; import me.chanjar.weixin.cp.bean.WxCpTpAdmin; import java.util.List; /** * <pre> * 管理企业号应用 * 文档地址:<a href="https://work.weixin.qq.com/api/doc#10087">...</a> * Created by huansinho on 2018/4/13. * </pre> * * @author <a href="https://github.com/huansinho">huansinho</a> */ public interface WxCpAgentService { /** * <pre> * 获取企业号应用信息 * 该API用于获取企业号某个应用的基本信息,包括头像、昵称、账号类型、认证类型、可见范围等信息 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#10087">...</a> * </pre> * * @param agentId 企业应用的id * @return wx cp agent * @throws WxErrorException the wx error exception */ WxCpAgent get(Integer agentId) throws WxErrorException; /** * <pre> * 设置应用. * 仅企业可调用,可设置当前凭证对应的应用;第三方不可调用。 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#10088">...</a> * </pre> * * @param agentInfo 应用信息 * @throws WxErrorException the wx error exception */ void set(WxCpAgent agentInfo) throws WxErrorException; /** * <pre> * 获取应用列表. * 企业仅可获取当前凭证对应的应用;第三方仅可获取被授权的应用。 * 详情请见: <a href="https://work.weixin.qq.com/api/doc#11214">...</a> * </pre> * * @return the list * @throws WxErrorException the wx error exception */ List<WxCpAgent> list() throws WxErrorException; /** * <pre> * 获取应用管理员列表 * 第三方服务商可以用此接口获取授权企业中某个第三方应用或者代开发应用的管理员列表(不包括外部管理员), * 以便服务商在用户进入应用主页之后根据是否管理员身份做权限的区分。 * 详情请见: <a href="https://developer.work.weixin.qq.com/document/path/90506">文档</a> * </pre> * * @param agentId 应用id * @return admin list * @throws WxErrorException the wx error exception */ WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.service.WxService; import me.chanjar.weixin.common.session.WxSession; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature; import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; import me.chanjar.weixin.cp.bean.WxCpProviderToken; import me.chanjar.weixin.cp.config.WxCpConfigStorage; /** * 微信API的Service. * * @author chanjaster */ public interface WxCpService extends WxService { /** * <pre> * 验证推送过来的消息的正确性 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=验证消息真实性 * </pre> * * @param msgSignature 消息签名 * @param timestamp 时间戳 * @param nonce 随机数 * @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息 * @return the boolean */ boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); /** * 获取access_token, 不强制刷新access_token * * @return the access token * @throws WxErrorException the wx error exception * @see #getAccessToken(boolean) #getAccessToken(boolean)#getAccessToken(boolean)#getAccessToken(boolean) */ String getAccessToken() throws WxErrorException; /** * <pre> * 获取access_token,本方法线程安全 * 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限 * 另:本service的所有方法都会在access_token过期是调用此方法 * 程序员在非必要情况下尽量不要主动调用此方法 * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token * </pre> * * @param forceRefresh 强制刷新 * @return the access token * @throws WxErrorException the wx error exception */ String getAccessToken(boolean forceRefresh) throws WxErrorException; /** * 获得jsapi_ticket,不强制刷新jsapi_ticket * * @return the jsapi ticket * @throws WxErrorException the wx error exception * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean)#getJsapiTicket(boolean) */ String getJsapiTicket() throws WxErrorException; /** * <pre> * 获得jsapi_ticket * 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 * * 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 * </pre> * * @param forceRefresh 强制刷新 * @return the jsapi ticket * @throws WxErrorException the wx error exception */ String getJsapiTicket(boolean forceRefresh) throws WxErrorException; /** * 获得jsapi_ticket,不强制刷新jsapi_ticket * 应用的jsapi_ticket用于计算agentConfig(参见“通过agentConfig注入应用的权限”)的签名,签名计算方法与上述介绍的config的签名算法完全相同,但需要注意以下区别: * <p> * 签名的jsapi_ticket必须使用以下接口获取。且必须用wx.agentConfig中的agentid对应的应用secret去获取access_token。 * 签名用的noncestr和timestamp必须与wx.agentConfig中的nonceStr和timestamp相同。 * * @return the agent jsapi ticket * @throws WxErrorException the wx error exception * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean)#getJsapiTicket(boolean)#getJsapiTicket(boolean) */ String getAgentJsapiTicket() throws WxErrorException; /** * <pre> * 获取应用的jsapi_ticket * 应用的jsapi_ticket用于计算agentConfig(参见“通过agentConfig注入应用的权限”)的签名,签名计算方法与上述介绍的config的签名算法完全相同,但需要注意以下区别: * * 签名的jsapi_ticket必须使用以下接口获取。且必须用wx.agentConfig中的agentid对应的应用secret去获取access_token。 * 签名用的noncestr和timestamp必须与wx.agentConfig中的nonceStr和timestamp相同。 * * 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 * * 详情请见:https://work.weixin.qq.com/api/doc#10029/%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E7%9A%84jsapi_ticket * </pre> * * @param forceRefresh 强制刷新 * @return the agent jsapi ticket * @throws WxErrorException the wx error exception */ String getAgentJsapiTicket(boolean forceRefresh) throws WxErrorException; /** * <pre> * 创建调用jsapi时所需要的签名 * * 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 * </pre> * * @param url url * @return the wx jsapi signature * @throws WxErrorException the wx error exception */ WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; /** * <pre> * 创建调用wx.agentConfig时所需要的签名 * * 详情请见:https://open.work.weixin.qq.com/api/doc/90000/90136/94313 * </pre> * * @param url url * @return the agent jsapi signature * @throws WxErrorException the wx error exception */ WxCpAgentJsapiSignature createAgentJsapiSignature(String url) throws WxErrorException; /** * 小程序登录凭证校验 * * @param jsCode 登录时获取的 code * @return the wx cp ma js code 2 session result * @throws WxErrorException the wx error exception */ WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorException; /** * <pre> * 获取企业微信回调IP段 * http://qydev.weixin.qq.com/wiki/index.php?title=回调模式#.E8.8E.B7.E5.8F.96.E5.BE.AE.E4.BF.A1.E6.9C.8D.E5.8A.A1.E5.99.A8.E7.9A.84ip.E6.AE.B5 * </pre> * * @return { "ip_list": ["101.226.103.*", "101.226.62.*"] } * @throws WxErrorException the wx error exception */ String[] getCallbackIp() throws WxErrorException; /** * <pre> * 获取企业微信接口IP段 * https://developer.work.weixin.qq.com/document/path/92520 * </pre> * * @return 企业微信接口IP段 * @throws WxErrorException the wx error exception */ String[] getApiDomainIp() throws WxErrorException; /** * <pre> * 获取服务商凭证 * 文档地址:https://work.weixin.qq.com/api/doc#90001/90143/91200 * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token * </pre> * * @param corpId 服务商的corpid * @param providerSecret 服务商的secret,在服务商管理后台可见 * @return { "errcode":0 , "errmsg":"ok" , "provider_access_token":"enLSZ5xxxxxxJRL", "expires_in":7200 } * @throws WxErrorException . */ WxCpProviderToken getProviderToken(String corpId, String providerSecret) throws WxErrorException; /** * 当不需要自动带accessToken的时候,可以用这个发起post请求 * * @param url 接口地址 * @param postData 请求body字符串 * @return the string * @throws WxErrorException the wx error exception */ String postWithoutToken(String url, String postData) throws WxErrorException; /** * <pre> * Service没有实现某个API的时候,可以用这个, * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 * 可以参考,{@link MediaUploadRequestExecutor}的实现方法 * </pre> * * @param <T> 请求值类型 * @param <E> 返回值类型 * @param executor 执行器 * @param uri 请求地址 * @param data 参数 * @return the t * @throws WxErrorException the wx error exception */ <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException; /** * <pre> * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试 * 默认:1000ms * </pre> * * @param retrySleepMillis 重试休息时间 */ void setRetrySleepMillis(int retrySleepMillis); /** * <pre> * 设置当微信系统响应系统繁忙时,最大重试次数 * 默认:5次 * </pre> * * @param maxRetryTimes 最大重试次数 */ void setMaxRetryTimes(int maxRetryTimes); /** * 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。 * * @param id id可以为任意字符串,建议使用FromUserName作为id * @return the session */ WxSession getSession(String id); /** * 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。 * * @param id id可以为任意字符串,建议使用FromUserName作为id * @param create 是否新建 * @return the session */ WxSession getSession(String id, boolean create); /** * 获取WxSessionManager 对象 * * @return WxSessionManager session manager */ WxSessionManager getSessionManager(); /** * <pre> * 设置WxSessionManager,只有当需要使用个性化的WxSessionManager的时候才需要调用此方法, * WxCpService默认使用的是{@link me.chanjar.weixin.common.session.StandardSessionManager} * </pre> * * @param sessionManager 会话管理器 */ void setSessionManager(WxSessionManager sessionManager); /** * 上传部门列表覆盖企业号上的部门信息 * * @param mediaId 媒体id * @return the string * @throws WxErrorException the wx error exception */ String replaceParty(String mediaId) throws WxErrorException; /** * 上传用户列表,增量更新成员 * * @param mediaId 媒体id * @return jobId 异步任务id * @throws WxErrorException the wx error exception */ String syncUser(String mediaId) throws WxErrorException; /** * 上传用户列表覆盖企业号上的用户信息 * * @param mediaId 媒体id * @return the string * @throws WxErrorException the wx error exception */ String replaceUser(String mediaId) throws WxErrorException; /** * 获取异步任务结果 * * @param jobId 异步任务id * @return the task result * @throws WxErrorException the wx error exception */ String getTaskResult(String jobId) throws WxErrorException; /** * 初始化http请求对象 */ void initHttp(); /** * 获取WxCpConfigStorage 对象 * * @return WxCpConfigStorage wx cp config storage */ WxCpConfigStorage getWxCpConfigStorage(); /** * 注入 {@link WxCpConfigStorage} 的实现 * * @param wxConfigProvider 配置对象 */ void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider); /** * 构造扫码登录链接 - 构造独立窗口登录二维码 * * @param redirectUri 重定向地址,需要进行UrlEncode * @param state 用于保持请求和回调的状态,授权请求后原样带回给企业。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议企业带上该参数,可设置为简单的随机数加session进行校验 * @return . string */ String buildQrConnectUrl(String redirectUri, String state); /** * 获取部门相关接口的服务类对象 * * @return the department service */ WxCpDepartmentService getDepartmentService(); /** * 获取媒体相关接口的服务类对象 * * @return the media service */ WxCpMediaService getMediaService(); /** * 获取菜单相关接口的服务类对象 * * @return the menu service */ WxCpMenuService getMenuService(); /** * 获取Oauth2相关接口的服务类对象 * * @return the oauth 2 service */ WxCpOAuth2Service getOauth2Service(); /** * 获取标签相关接口的服务类对象 * * @return the tag service */ WxCpTagService getTagService(); /** * 获取用户相关接口的服务类对象 * * @return the user service */ WxCpUserService getUserService(); /** * Gets external contact service. * * @return the external contact service */ WxCpExternalContactService getExternalContactService(); /** * 获取群聊服务 * * @return 群聊服务 chat service */ WxCpChatService getChatService(); /** * 获取任务卡片服务 * * @return 任务卡片服务 task card service */ WxCpTaskCardService getTaskCardService(); /** * Gets agent service. * * @return the agent service */ WxCpAgentService getAgentService(); /** * Gets message service. * * @return the message service */ WxCpMessageService getMessageService(); /** * 获取OA相关接口的服务类对象. * * @return the oa service */ WxCpOaService getOaService(); /** * 获取家校应用复学码相关接口的服务类对象 * * @return school service */ WxCpSchoolService getSchoolService(); /** * 获取家校沟通相关接口的服务类对象 * * @return school user service */ WxCpSchoolUserService getSchoolUserService(); /** * 获取家校应用健康上报的服务类对象 * * @return school health service */ WxCpSchoolHealthService getSchoolHealthService(); /** * 获取直播相关接口的服务类对象 * * @return the Living service */ WxCpLivingService getLivingService(); /** * 获取OA 自建应用相关接口的服务类对象 * * @return oa agent service */ WxCpOaAgentService getOaAgentService(); /** * 获取OA效率工具 微盘的服务类对象 * * @return oa we drive service */ WxCpOaWeDriveService getOaWeDriveService(); /** * 获取会话存档相关接口的服务类对象 * * @return msg audit service */ WxCpMsgAuditService getMsgAuditService(); /** * 获取日历相关接口的服务类对象 * * @return the oa calendar service */ WxCpOaCalendarService getOaCalendarService(); /** * 获取会议室相关接口的服务类对象 * * @return the oa meetingroom service */ WxCpOaMeetingRoomService getOaMeetingRoomService(); /** * 获取日程相关接口的服务类对象 * * @return the oa schedule service */ WxCpOaScheduleService getOaScheduleService(); /** * 获取群机器人消息推送服务 * * @return 群机器人消息推送服务 group robot service */ WxCpGroupRobotService getGroupRobotService(); /** * 获取工作台服务 * * @return the workbench service */ WxCpAgentWorkBenchService getWorkBenchService(); /** * 获取微信客服服务 * * @return 微信客服服务 kf service */ WxCpKfService getKfService(); /** * http请求对象 * * @return the request http */ RequestHttp<?, ?> getRequestHttp(); /** * Sets user service. * * @param userService the user service */ void setUserService(WxCpUserService userService); /** * Sets department service. * * @param departmentService the department service */ void setDepartmentService(WxCpDepartmentService departmentService); /** * Sets media service. * * @param mediaService the media service */ void setMediaService(WxCpMediaService mediaService); /** * Sets menu service. * * @param menuService the menu service */ void setMenuService(WxCpMenuService menuService); /** * Sets oauth 2 service. * * @param oauth2Service the oauth 2 service */ void setOauth2Service(WxCpOAuth2Service oauth2Service); /** * Sets tag service. * * @param tagService the tag service */ void setTagService(WxCpTagService tagService); /** * Sets kf service. * * @param kfService the kf service */ void setKfService(WxCpKfService kfService); /** * 获取异步导出服务 * * @return 异步导出服务 export service */ WxCpExportService getExportService(); /** * 设置异步导出服务 * * @param exportService 异步导出服务 */ void setExportService(WxCpExportService exportService); /** * 相关接口的服务类对象 * * @return the meeting service */ WxCpMeetingService getMeetingService(); /** * 企业互联的服务类对象 * * @return */ WxCpCorpGroupService getCorpGroupService(); /** * 获取智能机器人服务 * * @return 智能机器人服务 intelligent robot service */ WxCpIntelligentRobotService getIntelligentRobotService(); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpChatService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpChat; import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; import java.util.List; /** * 群聊服务. * * @author gaigeshen */ public interface WxCpChatService { /** * 创建群聊会话,注意:刚创建的群,如果没有下发消息,在企业微信不会出现该群. * * @param name 群聊名,最多50个utf8字符,超过将截断 * @param owner 指定群主的id。如果不指定,系统会随机从userlist中选一人作为群主 * @param users 群成员id列表。至少2人,至多500人 * @param chatId 群聊的唯一标志,不能与已有的群重复;字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z。如果不填,系统会随机生成群id * @return 创建的群聊会话chatId string * @throws WxErrorException 异常 */ String create(String name, String owner, List<String> users, String chatId) throws WxErrorException; /** * 修改群聊会话. * * @param chatId 群聊id * @param name 新的群聊名。若不需更新,请忽略此参数(null or empty)。最多50个utf8字符,超过将截断 * @param owner 新群主的id。若不需更新,请忽略此参数(null or empty) * @param usersToAdd 添加成员的id列表,若不需要更新,则传递空对象或者空集合 * @param usersToDelete 踢出成员的id列表,若不需要更新,则传递空对象或者空集合 * @throws WxErrorException 异常 */ void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; /** * 获取群聊会话. * * @param chatId 群聊编号 * @return 群聊会话 wx cp chat * @throws WxErrorException 异常 */ WxCpChat get(String chatId) throws WxErrorException; /** * 应用支持推送文本、图片、视频、文件、图文等类型. * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token=ACCESS_TOKEN * 文档地址:<a href="https://work.weixin.qq.com/api/doc#90000/90135/90248">...</a> * * @param message 要发送的消息内容对象 * @throws WxErrorException 异常 */ void sendMsg(WxCpAppChatMessage message) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorp; import java.util.List; /** * 企业互联相关接口 * * @author libo <422423229@qq.com> * Created on 27/2/2023 9:57 PM */ public interface WxCpCorpGroupService { /** * List app share info list. * * @param agentId the agent id * @param businessType the business type * @param corpId the corp id * @param limit the limit * @param cursor the cursor * @return the list * @throws WxErrorException the wx error exception */ List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.article.NewArticle; import me.chanjar.weixin.cp.bean.message.WxCpGroupRobotMessage; import java.util.List; /** * 微信群机器人消息发送api * 文档地址:https://work.weixin.qq.com/help?doc_id=13376 * 调用地址:https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key= * * @author yr created on 2020-8-20 */ public interface WxCpGroupRobotService { /** * 发送text类型的消息 * * @param content 文本内容,最长不超过2048个字节,必须是utf8编码 * @param mentionedList userId的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userId,可以使用mentioned_mobile_list * @param mobileList 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人 * @throws WxErrorException 异常 */ void sendText(String content, List<String> mentionedList, List<String> mobileList) throws WxErrorException; /** * 发送markdown类型的消息 * * @param content markdown内容,最长不超过4096个字节,必须是utf8编码 * @throws WxErrorException 异常 */ void sendMarkdown(String content) throws WxErrorException; /** * 发送image类型的消息 * * @param base64 图片内容的base64编码 * @param md5 图片内容(base64编码前)的md5值 * @throws WxErrorException 异常 */ void sendImage(String base64, String md5) throws WxErrorException; /** * 发送news类型的消息 * * @param articleList 图文消息,支持1到8条图文 * @throws WxErrorException 异常 */ void sendNews(List<NewArticle> articleList) throws WxErrorException; /** * 发送text类型的消息 * * @param webhookUrl webhook地址 * @param content 文本内容,最长不超过2048个字节,必须是utf8编码 * @param mentionedList userId的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userId,可以使用mentioned_mobile_list * @param mobileList 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人 * @throws WxErrorException 异常 */ void sendText(String webhookUrl, String content, List<String> mentionedList, List<String> mobileList) throws WxErrorException; /** * 发送markdown类型的消息 * * @param webhookUrl webhook地址 * @param content markdown内容,最长不超过4096个字节,必须是utf8编码 * @throws WxErrorException 异常 */ void sendMarkdown(String webhookUrl, String content) throws WxErrorException; /** * 发送markdown_v2类型的消息 * * @param content markdown内容,最长不超过4096个字节,必须是utf8编码 * @throws WxErrorException 异常 */ void sendMarkdownV2(String content) throws WxErrorException; /** * 发送markdown_v2类型的消息 * * @param webhookUrl webhook地址 * @param content markdown内容,最长不超过4096个字节,必须是utf8编码 * @throws WxErrorException 异常 */ void sendMarkdownV2(String webhookUrl, String content) throws WxErrorException; /** * 发送image类型的消息 * * @param webhookUrl webhook地址 * @param base64 图片内容的base64编码 * @param md5 图片内容(base64编码前)的md5值 * @throws WxErrorException 异常 */ void sendImage(String webhookUrl, String base64, String md5) throws WxErrorException; /** * 发送news类型的消息 * * @param webhookUrl webhook地址 * @param articleList 图文消息,支持1到8条图文 * @throws WxErrorException 异常 */ void sendNews(String webhookUrl, List<NewArticle> articleList) throws WxErrorException; /** * 发送文件类型的消息 * * @param webhookUrl webhook地址 * @param mediaId 文件id * @throws WxErrorException 异常 */ void sendFile(String webhookUrl, String mediaId) throws WxErrorException; /** * 发送文件类型的消息 * * @param webhookUrl webhook地址 * @param mediaId 语音文件id * @throws WxErrorException 异常 */ void sendVoice(String webhookUrl, String mediaId) throws WxErrorException; /** * 发送模板卡片消息 * @param webhookUrl * @param wxCpGroupRobotMessage * @throws WxErrorException */ void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMailService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMailService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailCommonSendRequest; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailMeetingSendRequest; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailScheduleSendRequest; /** * 企业微信y邮件相关接口. * <a href="https://developer.work.weixin.qq.com/document/path/95486">邮件</a> * * @author Hugo */ public interface WxCpOaMailService { /** * 发送普通邮件 * 应用可以通过该接口发送普通邮件,支持附件能力。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送普通邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp mailCommonSend(@NonNull WxCpMailCommonSendRequest request) throws WxErrorException; /** * 发送日程邮件 * 应用可以通过该接口发送日程邮件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送日程邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp mailScheduleSend(@NonNull WxCpMailScheduleSendRequest request) throws WxErrorException; /** * 发送会议邮件 * 应用可以通过该接口发送会议邮件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送会议邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp mailMeetingSend(@NonNull WxCpMailMeetingSendRequest request) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.doc.*; /** * 企业微信文档相关接口. * <a href="https://developer.work.weixin.qq.com/document/path/97392">文档</a> * * @author Hugo */ public interface WxCpOaWeDocService { /** * 新建文档 * 该接口用于新建文档和表格,新建收集表可前往 收集表管理 查看。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/create_doc?access_token=ACCESS_TOKEN * * @param request 新建文档对应请求参数 * @return url:新建文档的访问链接,docid:新建文档的docid * @throws WxErrorException the wx error exception */ WxCpDocCreateData docCreate(@NonNull WxCpDocCreateRequest request) throws WxErrorException; /** * 重命名文档/收集表 * 该接口用于对指定文档/收集表进行重命名。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/rename_doc?access_token=ACCESS_TOKEN * * @param request 重命名文档/收集表 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp docRename(@NonNull WxCpDocRenameRequest request) throws WxErrorException; /** * 删除文档/收集表 * 该接口用于删除指定文档/收集表。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/del_doc?access_token=ACCESS_TOKEN * * @param docId 文档docid(docid、formid只能填其中一个) * @param formId 收集表id(docid、formid只能填其中一个) * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp docDelete(String docId, String formId) throws WxErrorException; /** * 获取文档基础信息 * 该接口用于获取指定文档的基础信息。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/get_doc_base_info?access_token=ACCESS_TOKEN * * @param docId 文档docid * @return wx cp doc info * @throws WxErrorException the wx error exception */ WxCpDocInfo docInfo(@NonNull String docId) throws WxErrorException; /** * 分享文档 * 该接口用于获取文档的分享链接。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/doc_share?access_token=ACCESS_TOKEN * * @param docId 文档docid * @return url 文档分享链接 * @throws WxErrorException the wx error exception */ WxCpDocShare docShare(@NonNull String docId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.living.WxCpLivingResult; import me.chanjar.weixin.cp.bean.school.*; import java.util.List; /** * 企业微信家校应用 复学码相关接口. * https://developer.work.weixin.qq.com/document/path/93744 * <p> * 权限说明: * 仅复学码应用可以调用 * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on : 2022/5/31 9:10 */ public interface WxCpSchoolService { /** * 获取老师健康信息 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_teacher_customize_health_info?access_token=ACCESS_TOKEN * * @param date the date * @param nextKey the next key * @param limit the limit * @return teacher customize health info * @throws WxErrorException the wx error exception */ WxCpCustomizeHealthInfo getTeacherCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException; /** * 获取学生健康信息 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_student_customize_health_info?access_token=ACCESS_TOKEN * * @param date the date * @param nextKey the next key * @param limit the limit * @return student customize health info * @throws WxErrorException the wx error exception */ WxCpCustomizeHealthInfo getStudentCustomizeHealthInfo(String date, String nextKey, Integer limit) throws WxErrorException; /** * 获取师生健康码 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get_health_qrcode?access_token=ACCESS_TOKEN * * @param userIds the user ids * @param type the type * @return health qr code * @throws WxErrorException the wx error exception */ WxCpResultList getHealthQrCode(List<String> userIds, Integer type) throws WxErrorException; /** * 获取学生付款结果 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_payment_result?access_token=ACCESS_TOKEN * * @param paymentId the payment id * @return payment result * @throws WxErrorException the wx error exception */ WxCpPaymentResult getPaymentResult(String paymentId) throws WxErrorException; /** * 获取订单详情 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_trade?access_token=ACCESS_TOKEN * * @param paymentId the payment id * @param tradeNo the trade no * @return trade * @throws WxErrorException the wx error exception */ WxCpTrade getTrade(String paymentId, String tradeNo) throws WxErrorException; /** * 获取直播详情 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_living_info?access_token=ACCESS_TOKEN&livingid * =LIVINGID * * @param livingId the living id * @return living info * @throws WxErrorException the wx error exception */ WxCpSchoolLivingInfo getLivingInfo(String livingId) throws WxErrorException; /** * 获取老师直播ID列表 * 通过此接口可以获取指定老师的所有直播ID * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=ACCESS_TOKEN * * @param userId the user id * @param cursor the cursor * @param limit the limit * @return user all living id * @throws WxErrorException the wx error exception */ WxCpLivingResult.LivingIdResult getUserAllLivingId(String userId, String cursor, Integer limit) throws WxErrorException; /** * 获取观看直播统计 * 通过该接口可以获取所有观看直播的人员统计 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_watch_stat?access_token=ACCESS_TOKEN * * @param livingId the living id * @param nextKey the next key * @return watch stat * @throws WxErrorException the wx error exception */ WxCpSchoolWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException; /** * 获取未观看直播统计 * 通过该接口可以获取未观看直播的学生统计,学生的家长必须是已经关注「学校通知」才会纳入统计范围。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_unwatch_stat?access_token=ACCESS_TOKEN * * @param livingId the living id * @param nextKey the next key * @return unwatch stat * @throws WxErrorException the wx error exception */ WxCpSchoolUnwatchStat getUnwatchStat(String livingId, String nextKey) throws WxErrorException; /** * 删除直播回放 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=ACCESS_TOKEN * * @param livingId the living id * @return wx cp living result * @throws WxErrorException the wx error exception */ WxCpLivingResult deleteReplayData(String livingId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.kf.*; import java.util.List; /** * 微信客服接口 * <p> * 微信客服由腾讯微信团队为企业打造,用于满足企业的客服需求,帮助企业做好客户服务。企业可以在微信内、外各个场景中接入微信客服, * 用户可以发起咨询,企业可以进行回复。 * 企业可在微信客服官网使用企业微信扫码开通微信客服,开通后即可使用。 * * @author Fu created on 2022/1/19 19:25 */ public interface WxCpKfService { /** * 添加客服帐号,并可设置客服名称和头像。目前一家企业最多可添加10个客服帐号 * * @param add 客服帐号信息 * @return result -新创建的客服帐号ID * @throws WxErrorException 异常 */ WxCpKfAccountAddResp addAccount(WxCpKfAccountAdd add) throws WxErrorException; /** * 修改已有的客服帐号,可修改客服名称和头像。 * * @param upd 新的客服账号信息 * @return result wx cp base resp * @throws WxErrorException 异常 */ WxCpBaseResp updAccount(WxCpKfAccountUpd upd) throws WxErrorException; /** * 删除已有的客服帐号 * * @param del 要删除的客服帐号 * @return result wx cp base resp * @throws WxErrorException 异常 */ WxCpBaseResp delAccount(WxCpKfAccountDel del) throws WxErrorException; /** * 获取客服帐号列表,包括所有的客服帐号的客服ID、名称和头像。 * * @param offset 分页,偏移量, 默认为0 * @param limit 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100 * @return 客服帐号列表 wx cp kf account list resp * @throws WxErrorException 异常 */ WxCpKfAccountListResp listAccount(Integer offset, Integer limit) throws WxErrorException; /** * 企业可通过此接口获取带有不同参数的客服链接,不同客服帐号对应不同的客服链接。获取后,企业可将链接嵌入到网页等场景中, * 微信用户点击链接即可向对应的客服帐号发起咨询。企业可依据参数来识别用户的咨询来源等 * * @param link 参数 * @return 链接 account link * @throws WxErrorException 异常 */ WxCpKfAccountLinkResp getAccountLink(WxCpKfAccountLink link) throws WxErrorException; /** * 接待人员管理 * 添加指定客服帐号的接待人员,每个客服帐号目前最多可添加500个接待人员。 * * @param openKfid 客服帐号ID * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 * @return 添加客服账号结果 wx cp kf servicer op resp * @throws WxErrorException 异常 */ WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException; /** * 接待人员管理 * 添加指定客服账号的接待人员,每个客服账号目前最多可添加2000个接待人员,20个部门。 * userid_list和department_id_list至少需要填其中一个 * * @param openKfid 客服帐号ID * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 * @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 20。 * @return 添加客服账号结果 wx cp kf servicer op resp * @throws WxErrorException 异常 */ WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList,List<String> departmentIdList) throws WxErrorException; /** * 接待人员管理 * 从客服帐号删除接待人员 * * @param openKfid 客服帐号ID * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 * @return 删除客服账号结果 wx cp kf servicer op resp * @throws WxErrorException 异常 */ WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException; /** * 接待人员管理 * 从客服帐号删除接待人员 * userid_list和department_id_list至少需要填其中一个 * * @param openKfid 客服帐号ID * @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 * @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 100。超过100个需分批调用。 * @return 删除客服账号结果 wx cp kf servicer op resp * @throws WxErrorException 异常 */ WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException; /** * 接待人员管理 * 获取某个客服帐号的接待人员列表 * * @param openKfid 客服帐号ID * @return 接待人员列表 wx cp kf servicer list resp * @throws WxErrorException 异常 */ WxCpKfServicerListResp listServicer(String openKfid) throws WxErrorException; /** * 分配客服会话 * 获取会话状态 * * @param openKfid 客服帐号ID * @param externalUserId 微信客户的external_userid * @return service state * @throws WxErrorException the wx error exception */ WxCpKfServiceStateResp getServiceState(String openKfid, String externalUserId) throws WxErrorException; /** * 分配客服会话 * 变更会话状态 * * @param openKfid 客服帐号ID * @param externalUserId 微信客户的external_userid * @param serviceState 变更的目标状态,状态定义和所允许的变更可参考概述中的流程图和表格 * @param servicerUserId 接待人员的userid。第三方应用填密文userid,即open_userid。当state=3时要求必填,接待人员须处于“正在接待”中。 * @return 部分状态返回回复语code wx cp kf service state trans resp * @throws WxErrorException the wx error exception */ WxCpKfServiceStateTransResp transServiceState(String openKfid, String externalUserId, Integer serviceState, String servicerUserId) throws WxErrorException; /** * 读取消息 * 微信客户发送的消息、接待人员在企业微信回复的消息、发送消息接口发送失败事件(如被用户拒收)、客户点击菜单消息的回复消息, * 可以通过该接口获取具体的消息内容和事件。不支持读取通过发送消息接口发送的消息。 * 支持的消息类型:文本、图片、语音、视频、文件、位置、链接、名片、小程序、菜单、事件。 * * @param cursor 上一次调用时返回的next_cursor,第一次拉取可以不填。不多于64字节 * @param token 回调事件返回的token字段,10分钟内有效;可不填,如果不填接口有严格的频率限制。不多于128字节 * @param limit 期望请求的数据量,默认值和最大值都为1000。 注意:可能会出现返回条数少于limit的情况,需结合返回的has_more字段判断是否继续请求。 * @param voiceFormat 语音消息类型,0-Amr 1-Silk,默认0。可通过该参数控制返回的语音格式 * @return 微信消息 wx cp kf msg list resp * @throws WxErrorException 异常 */ @Deprecated WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat) throws WxErrorException; WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat,String open_kfid) throws WxErrorException; /** * 发送消息 * 当微信客户处于“新接入待处理”或“由智能助手接待”状态下,可调用该接口给用户发送消息。 * 注意仅当微信客户在主动发送消息给客服后的48小时内,企业可发送消息给客户,最多可发送5条消息;若用户继续发送消息,企业可再次下发消息。 * 支持发送消息类型:文本、图片、语音、视频、文件、图文、小程序、菜单消息、地理位置。 * * @param request 发送信息 * @return 发送结果 wx cp kf msg send resp * @throws WxErrorException 异常 */ WxCpKfMsgSendResp sendMsg(WxCpKfMsgSendRequest request) throws WxErrorException; /** * 发送欢迎语等事件响应消息 * 当特定的事件回调消息包含code字段,或通过接口变更到特定的会话状态,会返回code字段。 * 开发者可以此code为凭证,调用该接口给用户发送相应事件场景下的消息,如客服欢迎语、客服提示语和会话结束语等。 * 除"用户进入会话事件"以外,响应消息仅支持会话处于获取该code的会话状态时发送,如将会话转入待接入池时获得的code仅能在会话状态为”待接入池排队中“时发送。 * <p> * 目前支持的事件场景和相关约束如下: * <p> * 事件场景 允许下发条数 code有效期 支持的消息类型 获取code途径 * 用户进入会话,用于发送客服欢迎语 1条 20秒 文本、菜单 事件回调 * 进入接待池,用于发送排队提示语等 1条 48小时 文本 转接会话接口 * 从接待池接入会话,用于发送非工作 * 时间的提示语或超时未回复的提示语 * 等 1条 48小时 文本 事件回调、转接会话接口 * 结束会话,用于发送结束会话提示语 * 或满意度评价等 1条 20秒 文本、菜单 事件回调、转接会话接口 * * @param request the request * @return wx cp kf msg send resp * @throws WxErrorException the wx error exception */ WxCpKfMsgSendResp sendMsgOnEvent(WxCpKfMsgSendRequest request) throws WxErrorException; /** * 获取客户基础信息 * * @param externalUserIdList the external user id list * @return wx cp kf customer batch get resp * @throws WxErrorException the wx error exception */ WxCpKfCustomerBatchGetResp customerBatchGet(List<String> externalUserIdList) throws WxErrorException; /** * <pre> * 获取「客户数据统计」企业汇总数据 * 通过此接口,可以获取咨询会话数、咨询客户数等企业汇总统计数据 * 请求方式:POST(HTTPS) * 请求地址: * <a href="https://qyapi.weixin.qq.com/cgi-bin/kf/get_corp_statistic?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/kf/get_corp_statistic?access_token=ACCESS_TOKEN</a> * 文档地址: * <a href="https://developer.work.weixin.qq.com/document/path/95489">https://developer.work.weixin.qq.com/document/path/95489</a> * <pre> * @param request 查询参数 * @return 客户数据统计 -企业汇总数据 * @throws WxErrorException the wx error exception */ WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest request) throws WxErrorException; /** * <pre> * 获取「客户数据统计」接待人员明细数据 * 通过此接口,可获取接入人工会话数、咨询会话数等与接待人员相关的统计信息 * 请求方式:POST(HTTPS) * 请求地址: * <a href="https://qyapi.weixin.qq.com/cgi-bin/kf/get_servicer_statistic?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/kf/get_servicer_statistic?access_token=ACCESS_TOKEN</a> * 文档地址: * <a href="https://developer.work.weixin.qq.com/document/path/95490">https://developer.work.weixin.qq.com/document/path/95490</a> * <pre> * @param request 查询参数 * @return 客户数据统计 -企业汇总数据 * @throws WxErrorException the wx error exception */ WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException; // 「升级服务」配置 /** * 获取配置的专员与客户群 * * @return upgrade service config * @throws WxErrorException the wx error exception */ WxCpKfServiceUpgradeConfigResp getUpgradeServiceConfig() throws WxErrorException; /** * 升级专员服务 * * @param openKfid 客服帐号ID * @param externalUserId 微信客户的external_userid * @param userid 服务专员的userid * @param wording 推荐语 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp upgradeMemberService(String openKfid, String externalUserId, String userid, String wording) throws WxErrorException; /** * 升级客户群服务 * * @param openKfid 客服帐号ID * @param externalUserId 微信客户的external_userid * @param chatId 客户群id * @param wording 推荐语 * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp upgradeGroupchatService(String openKfid, String externalUserId, String chatId, String wording) throws WxErrorException; /** * 为客户取消推荐 * * @param openKfid 客服帐号ID * @param externalUserId 微信客户的external_userid * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp cancelUpgradeService(String openKfid, String externalUserId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; import me.chanjar.weixin.cp.bean.school.user.*; import java.util.List; /** * 企业微信家校沟通相关接口. * https://developer.work.weixin.qq.com/document/path/91638 * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on : 2022/6/18 9:10 */ public interface WxCpSchoolUserService { /** * 获取访问用户身份 * 该接口用于根据code获取成员信息 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE * * @param code the code * @return user info * @throws WxErrorException the wx error exception */ WxCpOauth2UserInfo getUserInfo(@NonNull String code) throws WxErrorException; /** * 获取家校访问用户身份 * 该接口用于根据code获取家长或者学生信息 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE * * @param code the code * @return school user info * @throws WxErrorException the wx error exception */ WxCpOauth2UserInfo getSchoolUserInfo(@NonNull String code) throws WxErrorException; /** * 创建学生 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/create_student?access_token=ACCESS_TOKEN * * @param studentUserId the student user id * @param name the name * @param departments the departments * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp createStudent(@NonNull String studentUserId, @NonNull String name, @NonNull List<Integer> departments) throws WxErrorException; /** * 批量创建学生 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_create_student?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchCreateStudent(@NonNull WxCpBatchCreateStudentRequest request) throws WxErrorException; /** * 批量删除学生 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_delete_student?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchDeleteStudent(@NonNull WxCpBatchDeleteStudentRequest request) throws WxErrorException; /** * 批量更新学生 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_update_student?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchUpdateStudent(@NonNull WxCpBatchUpdateStudentRequest request) throws WxErrorException; /** * 删除学生 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_student?access_token=ACCESS_TOKEN&userid=USERID * * @param studentUserId the student user id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp deleteStudent(@NonNull String studentUserId) throws WxErrorException; /** * 更新学生 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/update_student?access_token=ACCESS_TOKEN * * @param studentUserId the student user id * @param newStudentUserId the new student user id * @param name the name * @param departments the departments * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserId, String name, List<Integer> departments) throws WxErrorException; /** * 创建家长 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/create_parent?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp createParent(@NonNull WxCpCreateParentRequest request) throws WxErrorException; /** * 批量创建家长 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_create_parent?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchCreateParent(@NonNull WxCpBatchCreateParentRequest request) throws WxErrorException; /** * 批量删除家长 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_delete_parent?access_token=ACCESS_TOKEN * * @param userIdList the user id list * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchDeleteParent(@NonNull String... userIdList) throws WxErrorException; /** * 批量更新家长 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/batch_update_parent?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp batch result list * @throws WxErrorException the wx error exception */ WxCpBatchResultList batchUpdateParent(@NonNull WxCpBatchUpdateParentRequest request) throws WxErrorException; /** * 读取学生或家长 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get?access_token=ACCESS_TOKEN&userid=USERID * * @param userId the user id * @return user * @throws WxErrorException the wx error exception */ WxCpUserResult getUser(@NonNull String userId) throws WxErrorException; /** * 获取部门成员详情 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID * &fetch_child=FETCH_CHILD * * @param departmentId 获取的部门id * @param fetchChild 1/0:是否递归获取子部门下面的成员 * @return user list * @throws WxErrorException the wx error exception */ WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException; /** * 获取部门家长详情 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list_parent?access_token=ACCESS_TOKEN&department_id * =DEPARTMENT_ID * * @param departmentId 获取的部门id * @return user list parent * @throws WxErrorException the wx error exception */ WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException; /** * 更新家长 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/update_parent?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp updateParent(@NonNull WxCpUpdateParentRequest request) throws WxErrorException; /** * 删除家长 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_parent?access_token=ACCESS_TOKEN&userid=USERID * * @param userId the user id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp deleteParent(@NonNull String userId) throws WxErrorException; /** * 设置家校通讯录自动同步模式 * 企业和第三方可通过此接口修改家校通讯录与班级标签之间的自动同步模式,注意,一旦设置禁止自动同步,将无法再次开启。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/set_arch_sync_mode?access_token=ACCESS_TOKEN * * @param archSyncMode 家校通讯录同步模式:1-禁止将标签同步至家校通讯录,2-禁止将家校通讯录同步至标签,3-禁止家校通讯录和标签相互同步 * @return arch sync mode * @throws WxErrorException the wx error exception */ WxCpBaseResp setArchSyncMode(@NonNull Integer archSyncMode) throws WxErrorException; /** * 创建部门 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/create?access_token=ACCESS_TOKEN * * @param request 请求参数对象 * @return wx cp create department * @throws WxErrorException the wx error exception */ WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException; /** * 更新部门 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/update?access_token=ACCESS_TOKEN * * @param request the request * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException; /** * 删除部门 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/delete?access_token=ACCESS_TOKEN&id=ID * * @param id the id * @return wx cp base resp * @throws WxErrorException the wx error exception */ WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException; /** * 设置关注「学校通知」的模式 * 可通过此接口修改家长关注「学校通知」的模式:“可扫码填写资料加入”或“禁止扫码填写资料加入” * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/set_subscribe_mode?access_token=ACCESS_TOKEN * * @param subscribeMode 关注模式, 1:可扫码填写资料加入, 2:禁止扫码填写资料加入 * @return subscribe mode * @throws WxErrorException the wx error exception */ WxCpBaseResp setSubscribeMode(@NonNull Integer subscribeMode) throws WxErrorException; /** * 获取关注「学校通知」的模式 * 可通过此接口获取家长关注「学校通知」的模式:“可扫码填写资料加入”或“禁止扫码填写资料加入” * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_subscribe_mode?access_token=ACCESS_TOKEN * * @return subscribe mode * @throws WxErrorException the wx error exception */ Integer getSubscribeMode() throws WxErrorException; /** * 获取外部联系人详情 * 学校可通过此接口,根据外部联系人的userid(如何获取?),拉取外部联系人详情。 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid * =EXTERNAL_USERID * * @param externalUserId 外部联系人的userid,注意不是学校成员的帐号 * @return external contact * @throws WxErrorException the wx error exception */ WxCpExternalContact getExternalContact(@NonNull String externalUserId) throws WxErrorException; /** * 获取可使用的家长范围 * 获取可在微信「学校通知-学校应用」使用该应用的家长范围,以学生或部门列表的形式返回。应用只能给该列表下的家长发送「学校通知」。注意该范围只能由学校的系统管理员在「管理端-家校沟通-配置」配置。 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/agent/get_allow_scope?access_token=ACCESS_TOKEN&agentid=AGENTID * * @param agentId the agent id * @return allow scope * @throws WxErrorException the wx error exception */ WxCpAllowScope getAllowScope(@NonNull Integer agentId) throws WxErrorException; /** * 外部联系人openid转换 * 企业和服务商可通过此接口,将微信外部联系人的userid(如何获取?)转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/convert_to_openid?access_token=ACCESS_TOKEN * * @param externalUserId the external user id * @return string * @throws WxErrorException the wx error exception */ String convertToOpenId(@NonNull String externalUserId) throws WxErrorException; /** * 获取部门列表 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID * * @param id 部门id。获取指定部门及其下的子部门。 如果不填,默认获取全量组织架构 * @return wx cp department list * @throws WxErrorException the wx error exception */ WxCpDepartmentList listDepartment(Integer id) throws WxErrorException; /** * 获取「学校通知」二维码 * 学校可通过此接口获取「学校通知」二维码,家长可通过扫描此二维码关注「学校通知」并接收学校推送的消息。 * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_subscribe_qr_code?access_token=ACCESS_TOKEN * * @return subscribe qr code * @throws WxErrorException the wx error exception */ WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException; /** * 修改自动升年级的配置 * 请求方式: POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/set_upgrade_info?access_token=ACCESS_TOKEN * * @param upgradeTime the upgrade time * @param upgradeSwitch the upgrade switch * @return upgrade info * @throws WxErrorException the wx error exception */ WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMsgAuditService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMsgAuditService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.msgaudit.*; import java.util.List; import java.util.function.Consumer; /** * 会话内容存档接口. * 官方文档:https://developer.work.weixin.qq.com/document/path/91360 * <p> * 如需自行实现,亦可调用Finance类库函数,进行实现: * com.tencent.wework.Finance * * @author Wang_Wong created on 2022-01-14 */ public interface WxCpMsgAuditService { /** * 拉取聊天记录函数 * * @param seq 从指定的seq开始拉取消息,注意的是返回的消息从seq+1开始返回,seq为之前接口返回的最大seq值。首次使用请使用seq:0 * @param limit 一次拉取的消息条数,最大值1000条,超过1000条会返回错误 * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null * @param timeout 超时时间,根据实际需要填写 * @return 返回是否调用成功 chat datas * @throws Exception the exception */ WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, String passwd, @NonNull long timeout) throws Exception; /** * 获取解密的聊天数据Model * * @param sdk getChatDatas()获取到的sdk * @param chatData getChatDatas()获取到的聊天数据 * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... * @return 解密后的聊天数据 decrypt data * @throws Exception the exception */ WxCpChatModel getDecryptData(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, @NonNull Integer pkcs1) throws Exception; /** * 获取解密的聊天数据明文 * * @param sdk getChatDatas()获取到的sdk * @param chatData getChatDatas()获取到的聊天数据 * @param pkcs1 使用什么方式进行解密,1代表使用PKCS1进行解密,2代表PKCS8进行解密 ... * @return 解密后的明文 chat plain text * @throws Exception the exception */ String getChatPlainText(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, @NonNull Integer pkcs1) throws Exception; /** * 获取媒体文件 * 针对图片、文件等媒体数据,提供sdk接口拉取数据内容。 * <p> * 注意: * 根据上面返回的文件类型,拼接好存放文件的绝对路径即可。此时绝对路径写入文件流,来达到获取媒体文件的目的。 * 详情可以看官方文档,亦可阅读此接口源码。 * * @param sdk getChatDatas()获取到的sdk,注意,每次获取的sdk会不一样 * @param sdkfileid 消息体内容中的sdkfileid信息 * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null * @param timeout 超时时间,分片数据需累加到文件存储。单次最大返回512K字节,如果文件比较大,自行设置长一点,比如timeout=10000 * @param targetFilePath 目标文件绝对路径+实际文件名,比如:/usr/local/file/20220114/474f866b39d10718810d55262af82662.gif * @throws WxErrorException the wx error exception */ void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, @NonNull String targetFilePath) throws WxErrorException; /** * 获取媒体文件 传入一个lambda,each所有的数据分片byte[],更加灵活 * 针对图片、文件等媒体数据,提供sdk接口拉取数据内容。 * 详情可以看官方文档,亦可阅读此接口源码。 * * @param sdk getChatDatas()获取到的sdk,注意,每次获取的sdk会不一样 * @param sdkfileid 消息体内容中的sdkfileid信息 * @param proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081,如果没有传null * @param passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123,如果没有传null * @param timeout 超时时间,分片数据需累加到文件存储。单次最大返回512K字节,如果文件比较大,自行设置长一点,比如timeout=10000 * @param action 传入一个lambda,each所有的数据分片 * @throws WxErrorException the wx error exception */ void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, @NonNull Consumer<byte[]> action) throws WxErrorException; /** * 获取会话内容存档开启成员列表 * 企业可通过此接口,获取企业开启会话内容存档的成员列表 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_permit_user_list?access_token=ACCESS_TOKEN * * @param type 拉取对应版本的开启成员列表。1表示办公版;2表示服务版;3表示企业版。非必填,不填写的时候返回全量成员列表。 * @return permit user list * @throws WxErrorException the wx error exception */ List<String> getPermitUserList(Integer type) throws WxErrorException; /** * 获取会话内容存档内部群信息 * 企业可通过此接口,获取会话内容存档本企业的内部群信息,包括群名称、群主id、公告、群创建时间以及所有群成员的id与加入时间。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/groupchat/get?access_token=ACCESS_TOKEN * * @param roomid 待查询的群id * @return group chat * @throws WxErrorException the wx error exception */ WxCpGroupChat getGroupChat(@NonNull String roomid) throws WxErrorException; /** * 获取会话同意情况 * 企业可通过下述接口,获取会话中外部成员的同意情况 * <p> * 单聊请求地址:https://qyapi.weixin.qq.com/cgi-bin/msgaudit/check_single_agree?access_token=ACCESS_TOKEN * <p> * 请求方式:POST(HTTPS) * * @param checkAgreeRequest 待查询的会话信息 * @return wx cp agree info * @throws WxErrorException the wx error exception */ WxCpAgreeInfo checkSingleAgree(@NonNull WxCpCheckAgreeRequest checkAgreeRequest) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
package me.chanjar.weixin.cp.api; import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.*; import java.util.Date; import java.util.List; /** * 企业微信OA相关接口. * * @author Element & Wang_Wong created on 2019-04-06 10:52 */ public interface WxCpOaService { /** * <pre>提交审批申请 * 调试工具 * 企业可通过审批应用或自建应用Secret调用本接口,代应用可见范围内员工在企业微信“审批应用”内提交指定类型的审批申请。 * * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=ACCESS_TOKEN * <a href="https://work.weixin.qq.com/api/doc/90000/90135/91853">文档地址</a> * </pre> * * @param request 请求 * @return 表单提交成功后 ,返回的表单编号 * @throws WxErrorException . */ String apply(WxCpOaApplyEventRequest request) throws WxErrorException; /** * <pre> * 获取打卡数据 * <a href="https://work.weixin.qq.com/api/doc#90000/90135/90262">文档地址</a> * </pre> * * @param openCheckinDataType 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡 * @param startTime 获取打卡记录的开始时间 * @param endTime 获取打卡记录的结束时间 * @param userIdList 需要获取打卡记录的用户列表 * @return 打卡数据列表 checkin data * @throws WxErrorException 异常 */ List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; /** * <pre> * 获取打卡规则 * <a href="https://work.weixin.qq.com/api/doc#90000/90135/90263">文档地址</a> * </pre> * * @param datetime 需要获取规则的当天日期 * @param userIdList 需要获取打卡规则的用户列表 * @return 打卡规则列表 checkin option * @throws WxErrorException . */ List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException; /** * <pre> * 获取企业所有打卡规则 * <a href="https://work.weixin.qq.com/api/doc/90000/90135/93384">文档地址</a> * </pre> * * @return 打卡规则列表 crop checkin option * @throws WxErrorException the wx error exception */ List<WxCpCropCheckinOption> getCropCheckinOption() throws WxErrorException; /** * <pre> * * 批量获取审批单号 * * 审批应用及有权限的自建应用,可通过Secret调用本接口,以获取企业一段时间内企业微信“审批应用”单据的审批编号,支持按模板类型、申请人、部门、申请单审批状态等条件筛选。 * 自建应用调用此接口,需在“管理后台-应用管理-审批-API-审批数据权限”中,授权应用允许提交审批单据。 * * 一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 * * <a href="https://work.weixin.qq.com/api/doc/90000/90135/91816">文档地址</a> * </pre> * * @param startTime 开始时间 * @param endTime 结束时间 * @param cursor 分页查询游标,默认为0,后续使用返回的next_cursor进行分页拉取 * @param size 一次请求拉取审批单数量,默认值为100,上限值为100 * @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable * @return WxCpApprovalInfo approval info * @throws WxErrorException . */ @Deprecated WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size, List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException; /** * short method * * @param startTime 开始时间 * @param endTime 结束时间 * @return WxCpApprovalInfo approval info * @throws WxErrorException . * @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api * .WxCpOaService#getApprovalInfome.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo */ @Deprecated WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException; /** * <pre> * * 批量获取审批单号 * * 审批应用及有权限的自建应用,可通过Secret调用本接口,以获取企业一段时间内企业微信“审批应用”单据的审批编号,支持按模板类型、申请人、部门、申请单审批状态等条件筛选。 * 自建应用调用此接口,需在“管理后台-应用管理-审批-API-审批数据权限”中,授权应用允许提交审批单据。 * * 一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 * * <a href="https://work.weixin.qq.com/api/doc/90000/90135/91816">文档地址</a> * * 1 接口频率限制 600次/分钟 * 2 请求的参数endtime需要大于startime, 起始时间跨度不能超过31天; * 3 老的分页游标字段cursor和next_cursor待废弃,请开发者使用新字段new_cursor和new_next_cursor。 * </pre> * * @param startTime 开始时间 * @param endTime 结束时间 * @param newCursor 分页查询游标,默认为0,后续使用返回的next_cursor进行分页拉取 * @param size 一次请求拉取审批单数量,默认值为100,上限值为100 * @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable * @return WxCpApprovalInfo approval info * @throws WxErrorException . */ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor, Integer size, List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException; /** * <pre> * 获取审批申请详情 * * 企业可通过审批应用或自建应用Secret调用本接口,根据审批单号查询企业微信“审批应用”的审批申请详情。 * * <a href="https://work.weixin.qq.com/api/doc/90000/90135/91983">文档地址</a> * </pre> * * @param spNo 审批单编号。 * @return WxCpApprovaldetail approval detail * @throws WxErrorException . */ WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException; /** * 获取企业假期管理配置 * 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。 * 第三方应用可获取应用可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。 * <p> * 请求方式:GET(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getcorpconf?access_token=ACCESS_TOKEN * * @return corp conf * @throws WxErrorException the wx error exception */ WxCpCorpConfInfo getCorpConf() throws WxErrorException; /** * 获取成员假期余额 * 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内各个员工的假期余额数据。 * 第三方应用可获取应用可见范围内各个员工的假期余额数据。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN * * @param userId 需要获取假期余额的成员的userid * @return user vacation quota * @throws WxErrorException the wx error exception */ WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException; /** * 获取审批数据(旧) * 提示:推荐使用新接口“批量获取审批单号”及“获取审批申请详情”,此接口后续将不再维护、逐步下线。 * 通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata?access_token=ACCESS_TOKEN * * @param startTime 获取审批记录的开始时间。Unix时间戳 * @param endTime 获取审批记录的结束时间。Unix时间戳 * @param nextSpNum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 * @return approval data * @throws WxErrorException the wx error exception */ WxCpGetApprovalData getApprovalData(@NonNull Long startTime, @NonNull Long endTime, Long nextSpNum) throws WxErrorException; /** * 修改成员假期余额 * 企业可通过审批应用或自建应用Secret调用本接口,修改可见范围内员工的“假期余额”。 * 第三方应用可通过应本接口修改应用可见范围内指定员工的“假期余额”。 * <p> * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/setoneuserquota?access_token=ACCESS_TOKEN * * @param userId 需要修改假期余额的成员的userid * @param vacationId 假期id * @param leftDuration 设置的假期余额,单位为秒,不能大于1000天或24000小时,当假期时间刻度为按小时请假时,必须为360整倍数,即0.1小时整倍数,按天请假时,必须为8640整倍数,即0.1天整倍数 * @param timeAttr 假期时间刻度:0-按天请假;1-按小时请假 * @param remarks 修改备注,用于显示在假期余额的修改记录当中,可对修改行为作说明,不超过200字符 * @return one user quota * @throws WxErrorException the wx error exception */ WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, @NonNull Integer leftDuration, @NonNull Integer timeAttr, String remarks) throws WxErrorException; /** * 获取公费电话拨打记录 * * @param startTime 查询的起始时间戳 * @param endTime 查询的结束时间戳 * @param offset 分页查询的偏移量 * @param limit 分页查询的每页大小,默认为100条,如该参数大于100则按100处理 * @return . dial record * @throws WxErrorException . */ List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException; /** * 获取审批模板详情 * * @param templateId 模板ID * @return . template detail * @throws WxErrorException . */ WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException; /** * 创建审批模板 * <br> * 可以调用此接口创建审批模板。创建新模板后,管理后台及审批应用内将生成对应模板,并生效默认流程和规则配置。 * <pre> * 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/97437">https://developer.work.weixin.qq.com/document/path/97437</a> * 权限说明 * • 仅『审批』系统应用、自建应用和代开发自建应用可调用。 * </pre> * * @param cpTemplate cpTemplate * @return templateId * @throws WxErrorException . */ String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException; /** * 更新审批模板 * <br> * 可调用本接口更新审批模板。更新模板后,管理后台及审批应用内将更新原模板的内容,已配置的审批流程和规则不变。 * <pre> * 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/97438">https://developer.work.weixin.qq.com/document/path/97438</a> * 权限说明 * • 仅『审批』系统应用,自建应用和代开发自建应用可调用 * • 所有应用都可以通过本接口更新自己的模板 * • 『审批』系统应用可以修改管理员手动创建的模板 * • 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板 * </pre> * * @param wxCpTemplate wxCpTemplate * @throws WxErrorException . */ void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException; /** * 获取打卡日报数据 * * @param startTime 获取日报的开始时间 * @param endTime 获取日报的结束时间 * @param userIdList 获取日报的userid列表 * @return 日报数据列表 checkin day data * @throws WxErrorException the wx error exception */ List<WxCpCheckinDayData> getCheckinDayData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; /** * 获取打卡月报数据 * * @param startTime 获取月报的开始时间 * @param endTime 获取月报的结束时间 * @param userIdList 获取月报的userid列表 * @return 月报数据列表 checkin month data * @throws WxErrorException the wx error exception */ List<WxCpCheckinMonthData> getCheckinMonthData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; /** * 获取打卡人员排班信息 * * @param startTime 获取排班信息的开始时间。Unix时间戳 * @param endTime 获取排班信息的结束时间。Unix时间戳(与starttime跨度不超过一个月) * @param userIdList 需要获取排班信息的用户列表(不超过100个) * @return 排班表信息 checkin schedule list * @throws WxErrorException the wx error exception */ List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; /** * 为打卡人员排班 * * @param wxCpSetCheckinSchedule the wx cp set checkin schedule * @throws WxErrorException the wx error exception */ void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException; /** * <pre> * 录入打卡人员人脸信息 * 企业可通过打卡应用Secret调用本接口,为企业打卡人员录入人脸信息,人脸信息仅用于人脸打卡。 * 上传图片大小限制:图片数据不超过1M * 请求方式:POST(HTTPS) * 请求地址: * <a href="https://qyapi.weixin.qq.com/cgi-bin/checkin/addcheckinuserface?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/checkin/addcheckinuserface?access_token=ACCESS_TOKEN</a> * 文档地址: * <a href="https://developer.work.weixin.qq.com/document/path/93378">https://developer.work.weixin.qq.com/document/path/93378</a> * <pre> * @param userId 需要录入的用户id * @param userFace 需要录入的人脸图片数据,需要将图片数据base64处理后填入,对已录入的人脸会进行更新处理 * @throws WxErrorException the wx error exception */ void addCheckInUserFace(String userId, String userFace) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java
package me.chanjar.weixin.cp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.message.*; /** * 消息推送接口. * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020 -08-30 */ public interface WxCpMessageService { /** * <pre> * 发送消息 * 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/90236 * </pre> * * @param message 要发送的消息对象 * @return the wx cp message send result * @throws WxErrorException the wx error exception */ WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException; /** * <pre> * 查询应用消息发送统计 * 请求方式:POST(HTTPS) * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/message/get_statistics?access_token=ACCESS_TOKEN * * 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/92369 * </pre> * * @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。 * @return 统计结果 statistics * @throws WxErrorException the wx error exception */ WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException; /** * <pre> * 互联企业的应用支持推送文本、图片、视频、文件、图文等类型。 * * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/message/send?access_token=ACCESS_TOKEN * 文章地址:https://work.weixin.qq.com/api/doc/90000/90135/90250 * </pre> * * @param message 要发送的消息对象 * @return the wx cp message send result * @throws WxErrorException the wx error exception */ WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException; /** * 发送「学校通知」 * https://developer.work.weixin.qq.com/document/path/92321 * <p> * 学校可以通过此接口来给家长发送不同类型的学校通知,来满足多种场景下的学校通知需求。目前支持的消息类型为文本、图片、语音、视频、文件、图文。 * <p> * 请求方式:POST(HTTPS) * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/externalcontact/message/send?access_token=ACCESS_TOKEN * * @param message 要发送的消息对象 * @return wx cp school contact message send result * @throws WxErrorException the wx error exception */ WxCpSchoolContactMessageSendResult sendSchoolContactMessage(WxCpSchoolContactMessage message) throws WxErrorException; /** * <pre> * 撤回应用消息 * * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/message/recall?access_token=ACCESS_TOKEN * 文档地址: https://developer.work.weixin.qq.com/document/path/94867 * </pre> * @param msgId 消息id * @throws WxErrorException */ void recall(String msgId) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpAgentService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpAgent; import me.chanjar.weixin.cp.bean.WxCpTpAdmin; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Agent.*; /** * <pre> * 管理企业号应用 * Created by huansinho on 2018/4/13. * </pre> * * @author <a href="https://github.com/huansinho">huansinho</a> */ @RequiredArgsConstructor public class WxCpAgentServiceImpl implements WxCpAgentService { private final WxCpService mainService; @Override public WxCpAgent get(Integer agentId) throws WxErrorException { if (agentId == null) { throw new IllegalArgumentException("缺少agentid参数"); } final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId); return WxCpAgent.fromJson(this.mainService.get(url, null)); } @Override public void set(WxCpAgent agentInfo) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_SET); String responseContent = this.mainService.post(url, agentInfo.toJson()); JsonObject jsonObject = GsonParser.parse(responseContent); if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); } } @Override public List<WxCpAgent> list() throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_LIST); String responseContent = this.mainService.get(url, null); JsonObject jsonObject = GsonParser.parse(responseContent); if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); } return WxCpGsonBuilder.create().fromJson(jsonObject.get("agentlist").toString(), new TypeToken<List<WxCpAgent>>() { }.getType()); } @Override public WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException { if (agentId == null) { throw new IllegalArgumentException("缺少agentid参数"); } JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("agentid", agentId); String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET_ADMIN_LIST); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject respObj = GsonParser.parse(responseContent); if (respObj.get(WxConsts.ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); } return WxCpTpAdmin.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.apache.ApacheBasicResponseHandler; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import java.io.IOException; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_AGENT_CONFIG_TICKET; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_JSAPI_TICKET; /** * <pre> * 默认接口实现类,使用apache httpclient实现 * Created by Binary Wang on 2017-5-27. * </pre> * <pre> * 增加分布式锁(基于WxCpConfigStorage实现)的支持 * Updated by yuanqixun on 2020-05-13 * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public class WxCpServiceImpl extends WxCpServiceApacheHttpClientImpl { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { final WxCpConfigStorage configStorage = getWxCpConfigStorage(); if (!configStorage.isAccessTokenExpired() && !forceRefresh) { return configStorage.getAccessToken(); } Lock lock = configStorage.getAccessTokenLock(); lock.lock(); try { // 拿到锁之后,再次判断一下最新的token是否过期,避免重刷 if (!configStorage.isAccessTokenExpired() && !forceRefresh) { return configStorage.getAccessToken(); } String url = String.format(configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); try { HttpGet httpGet = new HttpGet(url); if (getRequestHttpProxy() != null) { RequestConfig config = RequestConfig.custom().setProxy(getRequestHttpProxy()).build(); httpGet.setConfig(config); } String resultContent = getRequestHttpClient().execute(httpGet, ApacheBasicResponseHandler.INSTANCE); WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } catch (IOException e) { throw new WxRuntimeException(e); } } finally { lock.unlock(); } return configStorage.getAccessToken(); } @Override public String getAgentJsapiTicket(boolean forceRefresh) throws WxErrorException { final WxCpConfigStorage configStorage = getWxCpConfigStorage(); if (forceRefresh) { configStorage.expireAgentJsapiTicket(); } if (configStorage.isAgentJsapiTicketExpired()) { Lock lock = configStorage.getAgentJsapiTicketLock(); lock.lock(); try { // 拿到锁之后,再次判断一下最新的token是否过期,避免重刷 if (configStorage.isAgentJsapiTicketExpired()) { String responseContent = this.get(configStorage.getApiUrl(GET_AGENT_CONFIG_TICKET), null); JsonObject jsonObject = GsonParser.parse(responseContent); configStorage.updateAgentJsapiTicket(jsonObject.get("ticket").getAsString(), jsonObject.get("expires_in").getAsInt()); } } finally { lock.unlock(); } } return configStorage.getAgentJsapiTicket(); } @Override public String getJsapiTicket(boolean forceRefresh) throws WxErrorException { final WxCpConfigStorage configStorage = getWxCpConfigStorage(); if (forceRefresh) { configStorage.expireJsapiTicket(); } if (configStorage.isJsapiTicketExpired()) { Lock lock = configStorage.getJsapiTicketLock(); lock.lock(); try { // 拿到锁之后,再次判断一下最新的token是否过期,避免重刷 if (configStorage.isJsapiTicketExpired()) { String responseContent = this.get(configStorage.getApiUrl(GET_JSAPI_TICKET), null); JsonObject tmpJsonObject = GsonParser.parse(responseContent); configStorage.updateJsapiTicket(tmpJsonObject.get("ticket").getAsString(), tmpJsonObject.get("expires_in").getAsInt()); } } finally { lock.unlock(); } } return configStorage.getJsapiTicket(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpCorpGroupService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorp; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.LIST_SHARE_APP_INFO; /** * 企业互联相关接口实现类 * * @author libo <422423229@qq.com> * Created on 27/2/2023 9:57 PM */ @RequiredArgsConstructor public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService { private final WxCpService cpService; @Override public List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException { final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("agentid", agentId); jsonObject.addProperty("corpid", corpId); jsonObject.addProperty("business_type", businessType); jsonObject.addProperty("limit", limit); jsonObject.addProperty("cursor", cursor); String responseContent = this.cpService.post(url, jsonObject); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("corp_list"), new TypeToken<List<WxCpCorpGroupCorp>>() { }.getType() ); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.cp.api.WxCpChatService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpChat; import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; 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; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Chat.*; /** * 群聊服务实现. * * @author gaigeshen */ @RequiredArgsConstructor public class WxCpChatServiceImpl implements WxCpChatService { private final WxCpService cpService; @Override public String create(String name, String owner, List<String> users, String chatId) throws WxErrorException { Map<String, Object> data = new HashMap<>(4); if (StringUtils.isNotBlank(name)) { data.put("name", name); } if (StringUtils.isNotBlank(owner)) { data.put("owner", owner); } if (users != null) { data.put("userlist", users); } if (StringUtils.isNotBlank(chatId)) { data.put("chatid", chatId); } final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_CREATE); String result = this.cpService.post(url, WxGsonBuilder.create().toJson(data)); return GsonParser.parse(result).get("chatid").getAsString(); } @Override public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException { Map<String, Object> data = new HashMap<>(5); if (StringUtils.isNotBlank(chatId)) { data.put("chatid", chatId); } if (StringUtils.isNotBlank(name)) { data.put("name", name); } if (StringUtils.isNotBlank(owner)) { data.put("owner", owner); } if (usersToAdd != null && !usersToAdd.isEmpty()) { data.put("add_user_list", usersToAdd); } if (usersToDelete != null && !usersToDelete.isEmpty()) { data.put("del_user_list", usersToDelete); } final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_UPDATE); this.cpService.post(url, WxGsonBuilder.create().toJson(data)); } @Override public WxCpChat get(String chatId) throws WxErrorException { final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_GET_CHATID + chatId); String result = this.cpService.get(url, null); final String chatInfo = GsonParser.parse(result).getAsJsonObject("chat_info").toString(); return WxCpGsonBuilder.create().fromJson(chatInfo, WxCpChat.class); } @Override public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_SEND), message.toJson()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaCalendarService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.oa.calendar.WxCpOaCalendar; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * . * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020-09-20 */ @RequiredArgsConstructor public class WxCpOaCalendarServiceImpl implements WxCpOaCalendarService { private final WxCpService wxCpService; @Override public String add(WxCpOaCalendar calendar) throws WxErrorException { return this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(CALENDAR_ADD), calendar); } @Override public void update(WxCpOaCalendar calendar) throws WxErrorException { this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(CALENDAR_UPDATE), calendar); } @Override public List<WxCpOaCalendar> get(List<String> calIds) throws WxErrorException { String response = this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(CALENDAR_GET), GsonHelper.buildJsonObject("cal_id_list", calIds)); return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("calendar_list").getAsJsonArray().toString(), new TypeToken<List<WxCpOaCalendar>>() { }.getType()); } @Override public void delete(String calId) throws WxErrorException { this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(CALENDAR_DEL), GsonHelper.buildJsonObject("cal_id", calId)); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpIntelligentRobotService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.intelligentrobot.*; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.IntelligentRobot.*; /** * 企业微信智能机器人接口实现 * * @author Binary Wang */ @RequiredArgsConstructor public class WxCpIntelligentRobotServiceImpl implements WxCpIntelligentRobotService { private final WxCpService cpService; @Override public WxCpIntelligentRobotCreateResponse createRobot(WxCpIntelligentRobotCreateRequest request) throws WxErrorException { String responseText = this.cpService.post(CREATE_ROBOT, request.toJson()); return WxCpIntelligentRobotCreateResponse.fromJson(responseText); } @Override public void deleteRobot(String robotId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("robot_id", robotId); this.cpService.post(DELETE_ROBOT, jsonObject.toString()); } @Override public void updateRobot(WxCpIntelligentRobotUpdateRequest request) throws WxErrorException { this.cpService.post(UPDATE_ROBOT, request.toJson()); } @Override public WxCpIntelligentRobot getRobot(String robotId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("robot_id", robotId); String responseText = this.cpService.post(GET_ROBOT, jsonObject.toString()); return WxCpIntelligentRobot.fromJson(responseText); } @Override public WxCpIntelligentRobotChatResponse chat(WxCpIntelligentRobotChatRequest request) throws WxErrorException { String responseText = this.cpService.post(CHAT, request.toJson()); return WxCpIntelligentRobotChatResponse.fromJson(responseText); } @Override public void resetSession(String robotId, String userid, String sessionId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("robot_id", robotId); jsonObject.addProperty("userid", userid); jsonObject.addProperty("session_id", sessionId); this.cpService.post(RESET_SESSION, jsonObject.toString()); } @Override public WxCpIntelligentRobotSendMessageResponse sendMessage(WxCpIntelligentRobotSendMessageRequest request) throws WxErrorException { String responseText = this.cpService.post(SEND_MESSAGE, request.toJson()); return WxCpIntelligentRobotSendMessageResponse.fromJson(responseText); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpMessageService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.message.*; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; /** * 消息推送接口实现类. * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020-08-30 */ @RequiredArgsConstructor public class WxCpMessageServiceImpl implements WxCpMessageService { private final WxCpService cpService; @Override public WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException { Integer agentId = message.getAgentId(); if (null == agentId) { message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId()); } return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() .getApiUrl(Message.MESSAGE_SEND), message.toJson())); } @Override public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException { return WxCpMessageSendStatistics.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(Message.GET_STATISTICS), WxCpGsonBuilder.create().toJson(ImmutableMap.of("time_type", timeType)))); } @Override public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException { Integer agentId = message.getAgentId(); if (null == agentId) { message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId()); } return WxCpLinkedCorpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() .getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson())); } @Override public WxCpSchoolContactMessageSendResult sendSchoolContactMessage(WxCpSchoolContactMessage message) throws WxErrorException { if (null == message.getAgentId()) { message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId()); } return WxCpSchoolContactMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage() .getApiUrl(Message.EXTERNAL_CONTACT_MESSAGE_SEND), message.toJson())); } @Override public void recall(String msgId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("msgid", msgId); String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(Message.MESSAGE_RECALL); this.cpService.post(apiUrl, jsonObject.toString()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaOaScheduleServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaScheduleService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.oa.WxCpOaSchedule; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信日程接口实现类. * * @author <a href="https://github.com/binarywang">Binary Wang</a> created on 2020-12-25 */ @Slf4j @RequiredArgsConstructor public class WxCpOaOaScheduleServiceImpl implements WxCpOaScheduleService { private final WxCpService cpService; @Override public String add(WxCpOaSchedule schedule, Integer agentId) throws WxErrorException { Map<String, Serializable> param; if (agentId == null) { param = ImmutableMap.of("schedule", schedule); } else { param = ImmutableMap.of("schedule", schedule, "agentid", agentId); } return this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(SCHEDULE_ADD), WxCpGsonBuilder.create().toJson(param)); } @Override public void update(WxCpOaSchedule schedule) throws WxErrorException { this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(SCHEDULE_UPDATE), WxCpGsonBuilder.create().toJson(ImmutableMap.of("schedule", schedule))); } @Override public List<WxCpOaSchedule> getDetails(List<String> scheduleIds) throws WxErrorException { final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(SCHEDULE_GET), WxCpGsonBuilder.create().toJson(ImmutableMap.of("schedule_id_list", scheduleIds))); return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("schedule_list"), new TypeToken<List<WxCpOaSchedule>>() { }.getType()); } @Override public void delete(String scheduleId) throws WxErrorException { this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(SCHEDULE_DEL), WxCpGsonBuilder.create().toJson(ImmutableMap.of("schedule_id", scheduleId))); } @Override public List<WxCpOaSchedule> listByCalendar(String calId, Integer offset, Integer limit) throws WxErrorException { final Map<String, Object> param = new HashMap<>(3); param.put("cal_id", calId); if (offset != null) { param.put("offset", offset); } if (limit != null) { param.put("limit", limit); } final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(SCHEDULE_LIST), WxCpGsonBuilder.create().toJson(param)); return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("schedule_list"), new TypeToken<List<WxCpOaSchedule>>() { }.getType()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolHealthServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolHealthServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpSchoolHealthService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportAnswer; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds; import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo; import java.util.Optional; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; /** * 企业微信家校应用 健康上报接口实现类. * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on : 2022/5/31 9:16 */ @Slf4j @RequiredArgsConstructor public class WxCpSchoolHealthServiceImpl implements WxCpSchoolHealthService { private final WxCpService cpService; @Override public WxCpGetHealthReportStat getHealthReportStat(@NonNull String date) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_HEALTH_REPORT_STAT); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", date); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGetHealthReportStat.fromJson(responseContent); } @Override public WxCpGetReportJobIds getReportJobIds(Integer offset, Integer limit) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_JOBIDS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("offset", Optional.ofNullable(offset).orElse(0)); jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGetReportJobIds.fromJson(responseContent); } @Override public WxCpGetReportJobInfo getReportJobInfo(@NonNull String jobId, @NonNull String date) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_JOB_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("jobid", jobId); jsonObject.addProperty("date", date); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGetReportJobInfo.fromJson(responseContent); } @Override public WxCpGetReportAnswer getReportAnswer(@NonNull String jobId, @NonNull String date, Integer offset, Integer limit) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_REPORT_ANSWER); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("jobid", jobId); jsonObject.addProperty("date", date); if (offset != null) { jsonObject.addProperty("offset", offset); } if (limit != null) { jsonObject.addProperty("limit", limit); } String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGetReportAnswer.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpOaWeDriveService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.wedrive.*; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信微盘接口实现类. * * @author Wang_Wong created on 2022-04-22 */ @Slf4j @RequiredArgsConstructor public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { private final WxCpService cpService; @Override public WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_CREATE); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpSpaceCreateData.fromJson(responseContent); } @Override public WxCpBaseResp spaceRename(@NonNull WxCpSpaceRenameRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_RENAME); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp spaceDismiss(@NonNull String spaceId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_DISMISS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("spaceid", spaceId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpSpaceInfo spaceInfo(@NonNull String spaceId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("spaceid", spaceId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpSpaceInfo.fromJson(responseContent); } @Override public WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_ADD); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_DEL); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp spaceSetting(@NonNull WxCpSpaceSettingRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_SETTING); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpSpaceShare spaceShare(@NonNull String spaceId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_SHARE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("spaceid", spaceId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpSpaceShare.fromJson(responseContent); } @Override public WxCpFileList fileList(@NonNull WxCpFileListRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_LIST); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpFileList.fromJson(responseContent); } @Override public WxCpFileUpload fileUpload(@NonNull WxCpFileUploadRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_UPLOAD); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpFileUpload.fromJson(responseContent); } @Override public WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fileId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DOWNLOAD); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); jsonObject.addProperty("fileid", fileId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileDownload.fromJson(responseContent); } @Override public WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_RENAME); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("fileid", fileId); jsonObject.addProperty("new_name", newName); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileRename.fromJson(responseContent); } @Override public WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_CREATE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("spaceid", spaceId); jsonObject.addProperty("fatherid", fatherId); jsonObject.addProperty("file_type", fileType); jsonObject.addProperty("file_name", fileName); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileCreate.fromJson(responseContent); } @Override public WxCpFileMove fileMove(@NonNull WxCpFileMoveRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_MOVE); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpFileMove.fromJson(responseContent); } @Override public WxCpBaseResp fileDelete(@NonNull List<String> fileIds) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DELETE); WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(fileIds); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_ADD); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_DEL); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp fileSetting(@NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SETTING); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("fileid", fileId); jsonObject.addProperty("auth_scope", authScope); if (auth != null) { jsonObject.addProperty("auth", auth); } String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpFileShare fileShare(@NonNull String fileId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SHARE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("fileid", fileId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileShare.fromJson(responseContent); } @Override public WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("fileid", fileId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileInfo.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaAgentService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_OPEN_APPROVAL_DATA; /** * 企业微信自建应用接口实现类. * * @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a> created on 2022-04-06 */ @Slf4j @RequiredArgsConstructor public class WxCpOaAgentServiceImpl implements WxCpOaAgentService { private final WxCpService cpService; @Override public WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("thirdNo", thirdNo); String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_OPEN_APPROVAL_DATA); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGsonBuilder.create() .fromJson(GsonParser.parse(responseContent).get("data"), new TypeToken<WxCpOpenApprovalData>() { }.getType() ); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolUserServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolUserServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpSchoolUserService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; import me.chanjar.weixin.cp.bean.school.user.*; import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Objects; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; /** * 企业微信家校沟通相关接口. * https://developer.work.weixin.qq.com/document/path/91638 * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on : 2022/6/18 9:10 */ @Slf4j @RequiredArgsConstructor public class WxCpSchoolUserServiceImpl implements WxCpSchoolUserService { private final WxCpService cpService; @Override public WxCpOauth2UserInfo getUserInfo(@NonNull String code) throws WxErrorException { return cpService.getOauth2Service().getUserInfo(code); } @Override public WxCpOauth2UserInfo getSchoolUserInfo(@NonNull String code) throws WxErrorException { return cpService.getOauth2Service().getSchoolUserInfo(code); } @Override public WxCpBaseResp createStudent(@NonNull String studentUserId, @NonNull String name, @NonNull List<Integer> departments) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE_STUDENT); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("student_userid", studentUserId); jsonObject.addProperty("name", name); JsonArray jsonArray = new JsonArray(); for (Integer depart : departments) { jsonArray.add(new JsonPrimitive(depart)); } jsonObject.add("department", jsonArray); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBatchResultList batchCreateStudent(@NonNull WxCpBatchCreateStudentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_CREATE_STUDENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpBatchResultList batchDeleteStudent(@NonNull WxCpBatchDeleteStudentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_DELETE_STUDENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpBatchResultList batchUpdateStudent(@NonNull WxCpBatchUpdateStudentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_UPDATE_STUDENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpBaseResp deleteStudent(@NonNull String studentUserId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_STUDENT) + studentUserId; String responseContent = this.cpService.get(apiUrl, null); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserId, String name, List<Integer> departments) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_STUDENT); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("student_userid", studentUserId); if (StringUtils.isNotEmpty(newStudentUserId)) { jsonObject.addProperty("new_student_userid", newStudentUserId); } if (StringUtils.isNotEmpty(name)) { jsonObject.addProperty("name", name); } if (departments != null && !departments.isEmpty()) { JsonArray jsonArray = new JsonArray(); for (Integer depart : departments) { jsonArray.add(new JsonPrimitive(depart)); } jsonObject.add("department", jsonArray); } String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp createParent(@NonNull WxCpCreateParentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE_PARENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBatchResultList batchCreateParent(@NonNull WxCpBatchCreateParentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_CREATE_PARENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpBatchResultList batchDeleteParent(@NonNull String... userIdList) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_DELETE_PARENT); JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String userId : userIdList) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("useridlist", jsonArray); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpBatchResultList batchUpdateParent(@NonNull WxCpBatchUpdateParentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(BATCH_UPDATE_PARENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBatchResultList.fromJson(responseContent); } @Override public WxCpUserResult getUser(@NonNull String userId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER) + userId; String responseContent = this.cpService.get(apiUrl, null); return WxCpUserResult.fromJson(responseContent); } @Override public WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException { String apiUrl = String.format(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST), departmentId, fetchChild); String responseContent = this.cpService.get(apiUrl, null); return WxCpUserListResult.fromJson(responseContent); } @Override public WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST_PARENT) + departmentId; String responseContent = this.cpService.get(apiUrl, null); return WxCpListParentResult.fromJson(responseContent); } @Override public WxCpBaseResp updateParent(@NonNull WxCpUpdateParentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_PARENT); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp deleteParent(@NonNull String userId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_PARENT) + userId; String responseContent = this.cpService.get(apiUrl, null); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp setArchSyncMode(@NonNull Integer archSyncMode) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_ARCH_SYNC_MODE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("arch_sync_mode", archSyncMode); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_CREATE); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpCreateDepartment.fromJson(responseContent); } @Override public WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_UPDATE); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_DELETE) + id; String responseContent = this.cpService.get(apiUrl, null); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp setSubscribeMode(@NonNull Integer subscribeMode) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_SUBSCRIBE_MODE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("subscribe_mode", subscribeMode); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public Integer getSubscribeMode() throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_SUBSCRIBE_MODE); String responseContent = this.cpService.get(apiUrl, null); return GsonParser.parse(responseContent).get("subscribe_mode").getAsInt(); } @Override public WxCpExternalContact getExternalContact(@NonNull String externalUserId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(EXTERNAL_CONTACT_GET) + externalUserId; String responseContent = this.cpService.get(apiUrl, null); return WxCpExternalContact.fromJson(responseContent); } @Override public WxCpAllowScope getAllowScope(@NonNull Integer agentId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_ALLOW_SCOPE) + agentId; String responseContent = this.cpService.get(apiUrl, null); return WxCpAllowScope.fromJson(responseContent); } @Override public String convertToOpenId(@NonNull String externalUserId) throws WxErrorException { return cpService.getExternalContactService().convertToOpenid(externalUserId); } @Override public WxCpDepartmentList listDepartment(Integer id) throws WxErrorException { String apiUrl = Objects.isNull(id) ? this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST) : String.format("%s?id=%s", this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST), id); String responseContent = this.cpService.get(apiUrl, null); return WxCpDepartmentList.fromJson(responseContent); } @Override public WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_SUBSCRIBE_QR_CODE); String responseContent = this.cpService.get(apiUrl, null); return WxCpSubscribeQrCode.fromJson(responseContent); } @Override public WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_UPGRADE_INFO); JsonObject jsonObject = new JsonObject(); if (upgradeTime != null) { jsonObject.addProperty("upgrade_time", upgradeTime); } if (upgradeSwitch != null) { jsonObject.addProperty("upgrade_switch", upgradeSwitch); } String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpSetUpgradeInfo.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDocServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDocServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpOaWeDocService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.doc.*; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信微盘接口实现类. * * @author Wang_Wong created on 2022-04-22 */ @Slf4j @RequiredArgsConstructor public class WxCpOaWeDocServiceImpl implements WxCpOaWeDocService { private final WxCpService cpService; @Override public WxCpDocCreateData docCreate(@NonNull WxCpDocCreateRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_CREATE_DOC); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpDocCreateData.fromJson(responseContent); } @Override public WxCpBaseResp docRename(@NonNull WxCpDocRenameRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_RENAME_DOC); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp docDelete(String docId, String formId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DEL_DOC); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("docid", docId); jsonObject.addProperty("formid", formId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpDocInfo docInfo(@NonNull String docId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_DOC_BASE_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("docid", docId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpDocInfo.fromJson(responseContent); } @Override public WxCpDocShare docShare(@NonNull String docId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DOC_SHARE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("docid", docId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpDocShare.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOnTpImpl.java
package me.chanjar.weixin.cp.api.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.tp.service.WxCpTpService; /** * <pre> * 默认接口实现类,使用apache httpclient实现,配合第三方应用service使用 * Created by zhenjun cai. * </pre> * * @author zhenjun cai */ @RequiredArgsConstructor public class WxCpServiceOnTpImpl extends WxCpServiceApacheHttpClientImpl { private final WxCpTpService wxCpTpService; @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isAccessTokenExpired() && !forceRefresh) { return this.configStorage.getAccessToken(); } //access token通过第三方应用service获取 //corpSecret对应企业永久授权码 WxAccessToken accessToken = wxCpTpService.getCorpToken(this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); return this.configStorage.getAccessToken(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceHttpComponentsImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceHttpComponentsImpl.java
package me.chanjar.weixin.cp.api.impl; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.hc.BasicResponseHandler; import me.chanjar.weixin.common.util.http.hc.DefaultHttpComponentsClientBuilder; import me.chanjar.weixin.common.util.http.hc.HttpComponentsClientBuilder; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.core5.http.HttpHost; import java.io.IOException; /** * The type Wx cp service apache http client. * * @author altusea */ public class WxCpServiceHttpComponentsImpl extends BaseWxCpServiceImpl<CloseableHttpClient, HttpHost> { private CloseableHttpClient httpClient; private HttpHost httpProxy; @Override public CloseableHttpClient getRequestHttpClient() { return httpClient; } @Override public HttpHost getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.HTTP_COMPONENTS; } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isAccessTokenExpired() && !forceRefresh) { return this.configStorage.getAccessToken(); } synchronized (this.globalAccessTokenRefreshLock) { String url = String.format(this.configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); try { HttpGet httpGet = new HttpGet(url); if (this.httpProxy != null) { RequestConfig config = RequestConfig.custom() .setProxy(this.httpProxy).build(); httpGet.setConfig(config); } String resultContent = getRequestHttpClient().execute(httpGet, BasicResponseHandler.INSTANCE); WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } catch (IOException e) { throw new WxRuntimeException(e); } } return this.configStorage.getAccessToken(); } @Override public void initHttp() { HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get(); apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost()) .httpProxyPort(this.configStorage.getHttpProxyPort()) .httpProxyUsername(this.configStorage.getHttpProxyUsername()) .httpProxyPassword(this.configStorage.getHttpProxyPassword().toCharArray()); if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(this.configStorage.getHttpProxyHost(), this.configStorage.getHttpProxyPort()); } this.httpClient = apacheHttpClientBuilder.build(); } @Override public WxCpConfigStorage getWxCpConfigStorage() { return this.configStorage; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTagServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpTagService; import me.chanjar.weixin.cp.bean.WxCpTag; import me.chanjar.weixin.cp.bean.WxCpTagAddOrRemoveUsersResult; import me.chanjar.weixin.cp.bean.WxCpTagGetResult; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tag.*; /** * <pre> * 标签管理接口. * Created by Binary Wang on 2017-6-25. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @RequiredArgsConstructor public class WxCpTagServiceImpl implements WxCpTagService { private final WxCpService mainService; @Override public String create(String name, Integer id) throws WxErrorException { JsonObject o = new JsonObject(); o.addProperty("tagname", name); if (id != null) { o.addProperty("tagid", id); } return this.create(o); } private String create(JsonObject param) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_CREATE); String responseContent = this.mainService.post(url, param.toString()); JsonObject jsonObject = GsonParser.parse(responseContent); return jsonObject.get("tagid").getAsString(); } @Override public void update(String tagId, String tagName) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_UPDATE); JsonObject o = new JsonObject(); o.addProperty("tagid", tagId); o.addProperty("tagname", tagName); this.mainService.post(url, o.toString()); } @Override public void delete(String tagId) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_DELETE), tagId); this.mainService.get(url, null); } @Override public List<WxCpTag> listAll() throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_LIST); String responseContent = this.mainService.get(url, null); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson( tmpJson.get("taglist"), new TypeToken<List<WxCpTag>>() { }.getType() ); } @Override public List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_GET), tagId); String responseContent = this.mainService.get(url, null); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson( tmpJson.get("userlist"), new TypeToken<List<WxCpUser>>() { }.getType() ); } @Override public WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_ADD_TAG_USERS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("tagid", tagId); this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(url, jsonObject.toString())); } @Override public WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_DEL_TAG_USERS); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("tagid", tagId); this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(url, jsonObject.toString())); } private void addUserIdsAndPartyIdsToJson(List<String> userIds, List<String> partyIds, JsonObject jsonObject) { if (userIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("userlist", jsonArray); } if (partyIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : partyIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("partylist", jsonArray); } } @Override public WxCpTagGetResult get(String tagId) throws WxErrorException { if (tagId == null) { throw new IllegalArgumentException("缺少tagId参数"); } String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_GET), tagId); String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOMailServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOMailServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpOaMailService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailCommonSendRequest; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailMeetingSendRequest; import me.chanjar.weixin.cp.bean.oa.mail.WxCpMailScheduleSendRequest; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.EXMAIL_APP_COMPOSE_SEND; /** * 企业微信邮件接口实现类. * * @author Hugo */ @Slf4j @RequiredArgsConstructor public class WxCpOMailServiceImpl implements WxCpOaMailService { private final WxCpService cpService; /** * 发送普通邮件 * 应用可以通过该接口发送普通邮件,支持附件能力。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送普通邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ @Override public WxCpBaseResp mailCommonSend(@NonNull WxCpMailCommonSendRequest request) throws WxErrorException { return this.mailSend(request.toJson()); } /** * 发送日程邮件 * 应用可以通过该接口发送日程邮件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送日程邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ @Override public WxCpBaseResp mailScheduleSend(@NonNull WxCpMailScheduleSendRequest request) throws WxErrorException { return this.mailSend(request.toJson()); } /** * 发送会议邮件 * 应用可以通过该接口发送会议邮件。 * <p> * 请求方式:POST(HTTPS) * 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/exmail/app/compose_send?access_token=ACCESS_TOKEN">...</a> * * @param request 发送会议邮件请求参数 * @return wx cp base resp * @throws WxErrorException the wx error exception */ @Override public WxCpBaseResp mailMeetingSend(@NonNull WxCpMailMeetingSendRequest request) throws WxErrorException { return this.mailSend(request.toJson()); } private WxCpBaseResp mailSend(String request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(EXMAIL_APP_COMPOSE_SEND); String responseContent = this.cpService.post(apiUrl, request); return WxCpBaseResp.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
package me.chanjar.weixin.cp.api.impl; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import okhttp3.*; import java.io.IOException; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_TOKEN; /** * The type Wx cp service ok http. * * @author someone */ @Slf4j public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkHttpProxyInfo> { private OkHttpClient httpClient; private OkHttpProxyInfo httpProxy; @Override public OkHttpClient getRequestHttpClient() { return httpClient; } @Override public OkHttpProxyInfo getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.OK_HTTP; } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { if (!this.configStorage.isAccessTokenExpired() && !forceRefresh) { return this.configStorage.getAccessToken(); } synchronized (this.globalAccessTokenRefreshLock) { //得到httpClient OkHttpClient client = getRequestHttpClient(); //请求的request Request request = new Request.Builder() .url(String.format(this.configStorage.getApiUrl(GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret())) .get() .build(); String resultContent = null; try { Response response = client.newCall(request).execute(); resultContent = response.body().string(); } catch (IOException e) { log.error(e.getMessage(), e); } WxError error = WxError.fromJson(resultContent, WxType.CP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } return this.configStorage.getAccessToken(); } @Override public void initHttp() { log.debug("WxCpServiceOkHttpImpl initHttp"); //设置代理 if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); //设置授权 clientBuilder.proxyAuthenticator(new Authenticator() { @Override public Request authenticate(Route route, Response response) throws IOException { String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); return response.request().newBuilder() .header("Proxy-Authorization", credential) .build(); } }); httpClient = clientBuilder.build(); } else { httpClient = DefaultOkHttpClientBuilder.get().build(); } } @Override public WxCpConfigStorage getWxCpConfigStorage() { return this.configStorage; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentWorkBenchServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpAgentWorkBenchService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpAgentWorkBench; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.WorkBench.*; /** * 工作台自定义展示实现 * * @author songshiyu * created at 11:24 2020/9/28 */ @RequiredArgsConstructor public class WxCpAgentWorkBenchServiceImpl implements WxCpAgentWorkBenchService { private final WxCpService mainService; @Override public void setWorkBenchTemplate(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException { final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_TEMPLATE_SET)); this.mainService.post(url, wxCpAgentWorkBench.toTemplateString()); } @Override public String getWorkBenchTemplate(Long agentId) throws WxErrorException { final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_TEMPLATE_GET)); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("agentid", agentId); return this.mainService.post(url, jsonObject.toString()); } @Override public void setWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException { final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_DATA_SET)); this.mainService.post(url, wxCpAgentWorkBench.toUserDataString()); } @Override public void batchSetWorkBenchData(WxCpAgentWorkBench wxCpAgentWorkBench) throws WxErrorException { final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WORKBENCH_BATCH_DATA_SET)); this.mainService.post(url, wxCpAgentWorkBench.toBatchUserDataString()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.common.collect.ImmutableMap; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpMeetingService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.HashMap; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信日程接口. * 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。 * 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。 * 官方文档:https://developer.work.weixin.qq.com/document/path/93626 * * @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31 */ @RequiredArgsConstructor public class WxCpMeetingServiceImpl implements WxCpMeetingService { private final WxCpService cpService; @Override public String create(WxCpMeeting meeting) throws WxErrorException { return this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_ADD), WxCpGsonBuilder.create().toJson(meeting)); } @Override public WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException { final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_UPDATE), WxCpGsonBuilder.create().toJson(meeting)); return WxCpGsonBuilder.create().fromJson(response, WxCpMeetingUpdateResult.class); } @Override public void cancel(String meetingId) throws WxErrorException { this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_CANCEL), WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId))); } @Override public WxCpMeeting getDetail(String meetingId) throws WxErrorException { final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_DETAIL), WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId))); return WxCpGsonBuilder.create().fromJson(response, WxCpMeeting.class); } @Override public WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit, Long beginTime, Long endTime) throws WxErrorException { final Map<String, Object> param = new HashMap<>(3); param.put("userid", userId); if (cursor != null) { param.put("cursor", cursor); } if (limit != null) { param.put("limit", limit); } if (beginTime != null) { param.put("begin_time", beginTime); } if (endTime != null) { param.put("end_time", endTime); } final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_MEETING_ID), WxCpGsonBuilder.create().toJson(param)); return WxCpGsonBuilder.create().fromJson(response, WxCpUserMeetingIdResult.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.common.collect.Maps; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpUserService; import me.chanjar.weixin.cp.bean.WxCpInviteResult; import me.chanjar.weixin.cp.bean.WxCpOpenUseridToUseridResult; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult; import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo; import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.time.FastDateFormat; import java.text.Format; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.User.*; /** * <pre> * Created by BinaryWang on 2017/6/24. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @RequiredArgsConstructor public class WxCpUserServiceImpl implements WxCpUserService { private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd"); private final WxCpService mainService; @Override public void authenticate(String userId) throws WxErrorException { this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(USER_AUTHENTICATE + userId), null); } @Override public void create(WxCpUser user) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CREATE); this.mainService.post(url, user.toJson()); } @Override public void update(WxCpUser user) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_UPDATE); this.mainService.post(url, user.toJson()); } @Override public void delete(String... userIds) throws WxErrorException { if (userIds.length == 1) { String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_DELETE + userIds[0]); this.mainService.get(url, null); return; } JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("useridlist", jsonArray); this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(USER_BATCH_DELETE), jsonObject.toString()); } @Override public WxCpUser getById(String userid) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_GET + userid); String responseContent = this.mainService.get(url, null); return WxCpUser.fromJson(responseContent); } @Override public List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { String params = ""; if (fetchChild != null) { params += "&fetch_child=" + (fetchChild ? "1" : "0"); } if (status != null) { params += "&status=" + status; } else { params += "&status=0"; } String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST + departId); String responseContent = this.mainService.get(url, params); JsonObject jsonObject = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson(jsonObject.get("userlist"), new TypeToken<List<WxCpUser>>() { }.getType() ); } @Override public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { String params = ""; if (fetchChild != null) { params += "&fetch_child=" + (fetchChild ? "1" : "0"); } if (status != null) { params += "&status=" + status; } else { params += "&status=0"; } String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_SIMPLE_LIST + departId); String responseContent = this.mainService.get(url, params); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson( tmpJson.get("userlist"), new TypeToken<List<WxCpUser>>() { }.getType() ); } @Override public WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException { JsonObject jsonObject = new JsonObject(); if (userIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("user", jsonArray); } if (partyIds != null) { JsonArray jsonArray = new JsonArray(); for (String userId : partyIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("party", jsonArray); } if (tagIds != null) { JsonArray jsonArray = new JsonArray(); for (String tagId : tagIds) { jsonArray.add(new JsonPrimitive(tagId)); } jsonObject.add("tag", jsonArray); } String url = this.mainService.getWxCpConfigStorage().getApiUrl(BATCH_INVITE); return WxCpInviteResult.fromJson(this.mainService.post(url, jsonObject.toString())); } @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CONVERT_TO_OPENID); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJson.get("openid") != null) { result.put("openid", tmpJson.get("openid").getAsString()); } if (tmpJson.get("appid") != null) { result.put("appid", tmpJson.get("appid").getAsString()); } return result; } @Override public String openid2UserId(String openid) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("openid", openid); String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CONVERT_TO_USERID); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("userid").getAsString(); } @Override public String getUserId(String mobile) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("mobile", mobile); String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_ID); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("userid").getAsString(); } @Override public String getUserIdByEmail(String email, int emailType) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("email", email); jsonObject.addProperty("email_type", emailType); String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_ID_BY_EMAIL); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("userid").getAsString(); } @Override public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); String responseContent = this.mainService.get(url, null); return WxCpExternalContactInfo.fromJson(responseContent); } @Override public String getJoinQrCode(int sizeType) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_JOIN_QR_CODE + sizeType); String responseContent = this.mainService.get(url, null); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("join_qrcode").getAsString(); } @Override public Integer getActiveStat(Date date) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", this.dateFormat.format(date)); String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_ACTIVE_STAT); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("active_cnt").getAsInt(); } @Override public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException { JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String userid : useridList) { jsonArray.add(userid); } jsonObject.add("userid_list", jsonArray); String url = this.mainService.getWxCpConfigStorage().getApiUrl(USERID_TO_OPEN_USERID); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpUseridToOpenUseridResult.fromJson(responseContent); } @Override public WxCpOpenUseridToUseridResult openUseridToUserid(List<String> openUseridList, String sourceAgentId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (String openUserid : openUseridList) { jsonArray.add(openUserid); } jsonObject.add("open_userid_list", jsonArray); jsonObject.addProperty("source_agentid", sourceAgentId); String url = this.mainService.getWxCpConfigStorage().getApiUrl(OPEN_USERID_TO_USERID); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpOpenUseridToUseridResult.fromJson(responseContent); } @Override public WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException { String apiUrl = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST_ID); JsonObject jsonObject = new JsonObject(); if (cursor != null) { jsonObject.addProperty("cursor", cursor); } if (limit != null) { jsonObject.addProperty("limit", limit); } String responseContent = this.mainService.post(apiUrl, jsonObject.toString()); return WxCpDeptUserResult.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import lombok.NonNull; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.oa.*; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.StringUtils; import java.util.Date; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; /** * 企业微信 OA 接口实现 * * @author Element created on 2019-04-06 11:20 */ @RequiredArgsConstructor public class WxCpOaServiceImpl implements WxCpOaService { private final WxCpService mainService; private static final int MONTH_SECONDS = 31 * 24 * 60 * 60; private static final int USER_IDS_LIMIT = 100; @Override public String apply(WxCpOaApplyEventRequest request) throws WxErrorException { String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(APPLY_EVENT), request.toJson()); return GsonParser.parse(responseContent).get("sp_no").getAsString(); } @Override public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, @NonNull Date startTime, @NonNull Date endTime, List<String> userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); } long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp > MONTH_SECONDS) { throw new WxRuntimeException("获取记录时间跨度不超过一个月"); } 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); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("checkindata"), new TypeToken<List<WxCpCheckinData>>() { }.getType() ); } @Override public List<WxCpCheckinOption> getCheckinOption(@NonNull Date datetime, List<String> userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); } 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); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("info"), new TypeToken<List<WxCpCheckinOption>>() { }.getType() ); } @Override public List<WxCpCropCheckinOption> getCropCheckinOption() throws WxErrorException { JsonObject jsonObject = new JsonObject(); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_CHECKIN_OPTION); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("group"), new TypeToken<List<WxCpCropCheckinOption>>() { }.getType() ); } @Override public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size, List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException { if (cursor == null) { cursor = 0; } if (size == null) { size = 100; } if (size < 0 || size > 100) { throw new IllegalArgumentException("size参数错误,请使用[1-100]填充,默认100"); } JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("starttime", startTime.getTime() / 1000L); jsonObject.addProperty("endtime", endTime.getTime() / 1000L); jsonObject.addProperty("size", size); jsonObject.addProperty("cursor", cursor); if (filters != null && !filters.isEmpty()) { JsonArray filterJsonArray = new JsonArray(); for (WxCpApprovalInfoQueryFilter filter : filters) { filterJsonArray.add(JsonParser.parseString(filter.toJson())); } jsonObject.add("filters", filterJsonArray); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_INFO); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalInfo.class); } @Override public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException { return this.getApprovalInfo(startTime, endTime, 0, null, null); } @Override public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor, Integer size, List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException { if (newCursor == null) { newCursor = ""; } if (size == null) { size = 100; } if (size < 0 || size > 100) { throw new IllegalArgumentException("size参数错误,请使用[1-100]填充,默认100"); } JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("starttime", startTime.getTime() / 1000L); jsonObject.addProperty("endtime", endTime.getTime() / 1000L); jsonObject.addProperty("size", size); jsonObject.addProperty("new_cursor", newCursor); if (filters != null && !filters.isEmpty()) { JsonArray filterJsonArray = new JsonArray(); for (WxCpApprovalInfoQueryFilter filter : filters) { filterJsonArray.add(JsonParser.parseString(filter.toJson())); } jsonObject.add("filters", filterJsonArray); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_INFO); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalInfo.class); } @Override public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("sp_no", spNo); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DETAIL); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); } @Override public WxCpCorpConfInfo getCorpConf() throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_CONF); String responseContent = this.mainService.get(url, null); return WxCpCorpConfInfo.fromJson(responseContent); } @Override public WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_VACATION_QUOTA); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpUserVacationQuota.fromJson(responseContent); } @Override public WxCpGetApprovalData getApprovalData(@NonNull Long startTime, @NonNull Long endTime, Long nextSpNum) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("starttime", startTime); jsonObject.addProperty("endtime", endTime); if (nextSpNum != null) { jsonObject.addProperty("next_spnum", nextSpNum); } String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGetApprovalData.fromJson(responseContent); } @Override public WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, @NonNull Integer leftDuration, @NonNull Integer timeAttr, String remarks) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_ONE_USER_QUOTA); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); jsonObject.addProperty("vacation_id", vacationId); jsonObject.addProperty("leftduration", leftDuration); jsonObject.addProperty("time_attr", timeAttr); if (StringUtils.isNotEmpty(remarks)) { jsonObject.addProperty("remarks", remarks); } String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpBaseResp.fromJson(responseContent); } @Override public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException { 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 >= MONTH_SECONDS) { throw new WxRuntimeException("受限于网络传输,起止时间的最大跨度为30天,如超过30天,则以结束时间为基准向前取30天进行查询"); } jsonObject.addProperty("start_time", starttimestamp); jsonObject.addProperty("end_time", endtimestamp); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("record"), new TypeToken<List<WxCpDialRecord>>() { }.getType() ); } @Override public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id", templateId); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL); String responseContent = this.mainService.post(url, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class); } @Override public String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CREATE_TEMPLATE); String responseContent = this.mainService.post(url, WxCpGsonBuilder.create().toJson(cpTemplate)); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("template_id").getAsString(); } @Override public void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE); this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplate)); } @Override public List<WxCpCheckinDayData> getCheckinDayData(@NonNull Date startTime, @NonNull Date endTime, List<String> userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); } long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonObject.addProperty("starttime", startTimestamp); jsonObject.addProperty("endtime", endTimestamp); for (String userid : userIdList) { jsonArray.add(userid); } jsonObject.add("useridlist", jsonArray); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DAY_DATA); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("datas"), new TypeToken<List<WxCpCheckinDayData>>() { }.getType() ); } @Override public List<WxCpCheckinMonthData> getCheckinMonthData(@NonNull Date startTime, @NonNull Date endTime, List<String> userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); } long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonObject.addProperty("starttime", startTimestamp); jsonObject.addProperty("endtime", endTimestamp); for (String userid : userIdList) { jsonArray.add(userid); } jsonObject.add("useridlist", jsonArray); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_MONTH_DATA); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("datas"), new TypeToken<List<WxCpCheckinMonthData>>() { }.getType() ); } @Override public List<WxCpCheckinSchedule> getCheckinScheduleList(@NonNull Date startTime, @NonNull Date endTime, List<String> userIdList) throws WxErrorException { if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) { throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取"); } long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonObject.addProperty("starttime", startTimestamp); jsonObject.addProperty("endtime", endTimestamp); for (String userid : userIdList) { jsonArray.add(userid); } jsonObject.add("useridlist", jsonArray); final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_SCHEDULE_DATA); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create().fromJson(tmpJson.get("schedule_list"), new TypeToken<List<WxCpCheckinSchedule>>() { }.getType() ); } @Override public void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException { final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_CHECKIN_SCHEDULE_DATA); this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpSetCheckinSchedule)); } @Override public void addCheckInUserFace(String userId, String userFace) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); jsonObject.addProperty("userface", userFace); String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CHECK_IN_USER_FACE); this.mainService.post(url, jsonObject.toString()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
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 me.chanjar.weixin.cp.bean.message.TemplateCardMessage; import java.util.HashMap; import java.util.List; import java.util.Map; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.UPDATE_TASK_CARD; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.UPDATE_TEMPLATE_CARD; /** * <pre> * 任务卡片管理接口. * Created by Jeff on 2019-05-16. * </pre> * * @author <a href="https://github.com/domainname">Jeff</a> created on 2019-05-16 */ @RequiredArgsConstructor public class WxCpTaskCardServiceImpl implements WxCpTaskCardService { private final WxCpService mainService; @Override public void update(List<String> userIds, String taskId, String replaceName) 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); // 文档地址:https://open.work.weixin.qq.com/wwopen/devtool/interface?doc_id=16386 data.put("clicked_key", replaceName); 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)); } @Override public void updateTemplateCardButton(TemplateCardMessage templateCardMessage) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE_CARD); this.mainService.post(url, templateCardMessage.toJson()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import com.tencent.wework.Finance; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpMsgAuditService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.msgaudit.*; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.function.Consumer; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.MsgAudit.*; /** * 会话内容存档接口实现类. * * @author Wang_Wong created on 2022-01-17 */ @Slf4j @RequiredArgsConstructor public class WxCpMsgAuditServiceImpl implements WxCpMsgAuditService { private final WxCpService cpService; /** * SDK初始化有效期,根据企微文档为7200秒 */ private static final int SDK_EXPIRES_TIME = 7200; @Override public WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, String passwd, @NonNull long timeout) throws Exception { // 获取或初始化SDK long sdk = this.initSdk(); long slice = Finance.NewSlice(); long ret = Finance.GetChatData(sdk, seq, limit, proxy, passwd, timeout, slice); if (ret != 0) { Finance.FreeSlice(slice); throw new WxErrorException("getchatdata err ret " + ret); } // 拉取会话存档 String content = Finance.GetContentFromSlice(slice); Finance.FreeSlice(slice); WxCpChatDatas chatDatas = WxCpChatDatas.fromJson(content); if (chatDatas.getErrCode().intValue() != 0) { throw new WxErrorException(chatDatas.toJson()); } chatDatas.setSdk(sdk); return chatDatas; } /** * 获取或初始化SDK,如果SDK已过期则重新初始化 * * @return sdk id * @throws WxErrorException 初始化失败时抛出异常 */ private synchronized long initSdk() throws WxErrorException { WxCpConfigStorage configStorage = cpService.getWxCpConfigStorage(); // 检查SDK是否已缓存且未过期 if (!configStorage.isMsgAuditSdkExpired()) { long cachedSdk = configStorage.getMsgAuditSdk(); if (cachedSdk > 0) { return cachedSdk; } } // SDK未初始化或已过期,需要重新初始化 String configPath = configStorage.getMsgAuditLibPath(); if (StringUtils.isEmpty(configPath)) { throw new WxErrorException("请配置会话存档sdk文件的路径,不要配错了!!"); } // 替换斜杠 String replacePath = configPath.replace("\\", "/"); // 获取最后一个斜杠的下标,用作分割路径 int lastIndex = replacePath.lastIndexOf("/") + 1; // 获取完整路径的前缀路径 String prefixPath = replacePath.substring(0, lastIndex); // 获取后缀的所有文件,目的遍历所有文件 String suffixFiles = replacePath.substring(lastIndex); // 包含so文件 String[] libFiles = suffixFiles.split(","); if (libFiles.length <= 0) { throw new WxErrorException("请仔细配置会话存档文件路径!!"); } List<String> libList = Arrays.asList(libFiles); // 判断windows系统会话存档sdk中dll的加载,因为会互相依赖所以是有顺序的,否则会导致无法加载sdk #2598 List<String> osLib = new LinkedList<>(); List<String> fileLib = new ArrayList<>(); libList.forEach(s -> { if (s.contains("lib")) { osLib.add(s); } else { fileLib.add(s); } }); osLib.addAll(fileLib); Finance.loadingLibraries(osLib, prefixPath); long sdk = Finance.NewSdk(); // 因为会话存档单独有个secret,优先使用会话存档的secret String msgAuditSecret = configStorage.getMsgAuditSecret(); if (StringUtils.isEmpty(msgAuditSecret)) { msgAuditSecret = configStorage.getCorpSecret(); } long ret = Finance.Init(sdk, configStorage.getCorpId(), msgAuditSecret); if (ret != 0) { Finance.DestroySdk(sdk); throw new WxErrorException("init sdk err ret " + ret); } // 缓存SDK configStorage.updateMsgAuditSdk(sdk, SDK_EXPIRES_TIME); log.debug("初始化会话存档SDK成功,sdk={}", sdk); return sdk; } @Override public WxCpChatModel getDecryptData(@NonNull long sdk, @NonNull WxCpChatDatas.WxCpChatData chatData, @NonNull Integer pkcs1) throws Exception { String plainText = this.decryptChatData(sdk, chatData, pkcs1); return WxCpChatModel.fromJson(plainText); } /** * Decrypt chat data string. * * @param sdk the sdk * @param chatData the chat data * @param pkcs1 the pkcs 1 * @return the string * @throws Exception the exception */ public String decryptChatData(long sdk, WxCpChatDatas.WxCpChatData chatData, Integer pkcs1) throws Exception { // 企业获取的会话内容,使用企业自行配置的消息加密公钥进行加密,企业可用自行保存的私钥解开会话内容数据。 // msgAuditPriKey 会话存档私钥不能为空 String priKey = cpService.getWxCpConfigStorage().getMsgAuditPriKey(); if (StringUtils.isEmpty(priKey)) { throw new WxErrorException("请配置会话存档私钥【msgAuditPriKey】"); } String decryptByPriKey = WxCpCryptUtil.decryptPriKey(chatData.getEncryptRandomKey(), priKey, pkcs1); // 每次使用DecryptData解密会话存档前需要调用NewSlice获取一个slice,在使用完slice中数据后,还需要调用FreeSlice释放。 long msg = Finance.NewSlice(); // 解密会话存档内容 // sdk不会要求用户传入rsa私钥,保证用户会话存档数据只有自己能够解密。 // 此处需要用户先用rsa私钥解密encrypt_random_key后,作为encrypt_key参数传入sdk来解密encrypt_chat_msg获取会话存档明文。 int ret = Finance.DecryptData(sdk, decryptByPriKey, chatData.getEncryptChatMsg(), msg); if (ret != 0) { Finance.FreeSlice(msg); throw new WxErrorException("msg err ret " + ret); } // 明文 String plainText = Finance.GetContentFromSlice(msg); Finance.FreeSlice(msg); return plainText; } @Override public String getChatPlainText(@NonNull long sdk, WxCpChatDatas.@NonNull WxCpChatData chatData, @NonNull Integer pkcs1) throws Exception { return this.decryptChatData(sdk, chatData, pkcs1); } @Override public void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, @NonNull String targetFilePath) throws WxErrorException { /** * 1、媒体文件每次拉取的最大size为512k,因此超过512k的文件需要分片拉取。 * 2、若该文件未拉取完整,sdk的IsMediaDataFinish接口会返回0,同时通过GetOutIndexBuf接口返回下次拉取需要传入GetMediaData的indexbuf。 * 3、indexbuf一般格式如右侧所示,”Range:bytes=524288-1048575“:表示这次拉取的是从524288到1048575的分片。单个文件首次拉取填写的indexbuf * 为空字符串,拉取后续分片时直接填入上次返回的indexbuf即可。 */ File targetFile = new File(targetFilePath); if (!targetFile.getParentFile().exists()) { targetFile.getParentFile().mkdirs(); } this.getMediaFile(sdk, sdkfileid, proxy, passwd, timeout, i -> { try { // 大于512k的文件会分片拉取,此处需要使用追加写,避免后面的分片覆盖之前的数据。 FileOutputStream outputStream = new FileOutputStream(targetFile, true); outputStream.write(i); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } }); } @Override public void getMediaFile(@NonNull long sdk, @NonNull String sdkfileid, String proxy, String passwd, @NonNull long timeout, @NonNull Consumer<byte[]> action) throws WxErrorException { /** * 1、媒体文件每次拉取的最大size为512k,因此超过512k的文件需要分片拉取。 * 2、若该文件未拉取完整,sdk的IsMediaDataFinish接口会返回0,同时通过GetOutIndexBuf接口返回下次拉取需要传入GetMediaData的indexbuf。 * 3、indexbuf一般格式如右侧所示,”Range:bytes=524288-1048575“:表示这次拉取的是从524288到1048575的分片。单个文件首次拉取填写的indexbuf为空字符串,拉取后续分片时直接填入上次返回的indexbuf即可。 */ String indexbuf = ""; int ret, data_len = 0; log.debug("正在分片拉取媒体文件 sdkFileId为{}", sdkfileid); while (true) { long mediaData = Finance.NewMediaData(); ret = Finance.GetMediaData(sdk, indexbuf, sdkfileid, proxy, passwd, timeout, mediaData); if (ret != 0) { Finance.FreeMediaData(mediaData); throw new WxErrorException("getmediadata err ret " + ret); } data_len += Finance.GetDataLen(mediaData); log.debug("正在分片拉取媒体文件 len:{}, data_len:{}, is_finish:{} \n", Finance.GetIndexLen(mediaData), data_len, Finance.IsMediaDataFinish(mediaData)); try { // 大于512k的文件会分片拉取,此处需要使用追加写,避免后面的分片覆盖之前的数据。 action.accept(Finance.GetData(mediaData)); } catch (Exception e) { e.printStackTrace(); } if (Finance.IsMediaDataFinish(mediaData) == 1) { // 已经拉取完成最后一个分片 Finance.FreeMediaData(mediaData); break; } else { // 获取下次拉取需要使用的indexbuf indexbuf = Finance.GetOutIndexBuf(mediaData); Finance.FreeMediaData(mediaData); } } } @Override public List<String> getPermitUserList(Integer type) throws WxErrorException { final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_PERMIT_USER_LIST); JsonObject jsonObject = new JsonObject(); if (type != null) { jsonObject.addProperty("type", type); } String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGsonBuilder.create().fromJson(GsonParser.parse(responseContent).getAsJsonArray("ids"), new TypeToken<List<String>>() { }.getType()); } @Override public WxCpGroupChat getGroupChat(@NonNull String roomid) throws WxErrorException { final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_GROUP_CHAT); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("roomid", roomid); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpGroupChat.fromJson(responseContent); } @Override public WxCpAgreeInfo checkSingleAgree(@NonNull WxCpCheckAgreeRequest checkAgreeRequest) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CHECK_SINGLE_AGREE); String responseContent = this.cpService.post(apiUrl, checkAgreeRequest.toJson()); return WxCpAgreeInfo.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpKfService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.kf.*; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.util.List; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Kf.*; /** * 微信客服接口-服务实现 * * @author Fu created on 2022/1/19 19:41 */ @RequiredArgsConstructor public class WxCpKfServiceImpl implements WxCpKfService { private final WxCpService cpService; private static final Gson GSON = new GsonBuilder().create(); @Override public WxCpKfAccountAddResp addAccount(WxCpKfAccountAdd add) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_ADD); String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(add)); return WxCpKfAccountAddResp.fromJson(responseContent); } @Override public WxCpBaseResp updAccount(WxCpKfAccountUpd upd) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_UPD); String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(upd)); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpBaseResp delAccount(WxCpKfAccountDel del) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_DEL); String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(del)); return WxCpBaseResp.fromJson(responseContent); } @Override public WxCpKfAccountListResp listAccount(Integer offset, Integer limit) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_LIST); JsonObject json = new JsonObject(); if (offset != null) { json.addProperty("offset", offset); } if (limit != null) { json.addProperty("limit", limit); } String responseContent = cpService.post(url, json.toString()); return WxCpKfAccountListResp.fromJson(responseContent); } @Override public WxCpKfAccountLinkResp getAccountLink(WxCpKfAccountLink link) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY); String responseContent = cpService.post(url, WxCpGsonBuilder.create().toJson(link)); return WxCpKfAccountLinkResp.fromJson(responseContent); } @Override public WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException { return servicerOp(openKfid, userIdList, null, SERVICER_ADD); } @Override public WxCpKfServicerOpResp addServicer(String openKfId, List<String> userIdList, List<String> departmentIdList) throws WxErrorException { validateParameters(SERVICER_ADD, userIdList, departmentIdList); return servicerOp(openKfId, userIdList, departmentIdList, SERVICER_ADD); } @Override public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException { return servicerOp(openKfid, userIdList, null, SERVICER_DEL); } @Override public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException { validateParameters(SERVICER_DEL, userIdList, departmentIdList); return servicerOp(openKfid, userIdList, departmentIdList, SERVICER_DEL); } private void validateParameters(String uri, List<String> userIdList, List<String> departmentIdList) { if ((userIdList == null || userIdList.isEmpty()) && (departmentIdList == null || departmentIdList.isEmpty())) { throw new IllegalArgumentException("userid_list和department_id_list至少需要填其中一个"); } if (SERVICER_DEL.equals(uri)) { if (userIdList != null && userIdList.size() > 100) { throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。"); } if (departmentIdList != null && departmentIdList.size() > 100) { throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。"); } } else { if (userIdList != null && userIdList.size() > 100) { throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。"); } if (departmentIdList != null && departmentIdList.size() > 20) { throw new IllegalArgumentException("可填充个数:0 ~ 20。"); } } } private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, List<String> departmentIdList, String uri) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(uri); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); if (userIdList != null && !userIdList.isEmpty()) { JsonArray userIdArray = new JsonArray(); userIdList.forEach(userIdArray::add); json.add("userid_list", userIdArray); } if (departmentIdList != null && !departmentIdList.isEmpty()) { JsonArray departmentIdArray = new JsonArray(); departmentIdList.forEach(departmentIdArray::add); json.add("department_id_list", departmentIdArray); } String responseContent = cpService.post(url, json.toString()); return WxCpKfServicerOpResp.fromJson(responseContent); } @Override public WxCpKfServicerListResp listServicer(String openKfid) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICER_LIST + openKfid); String responseContent = cpService.get(url, null); return WxCpKfServicerListResp.fromJson(responseContent); } @Override public WxCpKfServiceStateResp getServiceState(String openKfid, String externalUserId) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICE_STATE_GET); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); json.addProperty("external_userid", externalUserId); String responseContent = cpService.post(url, json.toString()); return WxCpKfServiceStateResp.fromJson(responseContent); } @Override public WxCpKfServiceStateTransResp transServiceState(String openKfid, String externalUserId, Integer serviceState, String servicerUserId) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SERVICE_STATE_TRANS); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); json.addProperty("external_userid", externalUserId); json.addProperty("service_state", serviceState); json.addProperty("servicer_userid", servicerUserId); String responseContent = cpService.post(url, json.toString()); return WxCpKfServiceStateTransResp.fromJson(responseContent); } @Override public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SYNC_MSG); JsonObject json = new JsonObject(); if (cursor != null) { json.addProperty("cursor", cursor); } if (token != null) { json.addProperty("token", token); } if (limit != null) { json.addProperty("limit", limit); } if (voiceFormat != null) { json.addProperty("voice_format", voiceFormat); } String responseContent = cpService.post(url, json); return WxCpKfMsgListResp.fromJson(responseContent); } @Override public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat, String openKfId) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SYNC_MSG); JsonObject json = new JsonObject(); if (cursor!=null) { json.addProperty("cursor", cursor); } if (token!=null) { json.addProperty("token", token); } if (limit!=null) { json.addProperty("limit", limit); } if (voiceFormat!=null) { json.addProperty("voice_format", voiceFormat); } if (openKfId != null) { json.addProperty("open_kfid", openKfId); } String responseContent = cpService.post(url, json); return WxCpKfMsgListResp.fromJson(responseContent); } @Override public WxCpKfMsgSendResp sendMsg(WxCpKfMsgSendRequest request) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SEND_MSG); String responseContent = cpService.post(url, GSON.toJson(request)); return WxCpKfMsgSendResp.fromJson(responseContent); } @Override public WxCpKfMsgSendResp sendMsgOnEvent(WxCpKfMsgSendRequest request) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(SEND_MSG_ON_EVENT); String responseContent = cpService.post(url, GSON.toJson(request)); return WxCpKfMsgSendResp.fromJson(responseContent); } @Override public WxCpKfCustomerBatchGetResp customerBatchGet(List<String> externalUserIdList) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_BATCH_GET); JsonArray array = new JsonArray(); externalUserIdList.forEach(array::add); JsonObject json = new JsonObject(); json.add("external_userid_list", array); String responseContent = cpService.post(url, json.toString()); return WxCpKfCustomerBatchGetResp.fromJson(responseContent); } @Override public WxCpKfServiceUpgradeConfigResp getUpgradeServiceConfig() throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_GET_UPGRADE_SERVICE_CONFIG); String response = cpService.get(url, null); return WxCpKfServiceUpgradeConfigResp.fromJson(response); } @Override public WxCpBaseResp upgradeMemberService(String openKfid, String externalUserId, String userid, String wording) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_UPGRADE_SERVICE); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); json.addProperty("external_userid", externalUserId); json.addProperty("type", 1); JsonObject memberJson = new JsonObject(); memberJson.addProperty("userid", userid); memberJson.addProperty("wording", wording); json.add("member", memberJson); String response = cpService.post(url, json); return WxCpBaseResp.fromJson(response); } @Override public WxCpBaseResp upgradeGroupchatService(String openKfid, String externalUserId, String chatId, String wording) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_UPGRADE_SERVICE); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); json.addProperty("external_userid", externalUserId); json.addProperty("type", 2); JsonObject groupchatJson = new JsonObject(); groupchatJson.addProperty("chat_id", chatId); groupchatJson.addProperty("wording", wording); json.add("groupchat", groupchatJson); String response = cpService.post(url, json); return WxCpBaseResp.fromJson(response); } @Override public WxCpBaseResp cancelUpgradeService(String openKfid, String externalUserId) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(CUSTOMER_CANCEL_UPGRADE_SERVICE); JsonObject json = new JsonObject(); json.addProperty("open_kfid", openKfid); json.addProperty("external_userid", externalUserId); String response = cpService.post(url, json); return WxCpBaseResp.fromJson(response); } @Override public WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest request) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(GET_CORP_STATISTIC); String responseContent = cpService.post(url, GSON.toJson(request)); return WxCpKfGetCorpStatisticResp.fromJson(responseContent); } @Override public WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(GET_SERVICER_STATISTIC); String responseContent = cpService.post(url, GSON.toJson(request)); return WxCpKfGetServicerStatisticResp.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.bean.menu.WxMenu; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpMenuService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Menu.*; /** * <pre> * 菜单管理相关接口. * Created by Binary Wang on 2017-6-25. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @RequiredArgsConstructor public class WxCpMenuServiceImpl implements WxCpMenuService { private final WxCpService mainService; @Override public void create(WxMenu menu) throws WxErrorException { this.create(this.mainService.getWxCpConfigStorage().getAgentId(), menu); } @Override public void create(Integer agentId, WxMenu menu) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_CREATE), agentId); this.mainService.post(url, menu.toJson()); } @Override public void delete() throws WxErrorException { this.delete(this.mainService.getWxCpConfigStorage().getAgentId()); } @Override public void delete(Integer agentId) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_DELETE), agentId); this.mainService.get(url, null); } @Override public WxMenu get() throws WxErrorException { return this.get(this.mainService.getWxCpConfigStorage().getAgentId()); } @Override public WxMenu get(Integer agentId) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_GET), agentId); try { String resultContent = this.mainService.get(url, null); return WxCpGsonBuilder.create().fromJson(resultContent, WxMenu.class); } catch (WxErrorException e) { // 46003 不存在的菜单数据 if (e.getError().getErrorCode() == 46003) { return null; } throw e; } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExportServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExportServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpExportService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.export.WxCpExportRequest; import me.chanjar.weixin.cp.bean.export.WxCpExportResult; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Export.*; /** * 异步导出接口 * * @author <a href="https://github.com/zhongjun96">zhongjun</a> created on 2022/4/21 */ @RequiredArgsConstructor public class WxCpExportServiceImpl implements WxCpExportService { private final WxCpService mainService; @Override public String simpleUser(WxCpExportRequest params) throws WxErrorException { return export(SIMPLE_USER, params); } @Override public String user(WxCpExportRequest params) throws WxErrorException { return export(USER, params); } @Override public String department(WxCpExportRequest params) throws WxErrorException { return export(DEPARTMENT, params); } @Override public String tagUser(WxCpExportRequest params) throws WxErrorException { return export(TAG_USER, params); } @Override public WxCpExportResult getResult(String jobId) throws WxErrorException { String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_RESULT), jobId); String responseContent = this.mainService.get(url, null); return WxCpGsonBuilder.create().fromJson(responseContent, WxCpExportResult.class); } private String export(String path, WxCpExportRequest params) throws WxErrorException { String url = this.mainService.getWxCpConfigStorage().getApiUrl(path); String responseContent = this.mainService.post(url, params.toJson()); JsonObject tmpJson = GsonParser.parse(responseContent); return tmpJson.get("jobid").getAsString(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java
package me.chanjar.weixin.cp.api.impl; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpLivingService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.living.*; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.StringUtils; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.*; /** * 企业微信直播接口实现类. * https://developer.work.weixin.qq.com/document/path/93633 * * @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on 2021-12-21 */ @Slf4j @RequiredArgsConstructor public class WxCpLivingServiceImpl implements WxCpLivingService { private final WxCpService cpService; @Override public String getLivingCode(String openId, String livingId) throws WxErrorException { final String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_CODE); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("openid", openId); jsonObject.addProperty("livingid", livingId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return GsonHelper.getString(GsonParser.parse(responseContent), "living_code"); } @Override public WxCpLivingInfo getLivingInfo(String livingId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_INFO) + livingId; String responseContent = this.cpService.get(apiUrl, null); return WxCpGsonBuilder.create() .fromJson(GsonParser.parse(responseContent).get("living_info"), new TypeToken<WxCpLivingInfo>() { }.getType() ); } @Override public WxCpWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_WATCH_STAT); JsonObject jsonObject = new JsonObject(); if (StringUtils.isNotBlank(nextKey)) { jsonObject.addProperty("next_key", nextKey); } jsonObject.addProperty("livingid", livingId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpWatchStat.fromJson(responseContent); } @Override public WxCpLivingResult.LivingIdResult getUserAllLivingId(String userId, String cursor, Integer limit) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_ALL_LIVINGID); JsonObject jsonObject = new JsonObject(); if (cursor != null) { jsonObject.addProperty("cursor", cursor); } if (limit != null) { jsonObject.addProperty("limit", limit); } jsonObject.addProperty("userid", userId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpLivingResult.LivingIdResult.fromJson(responseContent); } @Override public WxCpLivingShareInfo getLivingShareInfo(String wwShareCode) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_SHARE_INFO); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("ww_share_code", wwShareCode); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpLivingShareInfo.fromJson(responseContent); } @Override public String livingCreate(WxCpLivingCreateRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CREATE); String responseContent = this.cpService.post(apiUrl, request.toJson()); return GsonHelper.getString(GsonParser.parse(responseContent), "livingid"); } @Override public WxCpLivingResult livingModify(WxCpLivingModifyRequest request) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(MODIFY); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpLivingResult.fromJson(responseContent); } @Override public WxCpLivingResult livingCancel(@NonNull String livingId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(CANCEL); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("livingid", livingId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpLivingResult.fromJson(responseContent); } @Override public WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DELETE_REPLAY_DATA); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("livingid", livingId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpLivingResult.fromJson(responseContent); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false