diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java b/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java index 41eb051e3..7da674bf8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java @@ -40,6 +40,7 @@ public class ManagerInfo { private boolean orgmanager; @JSONField(name = "org_id") private Integer orgId; + private Integer parent_org_id; public JSONObject accountJson(boolean insert) { JSONObject account = new JSONObject(); @@ -110,6 +111,7 @@ public class ManagerInfo { account.put("username", getUsername()); } account.put("org_id", orgId); + account.put("parent_org_id",parent_org_id); return account; } @@ -272,4 +274,12 @@ public class ManagerInfo { public void setOrgmanager(boolean orgmanager) { this.orgmanager = orgmanager; } + + public Integer getParent_org_id() { + return parent_org_id; + } + + public void setParent_org_id(Integer parent_org_id) { + this.parent_org_id = parent_org_id; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java index ef33d3ec1..99bb93a41 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java @@ -9,7 +9,7 @@ import java.util.List; * Created by yixian on 2016-07-05. */ public interface ManagerAccountsService { - List listManagers(JSONObject loginManager); + List listManagers(JSONObject loginManager,JSONObject params); void saveManager(ManagerInfo manager, JSONObject loginManager); diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java index 860b292a5..b90b53a27 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java @@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.signin.core.impls; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.mappers.system.OrgMapper; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.signin.beans.ManagerInfo; import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService; @@ -30,12 +31,15 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Resource private FinancialBDConfigMapper financialBDConfigMapper; + @Resource + private OrgManager orgManager; + @Override - public List listManagers(JSONObject loginManager) { - JSONObject params = new JSONObject(); - if (loginManager.getInteger("org_id") != null) { + public List listManagers(JSONObject loginManager,JSONObject params) { + /* if (loginManager.getInteger("org_id") != null) { params.put("org_id", loginManager.getIntValue("org_id")); - } + }*/ + orgManager.checkOrgIds(loginManager,params); List managers = managerMapper.listAvailable(params, new PageBounds(Order.formString("create_time.desc"))); for (JSONObject manager : managers) { int role = manager.getIntValue("role"); @@ -90,7 +94,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { if (manager.isAdmin() || manager.isFinacial() || manager.isOperator() || manager.isServant() || manager.isSitemanager() || manager.isDeveloper()) { throw new BadRequestException("Invalid Role"); } - obj.remove("org_id"); + //obj.remove("org_id"); } obj.put("manager_id", userId); managerMapper.update(obj); diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java index 06c607702..e1f3652cd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java @@ -10,6 +10,7 @@ import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.http.HttpUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; @@ -37,9 +38,15 @@ public class ManagerAccountsController { @RequestMapping(method = RequestMethod.GET) @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) - public List listManagerss(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestParam Map map) { - loginManager.putAll(map); - return managerAccountsService.listManagers(loginManager); + public List listManagerss(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestParam(required = false) String org_id,@RequestParam(required = false) String org_id2) { + JSONObject params = new JSONObject(); + if(org_id != null){ + params.put("org_id",org_id); + } + if (StringUtils.isNotEmpty(org_id2)) { + params.put("org_id2", org_id2); + } + return managerAccountsService.listManagers(loginManager,params); } @RequestMapping(method = RequestMethod.POST) diff --git a/src/main/ui/static/config/managers/manager.js b/src/main/ui/static/config/managers/manager.js index 205ccdfdd..37a766f95 100644 --- a/src/main/ui/static/config/managers/manager.js +++ b/src/main/ui/static/config/managers/manager.js @@ -15,7 +15,8 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.search = {role:'111111111111'}; $scope.params = {}; $scope.listManagers = function () { - $http.get('/sys/manager_accounts').then(function (resp) { + var params = angular.copy($scope.params); + $http.get('/sys/manager_accounts',{params: params}).then(function (resp) { $scope.managers = resp.data; }) }; @@ -35,8 +36,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) }; - - $scope.listManagers(); $scope.modifyManager = function (manager) { $uibModal.open({ @@ -83,7 +82,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadOrgs(); $scope.loadOrgsChild= function (org_id) { - $scope.is_org2 = 'not_is'; $scope.choose_org = org_id; var params = angular.copy($scope.params); params.org_id = org_id; @@ -91,15 +89,19 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.orgs_child = resp.data; }) }; - - if(!$scope.manager.parent_org_id){ - $scope.is_org2 = 'not_is' - }else { + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + var params = angular.copy($scope.params); + params.org_id = $scope.currentUser.org_id; + $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { + $scope.orgs_child = resp.data; + }) + $scope.manager.org_id2 = $scope.manager.org_id; + } + if($scope.manager.parent_org_id){ $scope.manager.org_id2 = $scope.manager.org_id; $scope.manager.org_id = $scope.manager.parent_org_id; $scope.loadOrgsChild($scope.manager.org_id); - $scope.is_org2 = 'is'; - }; + } $scope.modify = function () { $scope.errmsg = null; if($scope.manager.password && $scope.manager.password.length < 8){ @@ -121,20 +123,16 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) }; - - - $scope.changeIsOrg2 = function (choose_org2) { - if($scope.choose_org != choose_org2){ - $scope.is_org2 = 'is'; - }else { - $scope.is_org2 = 'not_is' - } - - } }]); app.controller('newManagerDialogCtrl', ['$scope', '$http', function ($scope, $http) { $scope.params = {}; - $scope.is_org2 = 'not_is'; + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + var params = angular.copy($scope.params); + params.org_id = $scope.currentUser.org_id; + $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { + $scope.orgs_child = resp.data; + }) + } $scope.save = function (form) { $scope.errmsg = null; if (form.$invalid) { @@ -154,6 +152,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { // $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !'; // return; // } + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + $scope.manager.bd = true; + } if($scope.manager.org_id2 != "null") { $scope.manager.org_id = $scope.manager.org_id2; } @@ -172,7 +173,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadOrgs(); $scope.loadOrgsChild= function (org_id) { - $scope.is_org2 = 'not_is'; $scope.choose_org = org_id; var params = angular.copy($scope.params); params.org_id = org_id; @@ -180,14 +180,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.orgs_child = resp.data; }) }; - $scope.changeIsOrg2 = function (choose_org2) { - if($scope.choose_org != choose_org2){ - $scope.is_org2 = 'is'; - }else { - $scope.is_org2 = 'not_is' - } - - } }]); app.filter('managersFilter', [function () { return function (arr, filterObj) { diff --git a/src/main/ui/static/config/managers/templates/managers.html b/src/main/ui/static/config/managers/templates/managers.html index 95fc39ab0..c3adbbae0 100644 --- a/src/main/ui/static/config/managers/templates/managers.html +++ b/src/main/ui/static/config/managers/templates/managers.html @@ -17,7 +17,7 @@ -
+
-
- + ng-change="params.org_id2 = '';listManagers();loadOrgsChild(params.org_id)">
-
-
diff --git a/src/main/ui/static/config/managers/templates/modify.html b/src/main/ui/static/config/managers/templates/modify.html index a228b940c..93678996f 100644 --- a/src/main/ui/static/config/managers/templates/modify.html +++ b/src/main/ui/static/config/managers/templates/modify.html @@ -45,7 +45,7 @@
-
+

-
- -

- -

-
+ ng-options="org.org_id as org.name group by org.org_type for org in orgs_child">
diff --git a/src/main/ui/static/config/managers/templates/new_manager.html b/src/main/ui/static/config/managers/templates/new_manager.html index 5a4423dcd..d42e8ec9d 100644 --- a/src/main/ui/static/config/managers/templates/new_manager.html +++ b/src/main/ui/static/config/managers/templates/new_manager.html @@ -51,7 +51,7 @@
-
+

- -
+

+

@@ -114,11 +116,10 @@
-
+
diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js index 7a2973e40..8ddc741c4 100644 --- a/src/main/ui/static/config/organizations/organizations.js +++ b/src/main/ui/static/config/organizations/organizations.js @@ -336,7 +336,40 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { app.controller('modifyManagerCtrl', ['$scope', '$http', 'manager', function ($scope, $http, manager) { $scope.manager = manager; + $scope.params = {}; + $scope.loadOrgs = function () { + $http.get('/sys/orgs').then(function (resp) { + $scope.orgs = resp.data; + }) + }; + $scope.loadOrgs(); + + $scope.loadOrgsChild= function (org_id) { + $scope.choose_org = org_id; + var params = angular.copy($scope.params); + params.org_id = org_id; + $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { + $scope.orgs_child = resp.data; + }) + }; + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + $scope.loadOrgsChild($scope.currentUser.org_id); + } + if($scope.manager.parent_org_id){ + $scope.manager.org_id2 = $scope.manager.org_id; + $scope.manager.org_id = $scope.manager.parent_org_id; + $scope.loadOrgsChild($scope.manager.org_id); + }; $scope.modify = function () { + /*if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + if($scope.manager.org_id2 != "null") { + $scope.manager.parent_org_id = $scope.manager.org_id2; + } + delete $scope.manager.org_id2; + }*/ + if($scope.manager.org_id2 != null && $scope.manager.org_id2 != 'null') { + $scope.manager.org_id = $scope.manager.org_id2; + } $scope.errmsg = null; $http.put('/sys/manager_accounts/' + manager.manager_id, $scope.manager).then(function () { $scope.$close(); @@ -352,7 +385,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadOrgs(); }]); app.controller('newManagerCtrl', ['$scope', '$http','org',function ($scope, $http,org) { - + $scope.isOrg = true; $scope.save = function (form) { $scope.manager.org_id = org.org_id; $scope.errmsg = null; @@ -364,9 +397,13 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } - if(currentUser.org_id != null && !currentUser.parent_org_id){ - $scope.manager.bd=true; + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + $scope.manager.bd = true; + } + if($scope.manager.org_id2 != "null") { + $scope.manager.org_id = $scope.manager.org_id2; } + delete $scope.manager.org_id2; $http.post('/sys/manager_accounts', $scope.manager).then(function () { $scope.$close();