权限改造后相关接口改动

This commit is contained in:
jinyu 2016-03-28 13:16:21 +08:00
parent 08ab083e57
commit 7f2c1ddaab
3 changed files with 458 additions and 276 deletions

View File

@ -1,276 +1,301 @@
package com.foxinmy.weixin4j.qy.model; package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.Token; import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.qy.type.AgentAuthType; import com.foxinmy.weixin4j.qy.type.AgentAuthType;
/** /**
* 企业号oauth授权登陆信息&第三方应用授权信息 * 企业号oauth授权登陆信息&第三方应用授权信息
* *
* @className OUserInfo * @className OUserInfo
* @author jy * @author jy
* @date 2015年6月12日 * @date 2015年6月12日
* @since JDK 1.6 * @since JDK 1.6
* @see * @see
*/ */
public class OUserInfo implements Serializable { public class OUserInfo implements Serializable {
private static final long serialVersionUID = -567063562050171293L; private static final long serialVersionUID = -567063562050171293L;
/** /**
* 是否系统管理员 * 是否系统管理员
*/ */
@JSONField(name = "is_sys") @JSONField(name = "is_sys")
private boolean isSysAdmin; private boolean isSysAdmin;
/** /**
* 是否内部管理员 * 是否内部管理员
*/ */
@JSONField(name = "is_inner") @JSONField(name = "is_inner")
private boolean isInnerAdmin; private boolean isInnerAdmin;
/** /**
* 登陆管理员信息 * 登陆管理员信息
*/ */
@JSONField(name = "user_info") @JSONField(name = "user_info")
private User adminInfo; private User adminInfo;
/** /**
* 授权方企业信息 * 授权方企业信息
*/ */
@JSONField(name = "corp_info") @JSONField(name = "corp_info")
private CorpInfo corpInfo; private CorpInfo corpInfo;
/** /**
* 该管理员在该提供商中能使用的应用列表 * 该管理员在该提供商中能使用的应用列表
*/ */
@JSONField(name = "agent") @JSONField(name = "agent")
private List<AgentItem> agentInfo; private List<AgentItem> agentInfo;
/** /**
* 该管理员拥有的通讯录权限 * 该管理员拥有的通讯录权限
*/ */
@JSONField(name = "auth_info") @JSONField(name = "auth_info")
private AuthInfo authInfo; private AuthInfo authInfo;
/** /**
* 登录跳转的票据信息 * 登录跳转的票据信息
*/ */
@JSONField(name = "redirect_login_info") @JSONField(name = "redirect_login_info")
private Token redirectLoginInfo; private Token redirectLoginInfo;
public boolean isSysAdmin() { public boolean isSysAdmin() {
return isSysAdmin; return isSysAdmin;
} }
public boolean isInnerAdmin() { public boolean isInnerAdmin() {
return isInnerAdmin; return isInnerAdmin;
} }
public User getAdminInfo() { public User getAdminInfo() {
return adminInfo; return adminInfo;
} }
public CorpInfo getCorpInfo() { public CorpInfo getCorpInfo() {
return corpInfo; return corpInfo;
} }
public List<AgentItem> getAgentInfo() { public List<AgentItem> getAgentInfo() {
return agentInfo; return agentInfo;
} }
public AuthInfo getAuthInfo() { public AuthInfo getAuthInfo() {
return authInfo; return authInfo;
} }
public Token getRedirectLoginInfo() { public Token getRedirectLoginInfo() {
return redirectLoginInfo; return redirectLoginInfo;
} }
// ---------- setter 应该全部去掉 // ---------- setter 应该全部去掉
public void setSysAdmin(boolean isSysAdmin) { public void setSysAdmin(boolean isSysAdmin) {
this.isSysAdmin = isSysAdmin; this.isSysAdmin = isSysAdmin;
} }
public void setInnerAdmin(boolean isInnerAdmin) { public void setInnerAdmin(boolean isInnerAdmin) {
this.isInnerAdmin = isInnerAdmin; this.isInnerAdmin = isInnerAdmin;
} }
public void setAdminInfo(User adminInfo) { public void setAdminInfo(User adminInfo) {
this.adminInfo = adminInfo; this.adminInfo = adminInfo;
} }
public void setCorpInfo(CorpInfo corpInfo) { public void setCorpInfo(CorpInfo corpInfo) {
this.corpInfo = corpInfo; this.corpInfo = corpInfo;
} }
public void setAgentInfo(List<AgentItem> agentInfo) { public void setAgentInfo(List<AgentItem> agentInfo) {
this.agentInfo = agentInfo; this.agentInfo = agentInfo;
} }
public void setAuthInfo(AuthInfo authInfo) { public void setAuthInfo(AuthInfo authInfo) {
this.authInfo = authInfo; this.authInfo = authInfo;
} }
public void setRedirectLoginInfo(Token redirectLoginInfo) { public void setRedirectLoginInfo(Token redirectLoginInfo) {
this.redirectLoginInfo = redirectLoginInfo; this.redirectLoginInfo = redirectLoginInfo;
} }
@Override @Override
public String toString() { public String toString() {
return "OUserInfo [isSysAdmin=" + isSysAdmin + ", isInnerAdmin=" return "OUserInfo [isSysAdmin=" + isSysAdmin + ", isInnerAdmin=" + isInnerAdmin + ", adminInfo=" + adminInfo
+ isInnerAdmin + ", adminInfo=" + adminInfo + ", corpInfo=" + ", corpInfo=" + corpInfo + ", agentInfo=" + agentInfo + ", authInfo=" + authInfo
+ corpInfo + ", agentInfo=" + agentInfo + ", authInfo=" + ", redirectLoginInfo=" + redirectLoginInfo + "]";
+ authInfo + ", redirectLoginInfo=" + redirectLoginInfo + "]"; }
}
/**
/** * 授权信息
* 授权信息 *
* * @className AuthInfo
* @className AuthInfo * @author jy
* @author jy * @date 2015年6月22日
* @date 2015年6月22日 * @since JDK 1.6
* @since JDK 1.6 * @see
* @see */
*/ public static class AuthInfo implements Serializable {
public static class AuthInfo implements Serializable {
private static final long serialVersionUID = -4290240764958942370L;
private static final long serialVersionUID = -4290240764958942370L; /**
/** * 是否采用了新的授权没有该字段或者该字段为false表示是旧授权true表示是新授权
* 授权的应用信息 */
*/ @JSONField(name = "is_new_auth")
@JSONField(name = "agent") private boolean isNewAuth;
private List<AgentItem> agentItems; /**
/** * 授权的应用信息,新的权限体系其中通讯录权限以应用为节点
* 授权的通讯录部门 */
*/ @JSONField(name = "agent")
@JSONField(name = "department") private List<AgentItem> agentItems;
private List<DepartItem> departItems; /**
* 授权的通讯录部门,<font color="red">新的权限体系将废弃</font>
public List<AgentItem> getAgentItems() { */
return agentItems; @JSONField(name = "department")
} private List<DepartItem> departItems;
public List<DepartItem> getDepartItems() { public List<AgentItem> getAgentItems() {
return departItems; return agentItems;
} }
// ---------- setter 应该全部去掉 public List<DepartItem> getDepartItems() {
return departItems;
public void setAgentItems(List<AgentItem> agentItems) { }
this.agentItems = agentItems;
} // ---------- setter 应该全部去掉
public void setDepartItems(List<DepartItem> departItems) { public boolean isNewAuth() {
this.departItems = departItems; return isNewAuth;
} }
@Override public void setNewAuth(boolean isNewAuth) {
public String toString() { this.isNewAuth = isNewAuth;
return "AuthInfo [agentItems=" + agentItems + ", departItems=" }
+ departItems + "]";
} public void setAgentItems(List<AgentItem> agentItems) {
} this.agentItems = agentItems;
}
/**
* 授权的应用信息 public void setDepartItems(List<DepartItem> departItems) {
* this.departItems = departItems;
* @className AgentItem }
* @author jy
* @date 2015年6月22日 @Override
* @since JDK 1.6 public String toString() {
* @see return "AuthInfo [isNewAuth=" + isNewAuth + ", agentItems=" + agentItems + ", departItems=" + departItems
*/ + "]";
public static class AgentItem extends AgentOverview { }
}
private static final long serialVersionUID = -1188968391623633559L;
/** /**
* 管理员对应用的权限 * 授权的应用信息
*/ *
@JSONField(name = "auth_type") * @className AgentItem
private int authType; * @author jy
/** * @date 2015年6月22日
* 服务商套件中的对应应用id * @since JDK 1.6
*/ * @see
@JSONField(name = "appid") */
private int appId; public static class AgentItem extends AgentOverview {
/**
* 授权方应用敏感权限组目前仅有get_location表示是否有权限设置应用获取地理位置的开关 private static final long serialVersionUID = -1188968391623633559L;
*/ /**
@JSONField(name = "api_group") * 管理员对应用的权限
private List<String> apiGroup; */
@JSONField(name = "auth_type")
public int getAuthType() { private int authType;
return authType; /**
} * 服务商套件中的对应应用id
*/
@JSONField(serialize = false) @JSONField(name = "appid")
public AgentAuthType getFormatAuthType() { private int appId;
if (authType == 0) { /**
return AgentAuthType.USE; * 授权方应用敏感权限组目前仅有get_location表示是否有权限设置应用获取地理位置的开关,
} else if (authType == 1) { * <font color="red">新的权限体系将废弃</font>
return AgentAuthType.MANAGE; */
} @JSONField(name = "api_group")
return null; private List<String> apiGroup;
} /**
* 应用对应的权限,<font color="red">新的权限体系</font>
public int getAppId() { */
return appId; @JSONField(name = "privilege")
} private PrivilegeInfo privilege;
public List<String> getApiGroup() { public int getAuthType() {
return apiGroup; return authType;
} }
// ---------- setter 应该全部去掉 @JSONField(serialize = false)
public AgentAuthType getFormatAuthType() {
public void setAuthType(int authType) { if (authType == 0) {
this.authType = authType; return AgentAuthType.USE;
} } else if (authType == 1) {
return AgentAuthType.MANAGE;
public void setAppId(int appId) { }
this.appId = appId; return null;
} }
public void setApiGroup(List<String> apiGroup) { public int getAppId() {
this.apiGroup = apiGroup; return appId;
} }
@Override public List<String> getApiGroup() {
public String toString() { return apiGroup;
return "AgentItem [authType=" + authType + ", appId=" + appId }
+ ", apiGroup=" + apiGroup + ", " + super.toString() + "]";
} // ---------- setter 应该全部去掉
}
public PrivilegeInfo getPrivilege() {
/** return privilege;
* 授权的通讯录部门 }
*
* @className DepartItem public void setPrivilege(PrivilegeInfo privilege) {
* @author jy this.privilege = privilege;
* @date 2015年6月22日 }
* @since JDK 1.6
* @see public void setAuthType(int authType) {
*/ this.authType = authType;
public static class DepartItem extends Party { }
private static final long serialVersionUID = 556556672204642407L; public void setAppId(int appId) {
this.appId = appId;
/** }
* 是否具有该部门的写权限
*/ public void setApiGroup(List<String> apiGroup) {
private boolean writable; this.apiGroup = apiGroup;
}
public boolean isWritable() {
return writable; @Override
} public String toString() {
return "AgentItem [authType=" + authType + ", appId=" + appId + ", apiGroup=" + apiGroup + ", privilege="
// ---------- setter 应该全部去掉 + privilege + ", " + super.toString() + "]";
public void setWritable(boolean writable) { }
this.writable = writable; }
}
/**
@Override * 授权的通讯录部门
public String toString() { *
return "DepartItem [writable=" + writable + ", " + super.toString() * @className DepartItem
+ "]"; * @author jy
} * @date 2015年6月22日
} * @since JDK 1.6
} * @see
*/
public static class DepartItem extends Party {
private static final long serialVersionUID = 556556672204642407L;
/**
* 是否具有该部门的写权限
*/
private boolean writable;
public boolean isWritable() {
return writable;
}
// ---------- setter 应该全部去掉
public void setWritable(boolean writable) {
this.writable = writable;
}
@Override
public String toString() {
return "DepartItem [writable=" + writable + ", " + super.toString() + "]";
}
}
}

View File

@ -0,0 +1,122 @@
package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
/**
* 权限信息
*
* @className Privilege
* @author jy
* @date 2016年3月28日
* @since JDK 1.6
* @see
*/
public class PrivilegeInfo implements Serializable {
private static final long serialVersionUID = 2689295767648714897L;
/**
* 权限级别
*/
private int level;
/**
* 应用可见范围成员
*/
@JSONField(name = "allow_user")
private List<String> allowUserIds;
/**
* 应用可见范围部门
*/
@JSONField(name = "allow_party")
private List<Integer> allowPartyIds;
/**
* 应用可见范围标签
*/
@JSONField(name = "allow_tag")
private List<Integer> allowTagIds;
/**
* 额外通讯录成员
*/
@JSONField(name = "extra_user")
private List<String> extraUserIds;
/**
* 额外通讯录部门
*/
@JSONField(name = "extra_party")
private List<Integer> extraPartyIds;
/**
* 额外通讯录标签
*/
@JSONField(name = "extra_tag")
private List<Integer> extraTagIds;
public int getLevel() {
return level;
}
@JSONField(serialize = false)
public PrivilegeLevel getFormatLevel() {
return PrivilegeLevel.values()[level - 1];
}
public void setLevel(int level) {
this.level = level;
}
public List<String> getAllowUserIds() {
return allowUserIds;
}
public void setAllowUserIds(List<String> allowUserIds) {
this.allowUserIds = allowUserIds;
}
public List<Integer> getAllowPartyIds() {
return allowPartyIds;
}
public void setAllowPartyIds(List<Integer> allowPartyIds) {
this.allowPartyIds = allowPartyIds;
}
public List<Integer> getAllowTagIds() {
return allowTagIds;
}
public void setAllowTagIds(List<Integer> allowTagIds) {
this.allowTagIds = allowTagIds;
}
public List<String> getExtraUserIds() {
return extraUserIds;
}
public void setExtraUserIds(List<String> extraUserIds) {
this.extraUserIds = extraUserIds;
}
public List<Integer> getExtraPartyIds() {
return extraPartyIds;
}
public void setExtraPartyIds(List<Integer> extraPartyIds) {
this.extraPartyIds = extraPartyIds;
}
public List<Integer> getExtraTagIds() {
return extraTagIds;
}
public void setExtraTagIds(List<Integer> extraTagIds) {
this.extraTagIds = extraTagIds;
}
@Override
public String toString() {
return "PrivilegeInfo [level=" + level + ", allowUserIds=" + allowUserIds + ", allowPartyIds=" + allowPartyIds
+ ", allowTagIds=" + allowTagIds + ", extraUserIds=" + extraUserIds + ", extraPartyIds=" + extraPartyIds
+ ", extraTagIds=" + extraTagIds + "]";
}
}

View File

@ -0,0 +1,35 @@
package com.foxinmy.weixin4j.qy.model;
/**
* 权限级别
*
* @className Privilege
* @author jy
* @date 2016年3月28日
* @since JDK 1.6
* @see
*/
public enum PrivilegeLevel {
/**
* 标识只读
*/
IDENTIFYING_READABLE(1),
/**
* 信息只读
*/
INFORMATION_READABLE(2),
/**
* 信息读写
*/
INFORMATION_READABLE$WRITABLE(3);
private int level;
PrivilegeLevel(int level) {
this.level = level;
}
public int getLevel() {
return this.level;
}
}