|
|
|
@ -31,7 +31,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> listManagers(JSONObject loginManager) {
|
|
|
|
|
checkBdRole(loginManager);
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
if (loginManager.getInteger("org_id") != null) {
|
|
|
|
|
params.put("org_id", loginManager.getIntValue("org_id"));
|
|
|
|
@ -58,7 +57,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveManager(ManagerInfo manager, JSONObject loginManager) {
|
|
|
|
|
checkBdRole(loginManager);
|
|
|
|
|
if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))) {
|
|
|
|
|
if (manager.isAdmin() || manager.isFinacial() || manager.isOperator() || manager.isServant() || manager.isSitemanager() || manager.isDeveloper()) {
|
|
|
|
|
throw new BadRequestException("Invalid Role");
|
|
|
|
@ -74,7 +72,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void modify(String userId, ManagerInfo manager, JSONObject loginManager) {
|
|
|
|
|
checkBdRole(loginManager);
|
|
|
|
|
JSONObject managerFromDb = managerMapper.findById(userId);
|
|
|
|
|
if (managerFromDb == null) {
|
|
|
|
|
throw new NotFoundException("manager not exists or invalid");
|
|
|
|
@ -95,7 +92,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void disable(String userId, JSONObject loginManager) {
|
|
|
|
|
checkBdRole(loginManager);
|
|
|
|
|
JSONObject manager = managerMapper.findById(userId);
|
|
|
|
|
if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))){
|
|
|
|
|
if (manager.getIntValue("org_id") != loginManager.getIntValue("org_id")) {
|
|
|
|
@ -127,15 +123,4 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
|
|
|
|
|
return financialBDConfigMapper.getBdConfig(bd_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkBdRole(JSONObject loginManager){
|
|
|
|
|
if(ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))){
|
|
|
|
|
JSONObject manager = managerMapper.findById(loginManager.getString("manager_id"));
|
|
|
|
|
if(manager.getString("org_id") != null){
|
|
|
|
|
JSONObject org = orgMapper.findOne(manager.getIntValue("org_id"));
|
|
|
|
|
if(org != null && org.getIntValue("type") == 0 && org.getString("parent_org_id") != null){
|
|
|
|
|
throw new BadRequestException("Invalid Role");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|