add permission function set role

master
luoyang 6 years ago
parent 408e5d9a30
commit 8ae8685487

@ -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;
}
}

@ -68,6 +68,23 @@ public class PermissionManagerImpl implements PermissionManager {
Map<String, List<JSONObject>> moduleMap = new TreeMap<>();
List<JSONObject> 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

@ -20,7 +20,7 @@
<li ui-sref-active-eq="active" ng-if="('monitor'|withModule)&&(currentUser.org_id==null)">
<a ui-sref="analysis_monitoring.pre_refund"><i class="fa fa-tv"></i> <span>欠款|Pre Refund</span></a>
</li>
<li ui-sref-active-eq="active" ng-if="('RiskManagement'|withModule)&&(currentUser.org_id==null)">
<li ui-sref-active-eq="active" ng-if="('riskManagement'|withModule)&&(currentUser.org_id==null)">
<a ui-sref="analysis_monitoring.risk_manager"><i class="fa fa-tv"></i> <span>风控记录|Risk Records</span></a>
</li>

@ -13,6 +13,54 @@
<label class="control-label" for="remark-input">Remark</label>
<input class="form-control" id="remark-input" ng-model="func.remark">
</div>
<div class="form-group">
<label class="control-label">Roles</label>
<p class="checkbox-inline checkbox">
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.admin" name="admin">Administrator
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.operator" name="operator">Compliance
</label>
<label>
<input type="checkbox" ng-model="func.bd" name="bd">BD User
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.finacial" name="finacial">Accountant
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.servant" name="servant">Service
</label>
<!--<label ng-if="!manager.admin && !manager.operator">-->
<!--<input type="checkbox" ng-model="manager.accountmanager" name="accountmanager">Account Manager-->
<!--</label>-->
<label>
<input type="checkbox" ng-model="func.director" name="director">Director
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.sitemanager" name="sitemanager">Markting
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.developer" name="developer">Developer
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.bdleader" name="bdleader">BD Leader
</label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.riskmanager" name="riskmanager">Risk Manager
</label>
<!-- <label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="manager.orgmanager" name="orgmanager">Org Manager
</label>-->
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="func.salesmanager" name="salesmanager">Sales Manager
</label>
<!-- <label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="manager.datacontent" name="datacontent">Data Content
</label>-->
</p>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-click="modifyFunction()">Save</button>

@ -15,6 +15,23 @@
<th ng-bind="func.func_id" title="{{func.remark}}"></th>
<td ng-bind="func.uri+'['+func.req_methods+']'" title="{{func.remark}}"></td>
<td ng-bind="func.name"></td>
<td>
<i class="fa fa-user-secret" title="Administrator" ng-class="{'text-green':func.admin,'text-gray':!func.admin}"></i>
<i class="fa fa-eye" title="Compliance" ng-class="{'text-green':func.operator,'text-gray':!func.operator}"></i>
<i class="fa fa-crosshairs" title="BD User" ng-class="{'text-green':func.bd,'text-gray':!func.bd}"></i>
<i class="fa fa-balance-scale" title="Accountant" ng-class="{'text-green':func.finacial,'text-gray':!func.finacial}"></i>
<i class="fa fa-tty" title="Service" ng-class="{'text-green':func.sevant,'text-gray':!func.servant}"></i>
<!--<i class="fa fa-university" title="Account Manager" ng-class="{'text-green':func.accountmanager,'text-gray':!func.accountmanager}"></i>-->
<i class="fa fa-line-chart" title="Director" ng-class="{'text-green':func.director,'text-gray':!func.director}"></i>
<i class="fa fa-map-o" title="Markting" ng-class="{'text-green':func.sitemanager,'text-gray':!func.sitemanager}"></i>
<i class="fa fa-code" title="Developer" ng-class="{'text-green':func.developer,'text-gray':!func.developer}"></i>
<i class="fa fa-male" title="BD Leader" ng-class="{'text-green':func.bdleader,'text-gray':!func.bdleader}"></i>
<i class="fa fa-user" title="Risk Manager" ng-class="{'text-green':func.riskmanager,'text-gray':!func.riskmanager}"></i>
<i class="fa fa-tripadvisor" title="GUEST" ng-class="{'text-green':func.guest,'text-gray':!func.guest}"></i>
<!--<i class="fa fa-user-plus" title="Org Manager" ng-class="{'text-green':func.orgmanager,'text-gray':!func.orgmanager}"></i>-->
<i class="fa fa-ticket" title="Sales Manager" ng-class="{'text-green':func.salesmanager,'text-gray':!func.salesmanager}"></i>
<!--<i class="fa fa-save" title="Data Content" ng-class="{'text-green':func.datacontent,'text-gray':!func.datacontent}"></i>-->
</td>
<td>
<a role="button" ng-click="moveFunction(func)" title="Move"><i class="fa fa-arrows"></i></a>
<a role="button" ng-click="editFunctionInfo(func)" title="Edit"><i class="fa fa-edit"></i></a>
@ -32,6 +49,23 @@
<th ng-bind="func.func_id+(func.remark?'('+func.remark+')':'')" title="{{func.remark}}"></th>
<td ng-bind="func.uri+'['+func.req_methods+']'" title="{{func.remark}}"></td>
<td ng-bind="func.name"></td>
<td>
<i class="fa fa-user-secret" title="Administrator" ng-class="{'text-green':func.admin,'text-gray':!func.admin}"></i>
<i class="fa fa-eye" title="Compliance" ng-class="{'text-green':func.operator,'text-gray':!func.operator}"></i>
<i class="fa fa-crosshairs" title="BD User" ng-class="{'text-green':func.bd,'text-gray':!func.bd}"></i>
<i class="fa fa-balance-scale" title="Accountant" ng-class="{'text-green':func.finacial,'text-gray':!func.finacial}"></i>
<i class="fa fa-tty" title="Service" ng-class="{'text-green':func.sevant,'text-gray':!func.servant}"></i>
<!--<i class="fa fa-university" title="Account Manager" ng-class="{'text-green':func.accountmanager,'text-gray':!func.accountmanager}"></i>-->
<i class="fa fa-line-chart" title="Director" ng-class="{'text-green':func.director,'text-gray':!func.director}"></i>
<i class="fa fa-map-o" title="Markting" ng-class="{'text-green':func.sitemanager,'text-gray':!func.sitemanager}"></i>
<i class="fa fa-code" title="Developer" ng-class="{'text-green':func.developer,'text-gray':!func.developer}"></i>
<i class="fa fa-male" title="BD Leader" ng-class="{'text-green':func.bdleader,'text-gray':!func.bdleader}"></i>
<i class="fa fa-user" title="Risk Manager" ng-class="{'text-green':func.riskmanager,'text-gray':!func.riskmanager}"></i>
<i class="fa fa-tripadvisor" title="GUEST" ng-class="{'text-green':func.guest,'text-gray':!func.guest}"></i>
<!--<i class="fa fa-user-plus" title="Org Manager" ng-class="{'text-green':func.orgmanager,'text-gray':!func.orgmanager}"></i>-->
<i class="fa fa-ticket" title="Sales Manager" ng-class="{'text-green':func.salesmanager,'text-gray':!func.salesmanager}"></i>
<!--<i class="fa fa-save" title="Data Content" ng-class="{'text-green':func.datacontent,'text-gray':!func.datacontent}"></i>-->
</td>
<td>
<a role="button" ng-click="moveFunction(func)" title="Move"><i class="fa fa-arrows"></i></a>
<a role="button" ng-click="editFunctionInfo(func)" title="Edit"><i class="fa fa-edit"></i></a>

@ -6,7 +6,7 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
{code: '2', label: 'test2'},
];
var app = angular.module('RiskManagement', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload']);
var app = angular.module('riskManagement', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('analysis_monitoring.risk_manager', {
url: '/risk/manage',

Loading…
Cancel
Save