mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
#477 企业号接口重构,分类管理
This commit is contained in:
parent
20e174eb6b
commit
2058623eaa
@ -19,9 +19,9 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信API的Service
|
||||
* @author chanjaster
|
||||
*/
|
||||
public interface WxCpService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 验证推送过来的消息的正确性
|
||||
@ -85,42 +85,6 @@ public interface WxCpService {
|
||||
*/
|
||||
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#create(WxMenu)}
|
||||
*/
|
||||
@Deprecated
|
||||
void menuCreate(WxMenu menu) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#create(Integer, WxMenu)}
|
||||
*/
|
||||
@Deprecated
|
||||
void menuCreate(Integer agentId, WxMenu menu) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#delete()} }
|
||||
*/
|
||||
@Deprecated
|
||||
void menuDelete() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#delete(Integer)}
|
||||
*/
|
||||
@Deprecated
|
||||
void menuDelete(Integer agentId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#get() }
|
||||
*/
|
||||
@Deprecated
|
||||
WxMenu menuGet() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMenuService#get(Integer)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxMenu menuGet(Integer agentId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 发送消息
|
||||
@ -131,175 +95,6 @@ public interface WxCpService {
|
||||
*/
|
||||
WxCpMessageSendResult messageSend(WxCpMessage message) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpDepartmentService#create(WxCpDepart)}
|
||||
*/
|
||||
@Deprecated
|
||||
Integer departCreate(WxCpDepart depart) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpDepartmentService#update(WxCpDepart)}
|
||||
*/
|
||||
@Deprecated
|
||||
void departUpdate(WxCpDepart group) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpDepartmentService#delete(Integer)}
|
||||
*/
|
||||
@Deprecated
|
||||
void departDelete(Integer departId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpDepartmentService#listAll() }
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpDepart> departGet() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMediaService#upload(String, String, InputStream)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream)
|
||||
throws WxErrorException, IOException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMediaService#upload(String, File)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpMediaService#download(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
File mediaDownload(String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#authenticate(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
void userAuthenticated(String userId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#create(WxCpUser)}
|
||||
*/
|
||||
@Deprecated
|
||||
void userCreate(WxCpUser user) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#update(WxCpUser)}
|
||||
*/
|
||||
@Deprecated
|
||||
void userUpdate(WxCpUser user) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#delete(String...)}
|
||||
*/
|
||||
@Deprecated
|
||||
void userDelete(String userid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#delete(String...)}
|
||||
*/
|
||||
@Deprecated
|
||||
void userDelete(String[] userids) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#getById(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxCpUser userGet(String userid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#listByDepartment(Integer, Boolean, Integer)}
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpUserService#listSimpleByDepartment(Integer, Boolean, Integer)}
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#create(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
String tagCreate(String tagName) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#update(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
void tagUpdate(String tagId, String tagName) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#delete(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
void tagDelete(String tagId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#listAll()}
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpTag> tagGet() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#listUsersByTagId(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#addUsers2Tag(String, List, List)}
|
||||
*/
|
||||
@Deprecated
|
||||
void tagAddUsers(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpTagService#removeUsersFromTag(String, List)}
|
||||
*/
|
||||
@Deprecated
|
||||
void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpOAuth2Service#buildAuthorizationUrl(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
String oauth2buildAuthorizationUrl(String state);
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpOAuth2Service#buildAuthorizationUrl(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
String oauth2buildAuthorizationUrl(String redirectUri, String state);
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpOAuth2Service#getUserInfo(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
String[] oauth2getUserInfo(String code) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link WxCpOAuth2Service#getUserInfo(Integer, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 邀请成员关注
|
||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
|
||||
* </pre>
|
||||
*
|
||||
* @param userId 用户的userid
|
||||
* @param inviteTips 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
||||
* @return 1:微信邀请 2.邮件邀请
|
||||
*/
|
||||
int invite(String userId, String inviteTips) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取微信服务器的ip段
|
||||
|
@ -80,4 +80,16 @@ public interface WxCpUserService {
|
||||
* @param userid 用户id
|
||||
*/
|
||||
WxCpUser getById(String userid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 邀请成员关注
|
||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
|
||||
* </pre>
|
||||
*
|
||||
* @param userId 用户的userid
|
||||
* @param inviteTips 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
||||
* @return 1:微信邀请 2.邮件邀请
|
||||
*/
|
||||
int invite(String userId, String inviteTips) throws WxErrorException;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service {
|
||||
|
||||
@Override
|
||||
public String[] getUserInfo(String code) throws WxErrorException {
|
||||
return getUserInfo(this.mainService.getWxCpConfigStorage().getAgentId(), code);
|
||||
return this.getUserInfo(this.mainService.getWxCpConfigStorage().getAgentId(), code);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,188 +138,6 @@ public abstract class WxCpServiceAbstractImpl<H, P> implements WxCpService, Requ
|
||||
return WxCpMessageSendResult.fromJson(this.post(url, message.toJson()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void menuCreate(WxMenu menu) throws WxErrorException {
|
||||
this.getMenuService().create(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void menuCreate(Integer agentId, WxMenu menu) throws WxErrorException {
|
||||
this.getMenuService().create(agentId, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void menuDelete() throws WxErrorException {
|
||||
this.getMenuService().delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void menuDelete(Integer agentId) throws WxErrorException {
|
||||
this.getMenuService().delete(agentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxMenu menuGet() throws WxErrorException {
|
||||
return this.getMenuService().get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxMenu menuGet(Integer agentId) throws WxErrorException {
|
||||
return this.getMenuService().get(agentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream)
|
||||
throws WxErrorException, IOException {
|
||||
return this.getMediaService().upload(mediaType, fileType, inputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException {
|
||||
return this.getMediaService().upload(mediaType, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public File mediaDownload(String mediaId) throws WxErrorException {
|
||||
return this.getMediaService().download(mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void userAuthenticated(String userId) throws WxErrorException {
|
||||
this.getUserService().authenticate(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void userCreate(WxCpUser user) throws WxErrorException {
|
||||
this.getUserService().create(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void userUpdate(WxCpUser user) throws WxErrorException {
|
||||
this.getUserService().update(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void userDelete(String userid) throws WxErrorException {
|
||||
this.getUserService().delete(userid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void userDelete(String[] userids) throws WxErrorException {
|
||||
this.getUserService().delete(userids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxCpUser userGet(String userid) throws WxErrorException {
|
||||
return this.getUserService().getById(userid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException {
|
||||
return this.getUserService().listByDepartment(departId, fetchChild, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException {
|
||||
return this.getUserService().listSimpleByDepartment(departId, fetchChild, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String tagCreate(String tagName) throws WxErrorException {
|
||||
return this.getTagService().create(tagName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tagUpdate(String tagId, String tagName) throws WxErrorException {
|
||||
this.getTagService().update(tagId, tagName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tagDelete(String tagId) throws WxErrorException {
|
||||
this.getTagService().delete(tagId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpTag> tagGet() throws WxErrorException {
|
||||
return this.getTagService().listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException {
|
||||
return this.getTagService().listUsersByTagId(tagId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tagAddUsers(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException {
|
||||
this.getTagService().addUsers2Tag(tagId, userIds, partyIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException {
|
||||
this.getTagService().removeUsersFromTag(tagId, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String oauth2buildAuthorizationUrl(String state) {
|
||||
return this.getOauth2Service().buildAuthorizationUrl(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String oauth2buildAuthorizationUrl(String redirectUri, String state) {
|
||||
return this.getOauth2Service().buildAuthorizationUrl(redirectUri, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] oauth2getUserInfo(String code) throws WxErrorException {
|
||||
return this.getOauth2Service().getUserInfo(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException {
|
||||
return this.getOauth2Service().getUserInfo(agentId, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int invite(String userId, String inviteTips) throws WxErrorException {
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/invite/send";
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("userid", userId);
|
||||
if (StringUtils.isNotEmpty(inviteTips)) {
|
||||
jsonObject.addProperty("invite_tips", inviteTips);
|
||||
}
|
||||
String responseContent = post(url, jsonObject.toString());
|
||||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
|
||||
return tmpJsonElement.getAsJsonObject().get("type").getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCallbackIp() throws WxErrorException {
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/getcallbackip";
|
||||
@ -516,30 +334,6 @@ public abstract class WxCpServiceAbstractImpl<H, P> implements WxCpService, Requ
|
||||
return userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Integer departCreate(WxCpDepart depart) throws WxErrorException {
|
||||
return this.getDepartmentService().create(depart);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void departUpdate(WxCpDepart depart) throws WxErrorException {
|
||||
this.getDepartmentService().update(depart);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void departDelete(Integer departId) throws WxErrorException {
|
||||
this.getDepartmentService().delete(departId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpDepart> departGet() throws WxErrorException {
|
||||
return this.getDepartmentService().listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestHttp getRequestHttp() {
|
||||
return this;
|
||||
|
@ -7,6 +7,7 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.api.WxCpUserService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -112,4 +113,16 @@ public class WxCpUserServiceImpl implements WxCpUserService {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int invite(String userId, String inviteTips) throws WxErrorException {
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/invite/send";
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("userid", userId);
|
||||
if (StringUtils.isNotEmpty(inviteTips)) {
|
||||
jsonObject.addProperty("invite_tips", inviteTips);
|
||||
}
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
|
||||
return tmpJsonElement.getAsJsonObject().get("type").getAsInt();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user