mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-12-17 17:41:32 +08:00
🆕 #2639【企业微信】增加微盘空间权限管理的接口
This commit is contained in:
@@ -94,4 +94,31 @@ public interface WxCpOaWeDriveService {
|
|||||||
*/
|
*/
|
||||||
WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException;
|
WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限管理
|
||||||
|
* 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。
|
||||||
|
* <p>
|
||||||
|
* 请求方式:POST(HTTPS)
|
||||||
|
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param request 权限管理请求参数
|
||||||
|
* @return
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
WxCpBaseResp spaceSetting(@NonNull WxCpSpaceSettingRequest request) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请链接
|
||||||
|
* 该接口用于获取空间邀请分享链接。
|
||||||
|
* <p>
|
||||||
|
* 请求方式:POST(HTTPS)
|
||||||
|
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param spaceId
|
||||||
|
* @return
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
WxCpSpaceShare spaceShare(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,4 +71,21 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService {
|
|||||||
return WxCpBaseResp.fromJson(responseContent);
|
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 userId, @NonNull String spaceId) throws WxErrorException {
|
||||||
|
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_SHARE);
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
jsonObject.addProperty("userid", userId);
|
||||||
|
jsonObject.addProperty("spaceid", spaceId);
|
||||||
|
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
|
||||||
|
return WxCpSpaceShare.fromJson(responseContent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package me.chanjar.weixin.cp.bean.oa.wedrive;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限管理请求.
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class WxCpSpaceSettingRequest implements Serializable {
|
||||||
|
private static final long serialVersionUID = -4960239393895754138L;
|
||||||
|
|
||||||
|
@SerializedName("userid")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@SerializedName("spaceid")
|
||||||
|
private String spaceId;
|
||||||
|
|
||||||
|
@SerializedName("enable_watermark")
|
||||||
|
private Boolean enableWatermark;
|
||||||
|
|
||||||
|
@SerializedName("add_member_only_admin")
|
||||||
|
private Boolean addMemberOnlyAdmin;
|
||||||
|
|
||||||
|
@SerializedName("enable_share_url")
|
||||||
|
private Boolean enableShareUrl;
|
||||||
|
|
||||||
|
@SerializedName("share_url_no_approve")
|
||||||
|
private Boolean shareUrlNoApprove;
|
||||||
|
|
||||||
|
@SerializedName("share_url_no_approve_default_auth")
|
||||||
|
private Integer shareUrlNoApproveDefaultAuth;
|
||||||
|
|
||||||
|
public static WxCpSpaceSettingRequest fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceSettingRequest.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package me.chanjar.weixin.cp.bean.oa.wedrive;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||||
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请链接.
|
||||||
|
*
|
||||||
|
* @author Wang_Wong
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WxCpSpaceShare extends WxCpBaseResp implements Serializable {
|
||||||
|
private static final long serialVersionUID = -5028321625142879581L;
|
||||||
|
|
||||||
|
@SerializedName("space_share_url")
|
||||||
|
private String spaceShareUrl;
|
||||||
|
|
||||||
|
public static WxCpSpaceShare fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceShare.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -151,6 +151,8 @@ public interface WxCpApiPathConsts {
|
|||||||
String SPACE_INFO = "/cgi-bin/wedrive/space_info";
|
String SPACE_INFO = "/cgi-bin/wedrive/space_info";
|
||||||
String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add";
|
String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add";
|
||||||
String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del";
|
String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del";
|
||||||
|
String SPACE_SETTING = "/cgi-bin/wedrive/space_setting";
|
||||||
|
String SPACE_SHARE = "/cgi-bin/wedrive/space_share";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审批流程引擎
|
* 审批流程引擎
|
||||||
|
|||||||
@@ -41,6 +41,26 @@ public class WxCpOaWeDriveServiceTest {
|
|||||||
String uId = "WangKai";
|
String uId = "WangKai";
|
||||||
String spId = "s.ww45d3e188865aca30.652091685u4h";
|
String spId = "s.ww45d3e188865aca30.652091685u4h";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限管理
|
||||||
|
*/
|
||||||
|
WxCpSpaceSettingRequest spaceSettingRequest = new WxCpSpaceSettingRequest();
|
||||||
|
spaceSettingRequest.setUserId(uId);
|
||||||
|
spaceSettingRequest.setSpaceId(spId);
|
||||||
|
// spaceSettingRequest.setEnableWatermark(false);
|
||||||
|
spaceSettingRequest.setAddMemberOnlyAdmin(true);
|
||||||
|
spaceSettingRequest.setEnableShareUrl(false);
|
||||||
|
spaceSettingRequest.setShareUrlNoApprove(true);
|
||||||
|
spaceSettingRequest.setShareUrlNoApproveDefaultAuth(2);
|
||||||
|
|
||||||
|
WxCpBaseResp spaceSetting = cpService.getOaWeDriveService().spaceSetting(spaceSettingRequest);
|
||||||
|
log.info("权限管理信息为:{}", spaceSetting.toJson());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请链接
|
||||||
|
*/
|
||||||
|
WxCpSpaceShare spaceShare = cpService.getOaWeDriveService().spaceShare(uId, spId);
|
||||||
|
log.info("获取邀请链接信息为:{}", spaceShare.toJson());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取空间信息
|
* 获取空间信息
|
||||||
|
|||||||
Reference in New Issue
Block a user