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