diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java index 05b99bde82..8f6c51ad9e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java @@ -94,4 +94,31 @@ public interface WxCpOaWeDriveService { */ WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException; + /** + * 权限管理 + * 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。 + *

+ * 请求方式: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; + + /** + * 获取邀请链接 + * 该接口用于获取空间邀请分享链接。 + *

+ * 请求方式: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; + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java index cc5d53111e..4ed2da2c99 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java @@ -71,4 +71,21 @@ public WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws 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); + } + } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceSettingRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceSettingRequest.java new file mode 100644 index 0000000000..9239fb73f2 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceSettingRequest.java @@ -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); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceShare.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceShare.java new file mode 100644 index 0000000000..929073912d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpSpaceShare.java @@ -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); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index beabef410e..096d9d6c1f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -151,6 +151,8 @@ interface Oa { String SPACE_INFO = "/cgi-bin/wedrive/space_info"; String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add"; 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"; /** * 审批流程引擎 diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java index 93b69e167c..5a7f934042 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java @@ -41,6 +41,26 @@ public void test() throws WxErrorException { String uId = "WangKai"; 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()); /** * 获取空间信息