From 8ae8685487560b1351ca41ee5c0de090efa9066b Mon Sep 17 00:00:00 2001 From: luoyang Date: Fri, 26 Oct 2018 14:33:44 +0800 Subject: [PATCH] add permission function set role --- .../management/sysconfig/beans/FuncInfo.java | 192 ++++++++++++++++++ .../core/impls/PermissionManagerImpl.java | 21 +- .../templates/analysis_monitoring.html | 2 +- .../sysconfigs/templates/func_info_edit.html | 48 +++++ .../templates/permission_functions.html | 34 ++++ src/main/ui/static/risk/risk.js | 2 +- 6 files changed, 294 insertions(+), 5 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/FuncInfo.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/FuncInfo.java index 29c221991..63d881c92 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/FuncInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/FuncInfo.java @@ -1,5 +1,7 @@ package au.com.royalpay.payment.manage.management.sysconfig.beans; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; /** @@ -8,6 +10,21 @@ import org.apache.commons.lang3.StringUtils; public class FuncInfo { private String name; private String remark; + private boolean admin; + private boolean operator; + private boolean bd; + private boolean finacial; + private boolean servant; + private boolean accountmanager; + private boolean director; + private boolean sitemanager; + private boolean developer; + private boolean bdleader; + private boolean riskmanager; + private boolean guest; + private boolean orgmanager; + private boolean salesmanager; + private boolean datacontent; public String getName() { return StringUtils.isEmpty(name) ? null : name; @@ -24,4 +41,179 @@ public class FuncInfo { public void setRemark(String remark) { this.remark = remark; } + + public void setSalesmanager(boolean salesmanager) { + this.salesmanager = salesmanager; + } + + public boolean isAdmin() { + return admin; + } + + public boolean isBd() { + return bd; + } + + public boolean isFinacial() { + return finacial; + } + + public boolean isAccountmanager() { + return accountmanager; + } + + public boolean isOperator() { + return operator; + } + + public boolean isDeveloper() { + return developer; + } + + public boolean isDirector() { + return director; + } + + public boolean isServant() { + return servant; + } + + public void setAccountmanager(boolean accountmanager) { + this.accountmanager = accountmanager; + } + + public boolean isBdleader() { + return bdleader; + } + + public boolean isSitemanager() { + return sitemanager; + } + + public void setAdmin(boolean admin) { + this.admin = admin; + } + + public void setBd(boolean bd) { + this.bd = bd; + } + + public boolean isGuest() { + return guest; + } + + public void setDeveloper(boolean developer) { + this.developer = developer; + } + + public boolean isRiskmanager() { + return riskmanager; + } + + public void setDirector(boolean director) { + this.director = director; + } + + public void setBdleader(boolean bdleader) { + this.bdleader = bdleader; + } + + public void setFinacial(boolean finacial) { + this.finacial = finacial; + } + + public void setOperator(boolean operator) { + this.operator = operator; + } + + public void setServant(boolean servant) { + this.servant = servant; + } + + public void setGuest(boolean guest) { + this.guest = guest; + } + + public void setRiskmanager(boolean riskmanager) { + this.riskmanager = riskmanager; + } + + public void setSitemanager(boolean sitemanager) { + this.sitemanager = sitemanager; + } + + public void setDatacontent(boolean datacontent) { + this.datacontent = datacontent; + } + + public boolean isSalesmanager() { + return salesmanager; + } + + public boolean isOrgmanager() { + return orgmanager; + } + + public boolean isDatacontent() { + return datacontent; + } + + public void setOrgmanager(boolean orgmanager) { + this.orgmanager = orgmanager; + } + + + public JSONObject initObject(JSONObject mod) { + mod.put("name", getName()); + mod.put("remark", getRemark()); + int role = 0; + if (admin) { + role |= ManagerRole.ADMIN.getMask(); + } + if (operator) { + role |= ManagerRole.OPERATOR.getMask(); + } + if (sitemanager) { + role |= ManagerRole.SITE_MANAGER.getMask(); + } + if (bd) { + role |= ManagerRole.BD_USER.getMask(); + } + if (finacial) { + role |= ManagerRole.FINANCIAL_STAFF.getMask(); + } + if (servant) { + role |= ManagerRole.SERVANT.getMask(); + } + if (accountmanager) { + role |= ManagerRole.ACCOUNT_MANAGER.getMask(); + } + if (director) { + role |= ManagerRole.DIRECTOR.getMask(); + } + if (developer) { + role |= ManagerRole.DEVELOPER.getMask(); + } + if (bdleader){ + role |= ManagerRole.BD_LEADER.getMask(); + } + if (riskmanager){ + role |= ManagerRole.RISK_MANAGER.getMask(); + } + if (guest){ + role |= ManagerRole.GUEST.getMask(); + } + if (orgmanager){ + role |= ManagerRole.ORG_MANAGER.getMask(); + } + if (salesmanager) { + role |= ManagerRole.SALES_MANAGER.getMask(); + } + if (datacontent) { + role |= ManagerRole.DATA_CONTENT.getMask(); + } + mod.put("role", role); + return mod; + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionManagerImpl.java index 2b2710c5d..821f9f5e9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionManagerImpl.java @@ -68,6 +68,23 @@ public class PermissionManagerImpl implements PermissionManager { Map> moduleMap = new TreeMap<>(); List noModule = new ArrayList<>(); for (JSONObject func : funcs) { + int role = func.getIntValue("role"); + func.put("admin", ManagerRole.ADMIN.hasRole(role)); + func.put("operator", ManagerRole.OPERATOR.hasRole(role)); + func.put("bd", ManagerRole.BD_USER.hasRole(role)); + func.put("finacial", ManagerRole.FINANCIAL_STAFF.hasRole(role)); + func.put("servant", ManagerRole.SERVANT.hasRole(role)); +// func.put("accountmanager", ManagerRole.ACCOUNT_MANAGER.hasRole(role)); + func.put("director", ManagerRole.DIRECTOR.hasRole(role)); + func.put("sitemanager", ManagerRole.SITE_MANAGER.hasRole(role)); + func.put("developer", ManagerRole.DEVELOPER.hasRole(role)); + func.put("bdleader", ManagerRole.BD_LEADER.hasRole(role)); + func.put("riskmanager", ManagerRole.RISK_MANAGER.hasRole(role)); + func.put("guest", ManagerRole.GUEST.hasRole(role)); +// manager.put("orgmanager", ManagerRole.ORG_MANAGER.hasRole(role)); + func.put("salesmanager", ManagerRole.SALES_MANAGER.hasRole(role)); +// manager.put("datacontent", ManagerRole.DATA_CONTENT.hasRole(role)); + String module = func.getString("module"); if (module == null) { noModule.add(func); @@ -128,9 +145,7 @@ public class PermissionManagerImpl implements PermissionManager { public void updateFuncInfo(String funcId, FuncInfo funcInfo) { JSONObject update = new JSONObject(); update.put("func_id", funcId); - update.put("name", funcInfo.getName()); - update.put("remark", funcInfo.getRemark()); - permissionFunctionMapper.update(update); + permissionFunctionMapper.update(funcInfo.initObject(update)); } @Override diff --git a/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html b/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html index ebc28f9e6..e80d3b8e7 100644 --- a/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html +++ b/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html @@ -20,7 +20,7 @@
  • 欠款|Pre Refund
  • -
  • +
  • 风控记录|Risk Records
  • diff --git a/src/main/ui/static/config/sysconfigs/templates/func_info_edit.html b/src/main/ui/static/config/sysconfigs/templates/func_info_edit.html index 3e2bed66a..b3b76de42 100644 --- a/src/main/ui/static/config/sysconfigs/templates/func_info_edit.html +++ b/src/main/ui/static/config/sysconfigs/templates/func_info_edit.html @@ -13,6 +13,54 @@ +
    + +

    + + + + + + + + + + + + + + + + +

    +
    +