fix 账号组织bug

master
yuan 7 years ago
parent c228696136
commit e968c49c2b

@ -40,6 +40,7 @@ public class ManagerInfo {
private boolean orgmanager; private boolean orgmanager;
@JSONField(name = "org_id") @JSONField(name = "org_id")
private Integer orgId; private Integer orgId;
private Integer parent_org_id;
public JSONObject accountJson(boolean insert) { public JSONObject accountJson(boolean insert) {
JSONObject account = new JSONObject(); JSONObject account = new JSONObject();
@ -110,6 +111,7 @@ public class ManagerInfo {
account.put("username", getUsername()); account.put("username", getUsername());
} }
account.put("org_id", orgId); account.put("org_id", orgId);
account.put("parent_org_id",parent_org_id);
return account; return account;
} }
@ -272,4 +274,12 @@ public class ManagerInfo {
public void setOrgmanager(boolean orgmanager) { public void setOrgmanager(boolean orgmanager) {
this.orgmanager = 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;
}
} }

@ -9,7 +9,7 @@ import java.util.List;
* Created by yixian on 2016-07-05. * Created by yixian on 2016-07-05.
*/ */
public interface ManagerAccountsService { public interface ManagerAccountsService {
List<JSONObject> listManagers(JSONObject loginManager); List<JSONObject> listManagers(JSONObject loginManager,JSONObject params);
void saveManager(ManagerInfo manager, JSONObject loginManager); void saveManager(ManagerInfo manager, JSONObject loginManager);

@ -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.financial.FinancialBDConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper; 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.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.signin.beans.ManagerInfo; import au.com.royalpay.payment.manage.signin.beans.ManagerInfo;
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService; import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
@ -30,12 +31,15 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
@Resource @Resource
private FinancialBDConfigMapper financialBDConfigMapper; private FinancialBDConfigMapper financialBDConfigMapper;
@Resource
private OrgManager orgManager;
@Override @Override
public List<JSONObject> listManagers(JSONObject loginManager) { public List<JSONObject> listManagers(JSONObject loginManager,JSONObject params) {
JSONObject params = new JSONObject(); /* if (loginManager.getInteger("org_id") != null) {
if (loginManager.getInteger("org_id") != null) {
params.put("org_id", loginManager.getIntValue("org_id")); params.put("org_id", loginManager.getIntValue("org_id"));
} }*/
orgManager.checkOrgIds(loginManager,params);
List<JSONObject> managers = managerMapper.listAvailable(params, new PageBounds(Order.formString("create_time.desc"))); List<JSONObject> managers = managerMapper.listAvailable(params, new PageBounds(Order.formString("create_time.desc")));
for (JSONObject manager : managers) { for (JSONObject manager : managers) {
int role = manager.getIntValue("role"); 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()) { if (manager.isAdmin() || manager.isFinacial() || manager.isOperator() || manager.isServant() || manager.isSitemanager() || manager.isDeveloper()) {
throw new BadRequestException("Invalid Role"); throw new BadRequestException("Invalid Role");
} }
obj.remove("org_id"); //obj.remove("org_id");
} }
obj.put("manager_id", userId); obj.put("manager_id", userId);
managerMapper.update(obj); managerMapper.update(obj);

@ -10,6 +10,7 @@ import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -37,9 +38,15 @@ public class ManagerAccountsController {
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
@RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER})
public List<JSONObject> listManagerss(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestParam Map<String, Object> map) { public List<JSONObject> listManagerss(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestParam(required = false) String org_id,@RequestParam(required = false) String org_id2) {
loginManager.putAll(map); JSONObject params = new JSONObject();
return managerAccountsService.listManagers(loginManager); 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) @RequestMapping(method = RequestMethod.POST)

@ -15,7 +15,8 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.search = {role:'111111111111'}; $scope.search = {role:'111111111111'};
$scope.params = {}; $scope.params = {};
$scope.listManagers = function () { $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; $scope.managers = resp.data;
}) })
}; };
@ -35,8 +36,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}) })
}; };
$scope.listManagers(); $scope.listManagers();
$scope.modifyManager = function (manager) { $scope.modifyManager = function (manager) {
$uibModal.open({ $uibModal.open({
@ -83,7 +82,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.loadOrgs(); $scope.loadOrgs();
$scope.loadOrgsChild= function (org_id) { $scope.loadOrgsChild= function (org_id) {
$scope.is_org2 = 'not_is';
$scope.choose_org = org_id; $scope.choose_org = org_id;
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
params.org_id = org_id; params.org_id = org_id;
@ -91,15 +89,19 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.orgs_child = resp.data; $scope.orgs_child = resp.data;
}) })
}; };
if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){
if(!$scope.manager.parent_org_id){ var params = angular.copy($scope.params);
$scope.is_org2 = 'not_is' params.org_id = $scope.currentUser.org_id;
}else { $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_id2 = $scope.manager.org_id;
$scope.manager.org_id = $scope.manager.parent_org_id; $scope.manager.org_id = $scope.manager.parent_org_id;
$scope.loadOrgsChild($scope.manager.org_id); $scope.loadOrgsChild($scope.manager.org_id);
$scope.is_org2 = 'is'; }
};
$scope.modify = function () { $scope.modify = function () {
$scope.errmsg = null; $scope.errmsg = null;
if($scope.manager.password && $scope.manager.password.length < 8){ 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) { app.controller('newManagerDialogCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.params = {}; $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.save = function (form) {
$scope.errmsg = null; $scope.errmsg = null;
if (form.$invalid) { 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 !'; // $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !';
// return; // return;
// } // }
if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){
$scope.manager.bd = true;
}
if($scope.manager.org_id2 != "null") { if($scope.manager.org_id2 != "null") {
$scope.manager.org_id = $scope.manager.org_id2; $scope.manager.org_id = $scope.manager.org_id2;
} }
@ -172,7 +173,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.loadOrgs(); $scope.loadOrgs();
$scope.loadOrgsChild= function (org_id) { $scope.loadOrgsChild= function (org_id) {
$scope.is_org2 = 'not_is';
$scope.choose_org = org_id; $scope.choose_org = org_id;
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
params.org_id = org_id; params.org_id = org_id;
@ -180,14 +180,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.orgs_child = resp.data; $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 () { app.filter('managersFilter', [function () {
return function (arr, filterObj) { return function (arr, filterObj) {

@ -17,7 +17,7 @@
<label class="control-label" for="username-filter-input">Username</label> <label class="control-label" for="username-filter-input">Username</label>
<input type="text" class="form-control" ng-model="search.username" placeholder="Username" id="username-filter-input"> <input type="text" class="form-control" ng-model="search.username" placeholder="Username" id="username-filter-input">
</div> </div>
<div class="form-group" ng-if="'1'|withRole"> <div class="form-group" ng-if="('1'|withRole)">
<label class="control-label" for="role-filter-select">Role</label> <label class="control-label" for="role-filter-select">Role</label>
<select class="form-control" id="role-filter-select" ng-model="search.role"> <select class="form-control" id="role-filter-select" ng-model="search.role">
<option value="111111111111">All</option> <option value="111111111111">All</option>
@ -36,17 +36,18 @@
<option value="1000000000000">Org Manager</option> <option value="1000000000000">Org Manager</option>
</select> </select>
</div> </div>
<div class="form-group" ng-if="'1'|withRole"> <div class="form-group" ng-if="('1'|withRole)">
<select id="org-select" class="form-control" ng-model="search.org_id" <select id="org-select" class="form-control" ng-model="params.org_id"
ng-options="org.org_id as org.name group by org.org_type for org in orgs" ng-options="org.org_id as org.name group by org.org_type for org in orgs"
ng-change="loadOrgsChild(search.org_id)"> ng-change="params.org_id2 = '';listManagers();loadOrgsChild(params.org_id)">
<option value="">All Organizations</option> <option value="">All Organizations</option>
</select> </select>
</div> </div>
<div ng-if="((orgs_child.length > 1)&&( '1'|withRole))"> <div ng-if="(orgs_child.length > 1)&&('1'|withRole)">
<select id="org-child-select" class="form-control" ng-model="search.org_id" <select id="org-child-select" class="form-control" ng-model="params.org_id2"
ng-options="org.org_id as org.name group by org.org_type for org in orgs_child"> ng-options="org.org_id as org.name group by org.org_type for org in orgs_child"
ng-change="listManagers()">
<option value="">Sub Organizations</option> <option value="">Sub Organizations</option>
</select> </select>
</div> </div>

@ -45,7 +45,7 @@
<input class="form-control" type="text" id="wechat-input" name="wechat" <input class="form-control" type="text" id="wechat-input" name="wechat"
ng-model="manager.wechat"> ng-model="manager.wechat">
</div> </div>
<div class="form-group" ng-if="is_org2=='not_is'"> <div class="form-group">
<label class="control-label">Roles</label> <label class="control-label">Roles</label>
<p class="checkbox-inline checkbox"> <p class="checkbox-inline checkbox">
<label ng-if="('00001'|withRole)"> <label ng-if="('00001'|withRole)">
@ -86,14 +86,6 @@
</label> </label>
</p> </p>
</div> </div>
<div class="form-group" ng-if="!currentUser.org_id && is_org2=='is'">
<label class="control-label">Roles</label>
<p class="checkbox checkbox-inline">
<label ng-if="!manager.admin && !manager.operator">
<input type="checkbox" ng-model="manager.bd" name="bd">BD User
</label>
</p>
</div>
<div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && !manager.sitemanager && orgs!=null"> <div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && !manager.sitemanager && orgs!=null">
<label class="control-label" for="org-select">Organization</label> <label class="control-label" for="org-select">Organization</label>
<select class="form-control" ng-model="manager.org_id" id="org-select" <select class="form-control" ng-model="manager.org_id" id="org-select"
@ -103,11 +95,10 @@
</select> </select>
</div> </div>
<div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && orgs_child.length > 1"> <div class="form-group" ng-if="(('1'|withRole)||('1000000000000'|withRole)) && !manager.admin && !manager.operator && orgs_child.length > 1">
<label class="control-label" for="org-select">Sub Organization</label> <label class="control-label" for="org-select">Sub Organization</label>
<select class="form-control" ng-model="manager.org_id2" id="org-child-select" <select class="form-control" ng-model="manager.org_id2" id="org-child-select"
ng-options="org.org_id as org.name group by org.org_type for org in orgs_child" ng-options="org.org_id as org.name group by org.org_type for org in orgs_child">
ng-change="changeIsOrg2(manager.org_id2)">
<option value="">Choose</option> <option value="">Choose</option>
</select> </select>
</div> </div>

@ -51,7 +51,7 @@
<input class="form-control" type="text" id="wechat-input" name="wechat" <input class="form-control" type="text" id="wechat-input" name="wechat"
ng-model="manager.wechat"> ng-model="manager.wechat">
</div> </div>
<div class="form-group" ng-if="!currentUser.org_id && is_org2=='not_is'"> <div class="form-group" ng-if="!currentUser.org_id&&!isOrg">
<label class="control-label">Roles</label> <label class="control-label">Roles</label>
<p class="checkbox checkbox-inline"> <p class="checkbox checkbox-inline">
<label ng-if="('00001'|withRole)"> <label ng-if="('00001'|withRole)">
@ -95,13 +95,15 @@
</label> </label>
</p> </p>
</div> </div>
<div class="form-group" ng-if="!currentUser.org_id &&isOrg">
<div class="form-group" ng-if="!currentUser.org_id && is_org2=='is'">
<label class="control-label">Roles</label> <label class="control-label">Roles</label>
<p class="checkbox checkbox-inline"> <p class="checkbox checkbox-inline">
<label ng-if="!manager.admin && !manager.operator"> <label ng-if="!manager.admin && !manager.operator">
<input type="checkbox" ng-model="manager.bd" name="bd">BD User <input type="checkbox" ng-model="manager.bd" name="bd">BD User
</label> </label>
<label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="manager.orgmanager" name="guest">Org Manager
</label>
</p> </p>
</div> </div>
@ -114,11 +116,10 @@
</select> </select>
</div> </div>
<div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && orgs_child.length > 1"> <div class="form-group" ng-if="(('1'|withRole)||('1000000000000'|withRole)) && !manager.admin && !manager.operator && orgs_child.length > 1">
<label class="control-label" for="org-select">Sub Organization</label> <label class="control-label" for="org-select">Sub Organization</label>
<select class="form-control" ng-model="manager.org_id2" id="org-child-select" <select class="form-control" ng-model="manager.org_id2" id="org-child-select"
ng-options="org.org_id as org.name group by org.org_type for org in orgs_child" ng-options="org.org_id as org.name group by org.org_type for org in orgs_child">
ng-change="changeIsOrg2(manager.org_id2)">
<option value="">Choose</option> <option value="">Choose</option>
</select> </select>
</div> </div>

@ -336,7 +336,40 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
app.controller('modifyManagerCtrl', ['$scope', '$http', 'manager', function ($scope, $http, manager) { app.controller('modifyManagerCtrl', ['$scope', '$http', 'manager', function ($scope, $http, manager) {
$scope.manager = 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 () { $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; $scope.errmsg = null;
$http.put('/sys/manager_accounts/' + manager.manager_id, $scope.manager).then(function () { $http.put('/sys/manager_accounts/' + manager.manager_id, $scope.manager).then(function () {
$scope.$close(); $scope.$close();
@ -352,7 +385,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.loadOrgs(); $scope.loadOrgs();
}]); }]);
app.controller('newManagerCtrl', ['$scope', '$http','org',function ($scope, $http,org) { app.controller('newManagerCtrl', ['$scope', '$http','org',function ($scope, $http,org) {
$scope.isOrg = true;
$scope.save = function (form) { $scope.save = function (form) {
$scope.manager.org_id = org.org_id; $scope.manager.org_id = org.org_id;
$scope.errmsg = null; $scope.errmsg = null;
@ -364,9 +397,13 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}); });
return; return;
} }
if(currentUser.org_id != null && !currentUser.parent_org_id){ if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){
$scope.manager.bd = true; $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 () { $http.post('/sys/manager_accounts', $scope.manager).then(function () {
$scope.$close(); $scope.$close();

Loading…
Cancel
Save