LAPTOP-SB56SG4Q\86185
3 years ago
36 changed files with 2218 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-9481 |
||||
|
||||
JSD-9481 组织维度管理 |
||||
JSD-9481 组织维度管理\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.idha.org</id> |
||||
<name><![CDATA[组织维度管理]]></name> |
||||
<active>yes</active> |
||||
<version>1.1</version> |
||||
<env-version>10.0~11.0</env-version> |
||||
<jartime>2021-06-13</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[组织维度管理]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2021-06-13]适配升级,角色查询功能修改。<br/> |
||||
版本1.0主要功能:<br/> |
||||
组织维度管理。<br/> |
||||
]]></change-notes> |
||||
<main-package>com.fr.plugin.idha</main-package> |
||||
<extra-decision> |
||||
<SystemOptionProvider class="com.fr.plugin.idha.interfaces.OrganizationSystemOption"/> |
||||
<HttpHandlerProvider class="com.fr.plugin.idha.interfaces.OrganizationHttpHandlerProvider"/> |
||||
</extra-decision> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugin.idha.LocaleFinder"/> |
||||
<DBAccessProvider class="com.fr.plugin.idha.interfaces.RoleGroupDBAccess"/> |
||||
<FunctionDefineProvider class="com.fr.plugin.idha.function.GetExpandRole" name="GetExpandRole" |
||||
description="用户维度查询函数。示例:GetExpandRole($$$)"/> |
||||
</extra-core> |
||||
<function-recorder class="com.fr.plugin.idha.LocaleFinder"/> |
||||
</plugin> |
@ -0,0 +1,22 @@
|
||||
/** |
||||
* Copyright (C), 2015-2019 |
||||
* FileName: Constants |
||||
* Author: Louis |
||||
* Date: 2019/9/4 16:09 |
||||
* Description: Constants |
||||
* History: |
||||
* <author> <time> <version> <desc> |
||||
*/ |
||||
package com.fr.plugin.idha; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈Constants〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class Constants { |
||||
public static final String PLUGIN_ID = "com.fr.plugin.idha.org"; |
||||
public static final String ICON_PATH = "/com/fr/plugin/idha/images/logo16.png"; |
||||
} |
@ -0,0 +1,45 @@
|
||||
/** |
||||
* Copyright (C), 2015-2019 |
||||
* FileName: LocaleFinder |
||||
* Author: Louis |
||||
* Date: 2019/9/4 16:20 |
||||
* Description: LocaleFinder |
||||
* History: |
||||
* <author> <time> <version> <desc> |
||||
*/ |
||||
package com.fr.plugin.idha; |
||||
|
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
import static com.fr.plugin.idha.Constants.PLUGIN_ID; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈LocaleFinder〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
@EnableMetrics |
||||
@Authorize(callSignKey = PLUGIN_ID) |
||||
public class LocaleFinder extends AbstractLocaleFinder { |
||||
@Override |
||||
@Focus(id = PLUGIN_ID, text = "Plugin-idha", source = Original.PLUGIN) |
||||
public String find() { |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
return "com/fr/plugin/idha/locale/lang"; |
||||
} |
||||
return StringKit.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: Group |
||||
* Author: Louis |
||||
* Date: 2020/6/11 15:01 |
||||
*/ |
||||
package com.fr.plugin.idha.bean; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈Group〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class Group { |
||||
private String id; |
||||
private Boolean isParent; |
||||
private Boolean open; |
||||
private String pId; |
||||
private String pText; |
||||
private String parentNames; |
||||
private String privilegeDetailBeanList; |
||||
private String text; |
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("id", this.getId()); |
||||
result.put("isParent", this.getParent()); |
||||
result.put("open", this.getOpen()); |
||||
result.put("pId", this.getpId()); |
||||
result.put("pText", this.getpText()); |
||||
result.put("parentNames", JSONArray.create()); |
||||
result.put("privilegeDetailBeanList", this.getPrivilegeDetailBeanList()); |
||||
result.put("text", this.getText()); |
||||
return result; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Boolean getParent() { |
||||
return isParent; |
||||
} |
||||
|
||||
public void setParent(Boolean parent) { |
||||
isParent = parent; |
||||
} |
||||
|
||||
public Boolean getOpen() { |
||||
return open; |
||||
} |
||||
|
||||
public void setOpen(Boolean open) { |
||||
this.open = open; |
||||
} |
||||
|
||||
public String getpId() { |
||||
return pId; |
||||
} |
||||
|
||||
public void setpId(String pId) { |
||||
this.pId = pId; |
||||
} |
||||
|
||||
public String getpText() { |
||||
return pText; |
||||
} |
||||
|
||||
public void setpText(String pText) { |
||||
this.pText = pText; |
||||
} |
||||
|
||||
public String getParentNames() { |
||||
return parentNames; |
||||
} |
||||
|
||||
public void setParentNames(String parentNames) { |
||||
this.parentNames = parentNames; |
||||
} |
||||
|
||||
public String getPrivilegeDetailBeanList() { |
||||
return privilegeDetailBeanList; |
||||
} |
||||
|
||||
public void setPrivilegeDetailBeanList(String privilegeDetailBeanList) { |
||||
this.privilegeDetailBeanList = privilegeDetailBeanList; |
||||
} |
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public void setText(String text) { |
||||
this.text = text; |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GroupCode |
||||
* Author: Louis |
||||
* Date: 2020/6/26 21:33 |
||||
*/ |
||||
package com.fr.plugin.idha.bean; |
||||
|
||||
import com.fanruan.api.util.CodeKit; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <GroupCode> |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GroupCode { |
||||
private String id; |
||||
private String groupId; |
||||
private String roleId; |
||||
private String groupCode; |
||||
private String codeName; |
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("id", CodeKit.encodeURIComponent(this.getGroupCode())); |
||||
result.put("text", this.getCodeName()); |
||||
result.put("description", this.getCodeName()); |
||||
return result; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public String getRoleId() { |
||||
return roleId; |
||||
} |
||||
|
||||
public void setRoleId(String roleId) { |
||||
this.roleId = roleId; |
||||
} |
||||
|
||||
public String getGroupCode() { |
||||
return groupCode; |
||||
} |
||||
|
||||
public void setGroupCode(String groupCode) { |
||||
this.groupCode = groupCode; |
||||
} |
||||
|
||||
public String getCodeName() { |
||||
return codeName; |
||||
} |
||||
|
||||
public void setCodeName(String codeName) { |
||||
this.codeName = codeName; |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroup |
||||
* Author: Louis |
||||
* Date: 2020/6/3 16:31 |
||||
*/ |
||||
package com.fr.plugin.idha.bean; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.stable.db.data.BaseDataRecord; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroup〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroup extends BaseDataRecord implements Serializable { |
||||
private static final long serialVersionUID = -1056416324881106459L; |
||||
|
||||
private String groupCode; |
||||
private String groupName; |
||||
private String connection; |
||||
private String sql; |
||||
private long timeStamp; |
||||
|
||||
public RoleGroup() { |
||||
} |
||||
|
||||
public RoleGroupEntity createEntity(RoleGroupEntity roleGroupEntity) { |
||||
roleGroupEntity.setId(this.getId()); |
||||
roleGroupEntity.setGroupCode(this.groupCode); |
||||
roleGroupEntity.setGroupName(this.groupName); |
||||
roleGroupEntity.setConnection(this.connection); |
||||
roleGroupEntity.setSql(this.sql); |
||||
roleGroupEntity.setTimeStamp(this.timeStamp); |
||||
return roleGroupEntity; |
||||
} |
||||
|
||||
public String getGroupCode() { |
||||
return this.groupCode; |
||||
} |
||||
|
||||
public void setGroupCode(String groupCode) { |
||||
this.groupCode = groupCode; |
||||
} |
||||
|
||||
public String getGroupName() { |
||||
return this.groupName; |
||||
} |
||||
|
||||
public void setGroupName(String groupName) { |
||||
this.groupName = groupName; |
||||
} |
||||
|
||||
public String getConnection() { |
||||
return this.connection; |
||||
} |
||||
|
||||
public void setConnection(String connection) { |
||||
this.connection = connection; |
||||
} |
||||
|
||||
public String getSql() { |
||||
return this.sql; |
||||
} |
||||
|
||||
public void setSql(String sql) { |
||||
this.sql = sql; |
||||
} |
||||
|
||||
public long getTimeStamp() { |
||||
return this.timeStamp; |
||||
} |
||||
|
||||
public void setTimeStamp(long timeStamp) { |
||||
this.timeStamp = timeStamp; |
||||
} |
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("id", this.getId()); |
||||
result.put("groupCode", this.groupCode); |
||||
result.put("groupName", this.groupName); |
||||
result.put("connection", this.connection); |
||||
result.put("sql", this.sql); |
||||
return result; |
||||
} |
||||
|
||||
public JSONObject toJSONRootNode() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("value", this.getId()); |
||||
result.put("text", this.groupName); |
||||
result.put("cardType", "roleGroup.user.group"); |
||||
return result; |
||||
} |
||||
|
||||
public boolean equals(Object obj) { |
||||
return obj instanceof RoleGroupEntity && ComparatorUtils.equals(((RoleGroupEntity) obj).getId(), this.getId()); |
||||
} |
||||
} |
@ -0,0 +1,80 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupMiddle |
||||
* Author: Louis |
||||
* Date: 2020/6/4 14:38 |
||||
*/ |
||||
package com.fr.plugin.idha.bean; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.idha.entity.RoleGroupMiddleEntity; |
||||
import com.fr.stable.db.data.BaseDataRecord; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupMiddle〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroupMiddle extends BaseDataRecord implements Serializable { |
||||
private static final long serialVersionUID = -915422230631687470L; |
||||
|
||||
private String groupId; |
||||
private String code; |
||||
private String roleId; |
||||
|
||||
public RoleGroupMiddle() { |
||||
} |
||||
|
||||
public RoleGroupMiddleEntity createEntity(RoleGroupMiddleEntity roleGroupMiddleEntity) { |
||||
roleGroupMiddleEntity.setId(this.getId()); |
||||
roleGroupMiddleEntity.setGroupId(this.getGroupId()); |
||||
roleGroupMiddleEntity.setCode(this.getCode()); |
||||
roleGroupMiddleEntity.setRoleId(this.getRoleId()); |
||||
return roleGroupMiddleEntity; |
||||
} |
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("id", this.getId()); |
||||
result.put("groupId", this.getGroupId()); |
||||
result.put("code", this.getCode()); |
||||
result.put("roleId", this.getRoleId()); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
return obj instanceof RoleGroupMiddleEntity && ComparatorUtils.equals(((RoleGroupMiddleEntity) obj).getId(), this.getId()); |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getRoleId() { |
||||
return roleId; |
||||
} |
||||
|
||||
public void setRoleId(String roleId) { |
||||
this.roleId = roleId; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupDAO |
||||
* Author: Louis |
||||
* Date: 2020/6/4 11:44 |
||||
*/ |
||||
package com.fr.plugin.idha.dao; |
||||
|
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupDAO〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroupDao extends BaseDAO<RoleGroupEntity> { |
||||
public final static DAOProvider<RoleGroupEntity> DAO = new DAOProvider<RoleGroupEntity>() { |
||||
@Override |
||||
public Class<RoleGroupEntity> getEntityClass() { |
||||
return RoleGroupEntity.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BaseDAO<RoleGroupEntity>> getDAOClass() { |
||||
return RoleGroupDao.class; |
||||
} |
||||
}; |
||||
|
||||
public RoleGroupDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
|
||||
@Override |
||||
protected Class<RoleGroupEntity> getEntityClass() { |
||||
return RoleGroupEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupMiddleDao |
||||
* Author: Louis |
||||
* Date: 2020/6/4 14:33 |
||||
*/ |
||||
package com.fr.plugin.idha.dao; |
||||
|
||||
import com.fr.plugin.idha.entity.RoleGroupMiddleEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupMiddleDao〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroupMiddleDao extends BaseDAO<RoleGroupMiddleEntity> { |
||||
public final static DAOProvider<RoleGroupMiddleEntity> DAO = new DAOProvider<RoleGroupMiddleEntity>() { |
||||
@Override |
||||
public Class<RoleGroupMiddleEntity> getEntityClass() { |
||||
return RoleGroupMiddleEntity.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BaseDAO<RoleGroupMiddleEntity>> getDAOClass() { |
||||
return RoleGroupMiddleDao.class; |
||||
} |
||||
}; |
||||
|
||||
public RoleGroupMiddleDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
|
||||
@Override |
||||
protected Class<RoleGroupMiddleEntity> getEntityClass() { |
||||
return RoleGroupMiddleEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,125 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupEntity |
||||
* Author: Louis |
||||
* Date: 2020/6/3 16:18 |
||||
*/ |
||||
package com.fr.plugin.idha.entity; |
||||
|
||||
import com.fr.plugin.idha.bean.RoleGroup; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupEntity〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
@Entity |
||||
@Table(name = "fine_role_group") |
||||
public class RoleGroupEntity extends BaseEntity { |
||||
public static final String COLUMN_GROUP_CODE = "groupCode"; |
||||
public static final String COLUMN_GROUP_NAME = "groupName"; |
||||
public static final String COLUMN_CONNECTION = "connection"; |
||||
public static final String COLUMN_SQL = "sql"; |
||||
public static final String COLUMN_TIMESTAMP = "timeStamp"; |
||||
private static final long serialVersionUID = 2019521971055841884L; |
||||
@Column(name = "groupCode") |
||||
private String groupCode = ""; |
||||
@Column(name = "groupName") |
||||
private String groupName = ""; |
||||
@Column(name = "connection") |
||||
private String connection = ""; |
||||
@Column(name = "sql") |
||||
private String sql = ""; |
||||
@Column(name = "timeStamp") |
||||
private long timeStamp = 0L; |
||||
|
||||
public RoleGroupEntity() { |
||||
} |
||||
|
||||
public RoleGroup createBean(RoleGroup group) { |
||||
group.setId(this.getId()); |
||||
group.setGroupCode(this.getGroupCode()); |
||||
group.setGroupName(this.getGroupName()); |
||||
group.setConnection(this.getConnection()); |
||||
group.setSql(this.getSql()); |
||||
group.setTimeStamp(this.getTimeStamp()); |
||||
return group; |
||||
} |
||||
|
||||
public RoleGroupEntity id(String id) { |
||||
this.setId(id); |
||||
return this; |
||||
} |
||||
|
||||
public String getGroupCode() { |
||||
return this.groupCode; |
||||
} |
||||
|
||||
public void setGroupCode(String groupCode) { |
||||
this.groupCode = groupCode; |
||||
} |
||||
|
||||
public RoleGroupEntity groupName(String groupName) { |
||||
this.setGroupName(groupName); |
||||
return this; |
||||
} |
||||
|
||||
public String getGroupName() { |
||||
return this.groupName; |
||||
} |
||||
|
||||
public void setGroupName(String groupName) { |
||||
this.groupName = groupName; |
||||
} |
||||
|
||||
public RoleGroupEntity groupCode(String groupCode) { |
||||
this.setGroupCode(groupCode); |
||||
return this; |
||||
} |
||||
|
||||
public String getConnection() { |
||||
return this.connection; |
||||
} |
||||
|
||||
public void setConnection(String connection) { |
||||
this.connection = connection; |
||||
} |
||||
|
||||
public RoleGroupEntity connection(String connection) { |
||||
this.setConnection(connection); |
||||
return this; |
||||
} |
||||
|
||||
public String getSql() { |
||||
return this.sql; |
||||
} |
||||
|
||||
public void setSql(String sql) { |
||||
this.sql = sql; |
||||
} |
||||
|
||||
public RoleGroupEntity sql(String sql) { |
||||
this.setSql(sql); |
||||
return this; |
||||
} |
||||
|
||||
public long getTimeStamp() { |
||||
return this.timeStamp; |
||||
} |
||||
|
||||
public void setTimeStamp(long timeStamp) { |
||||
this.timeStamp = timeStamp; |
||||
} |
||||
|
||||
public RoleGroupEntity timeStamp(long timeStamp) { |
||||
this.setTimeStamp(timeStamp); |
||||
return this; |
||||
} |
||||
} |
@ -0,0 +1,89 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupMiddleEntity |
||||
* Author: Louis |
||||
* Date: 2020/6/4 14:14 |
||||
*/ |
||||
package com.fr.plugin.idha.entity; |
||||
|
||||
import com.fanruan.api.util.AssistKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupMiddleEntity〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
@Entity |
||||
@Table(name = "fine_role_group_middle") |
||||
public class RoleGroupMiddleEntity extends BaseEntity { |
||||
public static final String COLUMN_GROUP_ID = "groupId"; |
||||
public static final String COLUMN_CODE = "code"; |
||||
public static final String COLUMN_ROLE_ID = "roleId"; |
||||
|
||||
@Column(name = "groupId") |
||||
private String groupId = StringKit.EMPTY; |
||||
@Column(name = "code") |
||||
private String code = StringKit.EMPTY; |
||||
@Column(name = "roleId") |
||||
private String roleId = StringKit.EMPTY; |
||||
|
||||
public RoleGroupMiddleEntity() { |
||||
} |
||||
|
||||
public RoleGroupMiddleEntity id(String id) { |
||||
this.setId(id); |
||||
return this; |
||||
} |
||||
|
||||
public RoleGroupMiddleEntity groupId(String groupId) { |
||||
this.setGroupId(groupId); |
||||
return this; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public RoleGroupMiddleEntity code(String code) { |
||||
this.setCode(code); |
||||
return this; |
||||
} |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public RoleGroupMiddleEntity roleId(String roleId) { |
||||
this.setRoleId(roleId); |
||||
return this; |
||||
} |
||||
|
||||
public String getRoleId() { |
||||
return roleId; |
||||
} |
||||
|
||||
public void setRoleId(String roleId) { |
||||
this.roleId = roleId; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return AssistKit.toString(this); |
||||
} |
||||
} |
@ -0,0 +1,82 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetExpandRole |
||||
* Author: Louis |
||||
* Date: 2020/6/14 15:31 |
||||
*/ |
||||
package com.fr.plugin.idha.function; |
||||
|
||||
import com.fanruan.api.decision.user.UserKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.base.Utils; |
||||
import com.fr.decision.authority.data.CustomRole; |
||||
import com.fr.decision.webservice.v10.user.CustomRoleService; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.script.AbstractFunction; |
||||
import com.fr.stable.Primitive; |
||||
import com.fr.stable.script.Function; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈GetExpandRole〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetExpandRole extends AbstractFunction { |
||||
|
||||
public GetExpandRole() { |
||||
} |
||||
|
||||
@Override |
||||
public Object run(Object[] args) { |
||||
if (args.length < 1) { |
||||
return Primitive.ERROR_NAME; |
||||
} |
||||
String userName = Utils.objectToString(args[0]); |
||||
String groupRootCode = StringKit.EMPTY; |
||||
if (ComparatorUtils.equals(args.length, 2)) { |
||||
groupRootCode = Utils.objectToString(args[1]); |
||||
} |
||||
if (StringKit.isEmpty(userName)) { |
||||
return Primitive.ERROR_NAME; |
||||
} |
||||
try { |
||||
String userId = UserKit.getUser(userName).getId(); |
||||
HashSet<String> roleIds = getCustomRoleIds(userId); |
||||
HashSet<String> codeSet = RoleGroupService.GetCodeList(roleIds, groupRootCode); |
||||
return codeSet.toString(); |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
return Primitive.ERROR_NAME; |
||||
} |
||||
|
||||
@Override |
||||
public Type getType() { |
||||
return OTHER; |
||||
} |
||||
|
||||
/** |
||||
* 通过userid查询自定义角色id |
||||
* |
||||
* @param userId |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private HashSet<String> getCustomRoleIds(@NotNull String userId) throws Exception { |
||||
HashSet<String> result = new HashSet<String>(); |
||||
List<CustomRole> customRoleList = CustomRoleService.getInstance().getCustomRolesByUser(userId); |
||||
for (CustomRole customRole : customRoleList) { |
||||
result.add(customRole.getId()); |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: OrganizationComponent |
||||
* Author: Louis |
||||
* Date: 2020/6/3 15:07 |
||||
*/ |
||||
package com.fr.plugin.idha.interfaces; |
||||
|
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈OrganizationComponent〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class OrganizationComponent extends Component { |
||||
public static OrganizationComponent KEY = new OrganizationComponent(); |
||||
|
||||
public OrganizationComponent() { |
||||
} |
||||
|
||||
@Override |
||||
public ScriptPath script(RequestClient client) { |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
return ScriptPath.build("/com/fr/plugin/idha/web/idha.js"); |
||||
} |
||||
return ScriptPath.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public StylePath style(RequestClient client) { |
||||
return StylePath.build("/com/fr/plugin/idha/web/idha.css"); |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: OrganizationHttpHandlerProvider |
||||
* Author: Louis |
||||
* Date: 2020/6/3 15:36 |
||||
*/ |
||||
package com.fr.plugin.idha.interfaces; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.web.http.*; |
||||
import com.fr.stable.fun.Authorize; |
||||
|
||||
import static com.fr.plugin.idha.Constants.PLUGIN_ID; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈OrganizationHttpHandlerProvider〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
@Authorize(callSignKey = PLUGIN_ID) |
||||
public class OrganizationHttpHandlerProvider extends AbstractHttpHandlerProvider { |
||||
public OrganizationHttpHandlerProvider() { |
||||
} |
||||
|
||||
@Override |
||||
public BaseHttpHandler[] registerHandlers() { |
||||
if (!PluginContexts.currentContext().isAvailable()) { |
||||
return new BaseHttpHandler[]{}; |
||||
} |
||||
return new BaseHttpHandler[]{ |
||||
new GetCodesHandler(), |
||||
new SearchGroupsHandler(), |
||||
new GetGroupsHandler(), |
||||
new GetRolesHandler(), |
||||
new UpdateRoleGroupMiddleHandler(), |
||||
new GetRoleGroupRootHandler(), |
||||
new GetRoleGroupHandler(), |
||||
new DeleteRoleGroupHandler(), |
||||
new SaveRoleGroupHandler() |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: OrganizationSystemOption |
||||
* Author: Louis |
||||
* Date: 2020/6/3 14:23 |
||||
*/ |
||||
package com.fr.plugin.idha.interfaces; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fr.decision.fun.impl.AbstractSystemOptionProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈组织维度管理〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class OrganizationSystemOption extends AbstractSystemOptionProvider { |
||||
public OrganizationSystemOption() { |
||||
} |
||||
|
||||
@Override |
||||
public String id() { |
||||
return "OrganizationSystemOption"; |
||||
} |
||||
|
||||
@Override |
||||
public String displayName() { |
||||
return I18nKit.getLocText("Plugin-idha_Organizational_Dimension_Manager"); |
||||
} |
||||
|
||||
@Override |
||||
public int sortIndex() { |
||||
return 2; |
||||
} |
||||
|
||||
@Override |
||||
public Atom attach() { |
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
return OrganizationComponent.KEY; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupDBAccess |
||||
* Author: Louis |
||||
* Date: 2020/6/4 11:48 |
||||
*/ |
||||
package com.fr.plugin.idha.interfaces; |
||||
|
||||
import com.fr.plugin.db.AbstractDBAccessProvider; |
||||
import com.fr.plugin.idha.dao.RoleGroupDao; |
||||
import com.fr.plugin.idha.dao.RoleGroupMiddleDao; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupDBAccess〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroupDBAccess extends AbstractDBAccessProvider { |
||||
private static DBAccessor accessor; |
||||
|
||||
public RoleGroupDBAccess() { |
||||
} |
||||
|
||||
public static DBAccessor getAccessor() { |
||||
return accessor; |
||||
} |
||||
|
||||
@Override |
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{ |
||||
RoleGroupDao.DAO, |
||||
RoleGroupMiddleDao.DAO |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void onDBAvailable(DBAccessor dbAccessor) { |
||||
accessor = dbAccessor; |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: HttpUtils |
||||
* Author: Louis |
||||
* Date: 2020/6/4 15:45 |
||||
*/ |
||||
package com.fr.plugin.idha.util; |
||||
|
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈HttpUtils〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class HttpUtils { |
||||
public static JSONObject createSuccessResponseJSONObject() throws JSONException { |
||||
JSONObject result = JSONObject.create(); |
||||
result.put("errorCode", 0); |
||||
result.put("status", "success"); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,413 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: RoleGroupService |
||||
* Author: Louis |
||||
* Date: 2020/6/4 16:12 |
||||
*/ |
||||
package com.fr.plugin.idha.web; |
||||
|
||||
import com.fanruan.api.data.ConnectionKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.data.impl.AbstractDBDataModel; |
||||
import com.fr.data.impl.Connection; |
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.decision.base.util.UUIDUtil; |
||||
import com.fr.decision.webservice.bean.user.RoleBean; |
||||
import com.fr.decision.webservice.v10.user.CustomRoleService; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.plugin.idha.bean.Group; |
||||
import com.fr.plugin.idha.bean.GroupCode; |
||||
import com.fr.plugin.idha.dao.RoleGroupDao; |
||||
import com.fr.plugin.idha.dao.RoleGroupMiddleDao; |
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.plugin.idha.entity.RoleGroupMiddleEntity; |
||||
import com.fr.plugin.idha.interfaces.RoleGroupDBAccess; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈RoleGroupService〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class RoleGroupService { |
||||
/** |
||||
* 查询全部角色组,按照时间排序 |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static List<RoleGroupEntity> getAllSortedByTimeStamp() throws Exception { |
||||
return RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<List<RoleGroupEntity>>() { |
||||
@Override |
||||
public List<RoleGroupEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupDao.class).find(QueryFactory.create().addSort("timeStamp", true)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询全部角色组 |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static List<RoleGroupEntity> getAll() throws Exception { |
||||
return RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<List<RoleGroupEntity>>() { |
||||
@Override |
||||
public List<RoleGroupEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupDao.class).find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Save |
||||
* |
||||
* @param saveRoleGroup |
||||
* @throws Exception |
||||
*/ |
||||
public static void save(final RoleGroupEntity saveRoleGroup) throws Exception { |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupEntity>() { |
||||
@Override |
||||
public RoleGroupEntity run(DAOContext daoContext) throws Exception { |
||||
(daoContext.getDAO(RoleGroupDao.class)).addOrUpdate(saveRoleGroup); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Delete |
||||
* |
||||
* @param id |
||||
* @throws Exception |
||||
*/ |
||||
public static void delete(final String id) throws Exception { |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupEntity>() { |
||||
@Override |
||||
public RoleGroupEntity run(DAOContext daoContext) throws Exception { |
||||
(daoContext.getDAO(RoleGroupDao.class)).remove(id); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 通过groupCode查询自定义角色 |
||||
* |
||||
* @param groupId |
||||
* @param groupCode |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static List<RoleBean> getRolesByGroupId(final String groupId, final String groupCode) throws Exception { |
||||
List<RoleGroupMiddleEntity> middleEntityList = RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<List<RoleGroupMiddleEntity>>() { |
||||
@Override |
||||
public List<RoleGroupMiddleEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupMiddleDao.class).find( |
||||
QueryFactory.create().addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_GROUP_ID, groupId)) |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_CODE, groupCode)) |
||||
); |
||||
} |
||||
}); |
||||
if (middleEntityList == null || middleEntityList.isEmpty()) { |
||||
return null; |
||||
} |
||||
List<RoleBean> roleEntityList = new ArrayList<>(); |
||||
RoleBean roleBean; |
||||
for (final RoleGroupMiddleEntity middleEntity : middleEntityList) { |
||||
roleBean = CustomRoleService.getInstance().getCustomRole(middleEntity.getRoleId()); |
||||
roleEntityList.add(roleBean); |
||||
} |
||||
return roleEntityList; |
||||
} |
||||
|
||||
/** |
||||
* 删除维度与自定义角色关联 |
||||
* |
||||
* @param groupId |
||||
* @param code |
||||
* @param roleIds |
||||
* @throws Exception |
||||
*/ |
||||
public static void deleteMiddle(final String groupId, final String code, final Set<String> roleIds) throws Exception { |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupMiddleEntity>() { |
||||
@Override |
||||
public RoleGroupMiddleEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(RoleGroupMiddleDao.class).remove( |
||||
QueryFactory.create() |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_GROUP_ID, groupId)) |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_CODE, code)) |
||||
.addRestriction(RestrictionFactory.in(RoleGroupMiddleEntity.COLUMN_ROLE_ID, roleIds)) |
||||
); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增维度与自定义角色关联 |
||||
* |
||||
* @param groupId |
||||
* @param code |
||||
* @param roleIds |
||||
* @throws Exception |
||||
*/ |
||||
public static void saveMiddle(final String groupId, final String code, final Set<String> roleIds) throws Exception { |
||||
for (String roleId : roleIds) { |
||||
final RoleGroupMiddleEntity roleGroupMiddleEntity = (new RoleGroupMiddleEntity()) |
||||
.id(UUIDUtil.generate()) |
||||
.groupId(groupId) |
||||
.code(code) |
||||
.roleId(roleId); |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupMiddleEntity>() { |
||||
@Override |
||||
public RoleGroupMiddleEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(RoleGroupMiddleDao.class).addOrUpdate(roleGroupMiddleEntity); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除自定义角色与维度code关联 |
||||
* |
||||
* @param groupId |
||||
* @param roleId |
||||
* @param groupCodes |
||||
* @throws Exception |
||||
*/ |
||||
public static void deleteMiddleByID(final String groupId, final String roleId, final Set<String> groupCodes) throws Exception { |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupMiddleEntity>() { |
||||
@Override |
||||
public RoleGroupMiddleEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(RoleGroupMiddleDao.class).remove( |
||||
QueryFactory.create() |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_GROUP_ID, groupId)) |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_ROLE_ID, roleId)) |
||||
.addRestriction(RestrictionFactory.in(RoleGroupMiddleEntity.COLUMN_CODE, groupCodes)) |
||||
); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增自定义角色与维度code关联 |
||||
* |
||||
* @param groupId |
||||
* @param roleId |
||||
* @param groupCodes |
||||
* @throws Exception |
||||
*/ |
||||
public static void saveMiddleByCode(final String groupId, final String roleId, final Set<String> groupCodes) throws Exception { |
||||
for (String code : groupCodes) { |
||||
final RoleGroupMiddleEntity roleGroupMiddleEntity = (new RoleGroupMiddleEntity()) |
||||
.id(UUIDUtil.generate()) |
||||
.groupId(groupId) |
||||
.roleId(roleId) |
||||
.code(code); |
||||
RoleGroupDBAccess.getAccessor().runDMLAction(new DBAction<RoleGroupMiddleEntity>() { |
||||
@Override |
||||
public RoleGroupMiddleEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(RoleGroupMiddleDao.class).addOrUpdate(roleGroupMiddleEntity); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 查询指定维度的code列表 |
||||
* |
||||
* @param rootId |
||||
* @param pId |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static List<Group> getCodeByID(final String rootId, final String pId) throws Exception { |
||||
RoleGroupEntity roleGroupEntity = getRoleGroupEntity(rootId); |
||||
if (roleGroupEntity == null || StringKit.isEmpty(roleGroupEntity.getGroupCode()) |
||||
|| StringKit.isEmpty(roleGroupEntity.getConnection()) || StringKit.isEmpty(roleGroupEntity.getSql())) { |
||||
return null; |
||||
} |
||||
Connection connection = ConnectionKit.getConnection(roleGroupEntity.getConnection()); |
||||
if (connection == null) { |
||||
return null; |
||||
} |
||||
AbstractDBDataModel dataModel = DBTableData.createCacheableDBResultSet(connection, roleGroupEntity.getSql(), -1); |
||||
if (!ComparatorUtils.equals(dataModel.getColumnCount(), 3)) { |
||||
return null; |
||||
} |
||||
List<Group> result = new ArrayList<Group>(); |
||||
String filter = StringKit.equals(rootId, pId) ? roleGroupEntity.getGroupCode() : pId; |
||||
for (int row = 0; row < dataModel.getRowCount(); row++) { |
||||
if (StringKit.equals(filter, String.valueOf(dataModel.getValueAt(row, 1)))) { |
||||
result.add(createGroup(roleGroupEntity, dataModel, row)); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 搜索code值列表 |
||||
* |
||||
* @param rootId |
||||
* @param keyword |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static List<Group> searchGroupCode(final String rootId, final String keyword) throws Exception { |
||||
RoleGroupEntity roleGroupEntity = getRoleGroupEntity(rootId); |
||||
if (roleGroupEntity == null || StringKit.isEmpty(roleGroupEntity.getConnection()) || StringKit.isEmpty(roleGroupEntity.getSql())) { |
||||
return null; |
||||
} |
||||
Connection connection = ConnectionKit.getConnection(roleGroupEntity.getConnection()); |
||||
if (connection == null) { |
||||
return null; |
||||
} |
||||
AbstractDBDataModel dataModel = DBTableData.createCacheableDBResultSet(connection, roleGroupEntity.getSql(), -1); |
||||
if (!ComparatorUtils.equals(dataModel.getColumnCount(), 3)) { |
||||
return null; |
||||
} |
||||
List<Group> result = new ArrayList<Group>(); |
||||
for (int row = 0; row < dataModel.getRowCount(); row++) { |
||||
if (String.valueOf(dataModel.getValueAt(row, 2)).contains(keyword)) { |
||||
result.add(createGroup(roleGroupEntity, dataModel, row)); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@NotNull |
||||
private static Group createGroup(RoleGroupEntity roleGroupEntity, AbstractDBDataModel dataModel, int row) throws TableDataException { |
||||
Group group = new Group(); |
||||
group.setId(String.valueOf(dataModel.getValueAt(row, 0))); |
||||
group.setParent(Boolean.FALSE); |
||||
group.setOpen(Boolean.FALSE); |
||||
group.setpId(String.valueOf(dataModel.getValueAt(row, 1))); |
||||
group.setpText(roleGroupEntity.getGroupName()); |
||||
group.setParentNames(roleGroupEntity.getGroupName()); |
||||
group.setPrivilegeDetailBeanList(null); |
||||
group.setText(String.valueOf(dataModel.getValueAt(row, 2))); |
||||
return group; |
||||
} |
||||
|
||||
private static RoleGroupEntity getRoleGroupEntity(final String rootId) throws Exception { |
||||
return RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<RoleGroupEntity>() { |
||||
@Override |
||||
public RoleGroupEntity run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupDao.class).getById(rootId); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 通过自定义角色查询维度code列表 |
||||
* |
||||
* @param roleIds |
||||
* @param groupRootCode |
||||
* @return |
||||
*/ |
||||
public static HashSet<String> GetCodeList(final Set<String> roleIds, final String groupRootCode) throws Exception { |
||||
final QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.in(RoleGroupMiddleEntity.COLUMN_ROLE_ID, roleIds)); |
||||
if (StringKit.isNotEmpty(groupRootCode)) { |
||||
RoleGroupEntity roleGroupEntity = RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<RoleGroupEntity>() { |
||||
@Override |
||||
public RoleGroupEntity run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupDao.class).findOne( |
||||
QueryFactory.create().addRestriction(RestrictionFactory.eq(RoleGroupEntity.COLUMN_GROUP_CODE, groupRootCode)) |
||||
); |
||||
} |
||||
}); |
||||
if (roleGroupEntity != null) { |
||||
queryCondition.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_GROUP_ID, roleGroupEntity.getId())); |
||||
} |
||||
} |
||||
List<RoleGroupMiddleEntity> middleEntityList = RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<List<RoleGroupMiddleEntity>>() { |
||||
@Override |
||||
public List<RoleGroupMiddleEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupMiddleDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
HashSet<String> codeSet = new HashSet<String>(); |
||||
for (RoleGroupMiddleEntity entity : middleEntityList) { |
||||
codeSet.add(entity.getCode()); |
||||
} |
||||
return codeSet; |
||||
} |
||||
|
||||
/** |
||||
* 通过自定义角色查询指定维度的code列表 |
||||
* |
||||
* @param groupId |
||||
* @param roleId |
||||
* @return |
||||
*/ |
||||
public static List<GroupCode> getCodeListByRole(String groupId, String roleId) throws Exception { |
||||
Map<String, String> codeMap = getCodeMapByID(groupId); |
||||
final QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_GROUP_ID, groupId)) |
||||
.addRestriction(RestrictionFactory.eq(RoleGroupMiddleEntity.COLUMN_ROLE_ID, roleId)) |
||||
.addSort(RoleGroupMiddleEntity.COLUMN_CODE); |
||||
List<RoleGroupMiddleEntity> middleEntityList = RoleGroupDBAccess.getAccessor().runQueryAction(new DBAction<List<RoleGroupMiddleEntity>>() { |
||||
@Override |
||||
public List<RoleGroupMiddleEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(RoleGroupMiddleDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
List<GroupCode> codeList = new ArrayList<GroupCode>(); |
||||
for (RoleGroupMiddleEntity entity : middleEntityList) { |
||||
GroupCode groupCode = new GroupCode(); |
||||
groupCode.setId(entity.getId()); |
||||
groupCode.setGroupId(entity.getGroupId()); |
||||
groupCode.setGroupCode(entity.getCode()); |
||||
groupCode.setRoleId(entity.getRoleId()); |
||||
if (codeMap != null) { |
||||
groupCode.setCodeName(codeMap.get(entity.getCode())); |
||||
} |
||||
codeList.add(groupCode); |
||||
} |
||||
return codeList; |
||||
} |
||||
|
||||
/** |
||||
* 查询指定维度的code列表 |
||||
* |
||||
* @param groupId |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static Map<String, String> getCodeMapByID(final String groupId) throws Exception { |
||||
RoleGroupEntity roleGroupEntity = getRoleGroupEntity(groupId); |
||||
if (roleGroupEntity == null || StringKit.isEmpty(roleGroupEntity.getGroupCode()) |
||||
|| StringKit.isEmpty(roleGroupEntity.getConnection()) || StringKit.isEmpty(roleGroupEntity.getSql())) { |
||||
return null; |
||||
} |
||||
Connection connection = ConnectionKit.getConnection(roleGroupEntity.getConnection()); |
||||
if (connection == null) { |
||||
return null; |
||||
} |
||||
AbstractDBDataModel dataModel = DBTableData.createCacheableDBResultSet(connection, roleGroupEntity.getSql(), -1); |
||||
if (!ComparatorUtils.equals(dataModel.getColumnCount(), 3)) { |
||||
return null; |
||||
} |
||||
Map<String, String> result = new HashMap<String, String>(); |
||||
for (int row = 0; row < dataModel.getRowCount(); row++) { |
||||
result.put(String.valueOf(dataModel.getValueAt(row, 0)), |
||||
String.valueOf(dataModel.getValueAt(row, 2))); |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: DeleteRoleGroupHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/3 15:57 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈DeleteRoleGroupHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class DeleteRoleGroupHandler extends BaseHttpHandler { |
||||
public DeleteRoleGroupHandler() { |
||||
} |
||||
|
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.DELETE; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/od/roleGroup"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
final String id = WebUtils.getHTTPRequestParameter(request, "id"); |
||||
RoleGroupService.delete(id); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,67 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetCodesHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/26 21:28 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.bean.GroupCode; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <GetCodesHandler> |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetCodesHandler extends BaseHttpHandler { |
||||
public GetCodesHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/codes"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
String roleId = WebUtils.getHTTPRequestParameter(request, "roleId"); |
||||
List<GroupCode> groupCodeList = RoleGroupService.getCodeListByRole(groupId, roleId); |
||||
JSONArray data = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
if (!groupCodeList.isEmpty()) { |
||||
for (GroupCode groupCode : groupCodeList) { |
||||
data.put(groupCode.toJSONObject()); |
||||
} |
||||
} |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
result.put("data", data); |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,67 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetGroupsHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/11 11:58 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.bean.Group; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈GetGroupsHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetGroupsHandler extends BaseHttpHandler { |
||||
public GetGroupsHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/groups"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
String rootId = WebUtils.getHTTPRequestParameter(request, "rootId"); |
||||
String id = WebUtils.getHTTPRequestParameter(request, "id"); |
||||
List<Group> groupList = RoleGroupService.getCodeByID(rootId, id); |
||||
JSONArray data = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
if (groupList != null && !groupList.isEmpty()) { |
||||
for (Group group : groupList) { |
||||
data.put(group.toJSONObject()); |
||||
} |
||||
} |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
result.put("data", data); |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetRoleGroupHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/3 15:45 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.bean.RoleGroup; |
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈查询角色组信息〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetRoleGroupHandler extends BaseHttpHandler { |
||||
public GetRoleGroupHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/roleGroup"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
int startIdx = WebUtils.getHTTPRequestIntParameter(request, "startIdx", -1); |
||||
int count = WebUtils.getHTTPRequestIntParameter(request, "count", -1); |
||||
List<RoleGroupEntity> groupEntityList = RoleGroupService.getAllSortedByTimeStamp(); |
||||
JSONArray groupList = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
if (startIdx == -1 && count == -1) { |
||||
for (RoleGroupEntity roleGroupEntity : groupEntityList) { |
||||
groupList.put(roleGroupEntity.createBean(new RoleGroup()).toJSONObject()); |
||||
} |
||||
} else if (startIdx > -1 && count > -1) { |
||||
int length = Math.min(count + startIdx, groupEntityList.size()); |
||||
for (int i = startIdx; i < length; ++i) { |
||||
RoleGroupEntity roleGroupEntity = groupEntityList.get(i); |
||||
groupList.put(roleGroupEntity.createBean(new RoleGroup()).toJSONObject()); |
||||
} |
||||
} |
||||
result.put("total", groupEntityList.size()); |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
result.put("groupList", groupList); |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetRoleGroupRootHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/12 21:59 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.bean.RoleGroup; |
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈GetRoleGroupRootHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetRoleGroupRootHandler extends BaseHttpHandler { |
||||
public GetRoleGroupRootHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/roleGroup/root"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
List<RoleGroupEntity> groupEntityList = RoleGroupService.getAll(); |
||||
JSONArray groupList = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
for (RoleGroupEntity roleGroupEntity : groupEntityList) { |
||||
groupList.put(roleGroupEntity.createBean(new RoleGroup()).toJSONRootNode()); |
||||
} |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
result.put("data", groupList); |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: GetRolesHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/10 14:32 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.bean.user.RoleBean; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈通过GroupId查询自定义角色〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetRolesHandler extends BaseHttpHandler { |
||||
public GetRolesHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/roles"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
String groupCode = WebUtils.getHTTPRequestParameter(request, "groupCode"); |
||||
List<RoleBean> roleEntityList = RoleGroupService.getRolesByGroupId(groupId, groupCode); |
||||
JSONArray data = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
if (roleEntityList != null && PluginContexts.currentContext().isAvailable()) { |
||||
for (RoleBean roleBean : roleEntityList) { |
||||
JSONObject role = JSONObject.create(); |
||||
role.put("id", roleBean.getId()); |
||||
role.put("text", roleBean.getText()); |
||||
role.put("description", roleBean.getDescription()); |
||||
data.put(role); |
||||
} |
||||
} |
||||
result.put("data", data); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: SaveRoleGroupHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/3 16:06 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fr.decision.base.util.UUIDUtil; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.entity.RoleGroupEntity; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈SaveRoleGroupHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class SaveRoleGroupHandler extends BaseHttpHandler { |
||||
public SaveRoleGroupHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/roleGroup"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
JSONArray groupArr = new JSONArray(WebUtils.getHTTPRequestParameter(request, "groupArr")); |
||||
JSONArray groupIds = new JSONArray(); |
||||
|
||||
for (int i = 0; i < groupArr.length(); ++i) { |
||||
String groupId = groupArr.optJSONObject(i).optString("id"); |
||||
final boolean groupIdIsNotEmpty = StringUtils.isNotEmpty(groupId); |
||||
if (StringUtils.isEmpty(groupId)) { |
||||
groupId = UUIDUtil.generate(); |
||||
} |
||||
String groupCode = groupArr.optJSONObject(i).optString("groupCode"); |
||||
String groupName = groupArr.optJSONObject(i).optString("groupName"); |
||||
String connection = groupArr.optJSONObject(i).optString("connection"); |
||||
String sql = groupArr.optJSONObject(i).optString("sql"); |
||||
|
||||
List<RoleGroupEntity> groupList = RoleGroupService.getAll(); |
||||
if (groupList != null) { |
||||
for (RoleGroupEntity roleGroupEntity : groupList) { |
||||
if (ComparatorUtils.equals(roleGroupEntity.getGroupCode(), groupCode) && !groupIdIsNotEmpty) { |
||||
WebUtils.flushFailureMessageAutoClose(request, response, 11205018, "Group name is already existed"); |
||||
return; |
||||
} |
||||
if (groupIdIsNotEmpty && ComparatorUtils.equals(roleGroupEntity.getGroupCode(), groupCode) |
||||
&& !ComparatorUtils.equals(groupId, roleGroupEntity.getId())) { |
||||
WebUtils.flushFailureMessageAutoClose(request, response, 11205018, "Group name is already existed"); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
final RoleGroupEntity saveRoleGroup = (new RoleGroupEntity()).id(groupId) |
||||
.groupCode(groupCode) |
||||
.groupName(groupName) |
||||
.connection(connection) |
||||
.sql(sql) |
||||
.timeStamp(System.currentTimeMillis()); |
||||
RoleGroupService.save(saveRoleGroup); |
||||
groupIds.put(groupId); |
||||
} |
||||
|
||||
JSONObject result = JSONObject.create(); |
||||
result.put("errorCode", 0); |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
result.put("groupIds", groupIds); |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: SearchGroupsHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/12 11:33 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fanruan.api.util.CodeKit; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.idha.bean.Group; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈SearchGroupsHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class SearchGroupsHandler extends BaseHttpHandler { |
||||
public SearchGroupsHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/od/groups/search"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
String rootId = WebUtils.getHTTPRequestParameter(request, "rootId"); |
||||
String keyword = WebUtils.getHTTPRequestParameter(request, "keyword"); |
||||
int page = WebUtils.getHTTPRequestIntParameter(request, "page"); |
||||
int count = WebUtils.getHTTPRequestIntParameter(request, "count"); |
||||
List<Group> groupList = RoleGroupService.searchGroupCode(rootId, CodeKit.cjkDecode(keyword)); |
||||
JSONArray items = new JSONArray(); |
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
boolean hasNext = false; |
||||
if (groupList != null && !groupList.isEmpty() && PluginContexts.currentContext().isAvailable()) { |
||||
int startIndex = (page * count) - count; |
||||
int endIndex = page * count; |
||||
if (endIndex > groupList.size()) { |
||||
endIndex = groupList.size(); |
||||
} else { |
||||
hasNext = true; |
||||
} |
||||
for (int index = startIndex; index < endIndex; index++) { |
||||
items.put(groupList.get(index).toJSONObject()); |
||||
} |
||||
} |
||||
result.put("items", items); |
||||
result.put("hasNext", hasNext); |
||||
result.put("page", page); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
@ -0,0 +1,85 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: DeleteRoleGroupMiddleHandler |
||||
* Author: Louis |
||||
* Date: 2020/6/10 15:54 |
||||
*/ |
||||
package com.fr.plugin.idha.web.http; |
||||
|
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.idha.util.HttpUtils; |
||||
import com.fr.plugin.idha.web.RoleGroupService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.HashSet; |
||||
|
||||
/** |
||||
* 〈Function Description〉<br> |
||||
* 〈DeleteRoleGroupMiddleHandler〉 |
||||
* |
||||
* @author fr.open |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class UpdateRoleGroupMiddleHandler extends BaseHttpHandler { |
||||
public UpdateRoleGroupMiddleHandler() { |
||||
} |
||||
|
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/od/role"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
final String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
final String groupCode = WebUtils.getHTTPRequestParameter(request, "groupCode"); |
||||
final String param_addRoleIds = WebUtils.getHTTPRequestParameter(request, "addRoleIds"); |
||||
final String param_removeRoleIds = WebUtils.getHTTPRequestParameter(request, "removeRoleIds"); |
||||
|
||||
final String roleId = WebUtils.getHTTPRequestParameter(request, "roleId"); |
||||
final String param_addGroupCodes = WebUtils.getHTTPRequestParameter(request, "addGroupCodes"); |
||||
final String param_removeGroupCodes = WebUtils.getHTTPRequestParameter(request, "removeGroupCodes"); |
||||
// 选择角色添加和删除
|
||||
if (StringKit.isNotEmpty(groupId) && StringKit.isNotEmpty(groupCode) && StringKit.isNotEmpty(param_addRoleIds)) { |
||||
final JSONArray addRoleIds = new JSONArray(param_addRoleIds); |
||||
if (!addRoleIds.isEmpty()) { |
||||
RoleGroupService.saveMiddle(groupId, groupCode, new HashSet<String>(addRoleIds.getList())); |
||||
} |
||||
} |
||||
if (StringKit.isNotEmpty(groupId) && StringKit.isNotEmpty(groupCode) && StringKit.isNotEmpty(param_removeRoleIds)) { |
||||
final JSONArray removeRoleIds = new JSONArray(param_removeRoleIds); |
||||
if (!removeRoleIds.isEmpty()) { |
||||
RoleGroupService.deleteMiddle(groupId, groupCode, new HashSet<String>(removeRoleIds.getList())); |
||||
} |
||||
} |
||||
// 选择维度code添加和删除
|
||||
if (StringKit.isNotEmpty(groupId) && StringKit.isNotEmpty(roleId) && StringKit.isNotEmpty(param_addGroupCodes)) { |
||||
final JSONArray addGroupCodes = new JSONArray(param_addGroupCodes); |
||||
if (!addGroupCodes.isEmpty()) { |
||||
RoleGroupService.saveMiddleByCode(groupId, roleId, new HashSet<String>(addGroupCodes.getList())); |
||||
} |
||||
} |
||||
if (StringKit.isNotEmpty(groupId) && StringKit.isNotEmpty(roleId) && StringKit.isNotEmpty(param_removeGroupCodes)) { |
||||
final JSONArray removeGroupCodes = new JSONArray(param_removeGroupCodes); |
||||
if (!removeGroupCodes.isEmpty()) { |
||||
RoleGroupService.deleteMiddleByID(groupId, roleId, new HashSet<String>(removeGroupCodes.getList())); |
||||
} |
||||
} |
||||
|
||||
JSONObject result = HttpUtils.createSuccessResponseJSONObject(); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, result); |
||||
} |
||||
} |
After Width: | Height: | Size: 208 B |
@ -0,0 +1,43 @@
|
||||
Plugin-idha=Organizational Dimension Manager |
||||
Plugin-idha_Organizational_Dimension_Manager=Organizational Dimension Manager |
||||
##js groupmanagement |
||||
Plugin-idha_NetWork-Anomaly=Network exception, please check the network configuration |
||||
Plugin-idha_Role_Group=Role Group |
||||
Plugin-idha_Group_Code=Group Code |
||||
Plugin-idha_Group_Name=Group Name |
||||
Plugin-idha_Group_Connection=Connection |
||||
Plugin-idha_Group_Sql=SQL |
||||
Plugin-idha_Group_Code_Empty=Group Code Is Empty |
||||
Plugin-idha_Group_Name_Empty=Group Name Is Empty |
||||
Plugin-idha_Group_Connection_Empty=Connection Is Empty |
||||
Plugin-idha_Group_Sql_Empty=Sql Is Empty |
||||
Plugin-idha_New_Group=Create Role Group |
||||
Plugin-idha_Modify_Group=Modify Role Group |
||||
Plugin-idha_DeleteGroup_Confirm_Popup=Determine to delete the Role Group |
||||
Plugin-idha_Confirm=Confirm |
||||
Plugin-idha_Cancel=Cancel |
||||
Plugin-idha_Not_Null=Not allowed to be empty |
||||
##js group_role |
||||
Plugin-idha_Group=Group |
||||
Plugin-idha_Group_Code_List=Group Code List |
||||
Plugin-idha_Edit_Group_Role=Edit Role |
||||
Plugin-idha_Role_Root_No_Add=Role Root No Add |
||||
Plugin-idha_Group_No_Auth_Tip=Role No Auth Tip |
||||
Plugin-idha_Please_Choose_Group=Please Choose Group |
||||
Plugin-idha_Search_Or_Add_Role=Search Or Add Role |
||||
Plugin-idha_Select_Role=Select Role |
||||
Plugin-idha_Group_No_Role_Need_Add_Tip=Group No Role, Need Add |
||||
Plugin-idha_User_Select_Group_To_View=Select Group To View |
||||
Plugin-idha_Confirm_Delete_Role=Confirm Delete Role? |
||||
Plugin-idha_User_Belong_To_Role_Tip=User Belong To Role\uFF1F |
||||
Plugin-idha_Group_Name_Can_Not_Null=Group Name Can Not Null |
||||
## js all_role |
||||
Plugin-idha_All_Role_List=All Role List |
||||
Plugin-idha_Join_Group_Code_List=Join Group Code List |
||||
Plugin-idha_Edit_Group_Code=Edit Code |
||||
Plugin-idha_Please_Choose_Role=Please Choose Role |
||||
Plugin-idha_Role_No_Code_Need_Add_Tip=Role No Code, Need Add |
||||
Plugin-idha_User_Select_Role_To_View=Select Role To View |
||||
Plugin-idha_Select_Group_Code=\u9009\u62E9\u7EF4\u5EA6Code |
||||
Plugin-idha_Search_Or_Add_Code=Search Or Add Code |
||||
Plugin-idha_Confirm_Delete_Code=Confirm Delete Code? |
@ -0,0 +1,43 @@
|
||||
Plugin-idha=\u7EC4\u7EC7\u7EF4\u5EA6\u7BA1\u7406 |
||||
Plugin-idha_Organizational_Dimension_Manager=\u7EC4\u7EC7\u7EF4\u5EA6\u7BA1\u7406 |
||||
##js groupmanager |
||||
Plugin-idha_NetWork-Anomaly=\u7F51\u7EDC\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u914D\u7F6E |
||||
Plugin-idha_Role_Group=\u7EC4\u7EC7\u7EF4\u5EA6 |
||||
Plugin-idha_Group_Code=\u7EF4\u5EA6\u7F16\u7801 |
||||
Plugin-idha_Group_Name=\u7EF4\u5EA6\u540D\u79F0 |
||||
Plugin-idha_Group_Connection=\u6570\u636E\u6E90\u8FDE\u63A5 |
||||
Plugin-idha_Group_Sql=SQL\u8BED\u53E5 |
||||
Plugin-idha_Group_Code_Empty=\u7EF4\u5EA6\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-idha_Group_Name_Empty=\u7EF4\u5EA6\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-idha_Group_Connection_Empty=\u6570\u636E\u6E90\u94FE\u63A5\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-idha_Group_Sql_Empty=SQL\u8BED\u53E5\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-idha_New_Group=\u65B0\u5EFA\u7EC4\u7EC7\u7EF4\u5EA6 |
||||
Plugin-idha_Modify_Group=\u4FEE\u6539\u7EC4\u7EC7\u7EF4\u5EA6 |
||||
Plugin-idha_DeleteGroup_Confirm_Popup=\u786E\u5B9A\u5220\u9664\u6B64\u7EC4\u7EC7\u7EF4\u5EA6 |
||||
Plugin-idha_Confirm=\u786E\u5B9A |
||||
Plugin-idha_Cancel=\u53D6\u6D88 |
||||
Plugin-idha_Not_Null=\u4E0D\u5141\u8BB8\u4E3A\u7A7A |
||||
##js group_role |
||||
Plugin-idha_Group=\u7EF4\u5EA6 |
||||
Plugin-idha_Group_Code_List=Code\u5217\u8868 |
||||
Plugin-idha_Edit_Group_Role=\u7F16\u8F91\u89D2\u8272 |
||||
Plugin-idha_Role_Root_No_Add=\u4E0D\u80FD\u4E3A\u6839\u8282\u70B9\u6DFB\u52A0\u89D2\u8272 |
||||
Plugin-idha_Group_No_Auth_Tip=\u60A8\u6CA1\u6709\u8BE5\u7EF4\u5EA6\u8282\u70B9\u7684\u6743\u9650,\u5982\u6709\u7591\u95EE\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 |
||||
Plugin-idha_Please_Choose_Group=\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u7EF4\u5EA6 |
||||
Plugin-idha_Search_Or_Add_Role=\u641C\u7D22\u6216\u9009\u62E9\u89D2\u8272 |
||||
Plugin-idha_Select_Role=\u9009\u62E9\u89D2\u8272 |
||||
Plugin-idha_Group_No_Role_Need_Add_Tip=\u6682\u65E0\u89D2\u8272,\u70B9\u51FB\u9009\u62E9\u89D2\u8272\u8FDB\u884C\u6DFB\u52A0 |
||||
Plugin-idha_User_Select_Group_To_View=\u8BF7\u9009\u62E9\u7EF4\u5EA6\u8FDB\u884C\u67E5\u770B |
||||
Plugin-idha_Confirm_Delete_Role=\u786E\u8BA4\u5220\u9664\u8BE5\u89D2\u8272? |
||||
Plugin-idha_User_Belong_To_Role_Tip=\u60A8\u5C5E\u4E8E\u8BE5\u804C\u52A1\uFF0C\u5220\u9664\u8BE5\u804C\u52A1\u53EF\u80FD\u5BF9\u60A8\u7684\u6743\u9650\u4EA7\u751F\u5F71\u54CD\uFF0C\u786E\u5B9A\u5220\u9664\uFF1F |
||||
Plugin-idha_Group_Name_Can_Not_Null=\u7EF4\u5EA6\u540D\u4E0D\u80FD\u4E3A\u7A7A |
||||
## js all_role |
||||
Plugin-idha_All_Role_List=\u5168\u90E8\u89D2\u8272\u5217\u8868 |
||||
Plugin-idha_Join_Group_Code_List=\u5173\u8054Code\u5217\u8868 |
||||
Plugin-idha_Edit_Group_Code=\u7F16\u8F91Code |
||||
Plugin-idha_Please_Choose_Role=\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u89D2\u8272 |
||||
Plugin-idha_Role_No_Code_Need_Add_Tip=\u6682\u65E0Code,\u70B9\u51FB\u9009\u62E9code\u8FDB\u884C\u6DFB\u52A0 |
||||
Plugin-idha_User_Select_Role_To_View=\u8BF7\u9009\u62E9\u89D2\u8272\u8FDB\u884C\u67E5\u770B |
||||
Plugin-idha_Select_Group_Code=\u9009\u62E9\u7EF4\u5EA6Code |
||||
Plugin-idha_Search_Or_Add_Code=\u641C\u7D22\u6216\u9009\u62E9Code |
||||
Plugin-idha_Confirm_Delete_Code=\u786E\u8BA4\u5220\u9664\u8BE5Code? |
@ -0,0 +1,2 @@
|
||||
/* simple-template 20-06-17 13:47:33 */ |
||||
.roleGroup-container{font-family:PingFangSC-Regular,serif;font-size:12px;color:#3D4D66}.roleGroup-container .bi-combo .bi-editor-trigger,.roleGroup-container .bi-editor{border-radius:2px}.roleGroup-gray-color{color:#9EA6B2}.roleGroup-table-header{background:#EAF2FD}.odd{background:#FFF}.even{background:#FBFDFF}.roleGroup-tab-title{background:#FFF}.roleGroup-tab-content{background:#F7F8FA}.roleGroup-section-container{background:#FFF}.page-button{border:1px solid #E8EAED;border-radius:2px}.roleGroup-no-border{border:0}.roleGroup-border-box{box-sizing:border-box}.roleGroup-title{font-family:PingFangSC-Medium;color:#3D4D66} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue