Merge branch 'feature/SUPPORT-9296_fix_unblock' into develop

This commit is contained in:
gulnaz 2025-08-04 11:08:55 +03:00
commit d09cd7e31c
14 changed files with 534 additions and 60 deletions

View file

@ -27,12 +27,14 @@ import {ResetPasswordAccount} from "./dto/password/ResetPasswordAccount";
import {ResetPasswordData} from "./dto/password/ResetPasswordData";
import {ProcessRequest} from "./dto/ProcessRequest";
import {StatusUpdateService} from "../../../modules/app/service/status-update.service";
import {BlockedRegion} from "../../../generated/ru/micord/ervu/account_applications/enums/BlockedRegion";
@AnalyticalScope(SaveButton)
export class UserManagementService extends Behavior {
private static PROCESS_START_PATH = '/service/wf/service/start';
private static USER_BLOCK_PATH = "/service/idm/accounts/blocked/v1";
private static ACCOUNT_BLOCK_PATH = "/service/idm/accounts/blocked/v1";
private static PERSON_BLOCK_PATH = "/service/idm/persons/blocked/v1";
@NotNull()
@ObjectRef()
@ -61,6 +63,7 @@ export class UserManagementService extends Behavior {
const formJson = this.collectData();
const appNumber = formJson['appNumber'];
const accountId = formJson['accountId'];
const personId = formJson['idPerson'];
let request;
switch (kind) {
@ -83,7 +86,7 @@ export class UserManagementService extends Behavior {
case ApplicationKind.EDIT_USER_MAIN:
let editPersonData = new EditPersonData();
editPersonData.accountId = accountId;
editPersonData.personId = formJson['idPerson'];
editPersonData.personId = personId;
editPersonData.organizationId = formJson['idDomain'];
editPersonData.personData = this.populateDto(new Person(), formJson);
request = new ProcessRequest<EditPersonData>();
@ -124,10 +127,11 @@ export class UserManagementService extends Behavior {
});
break;
case ApplicationKind.BLOCK_USER:
this.doBlockingRequest([accountId], appNumber, true);
this.doBlockingRequest(accountId, personId, appNumber, true);
break;
case ApplicationKind.UNBLOCK_USER:
this.doBlockingRequest([accountId], appNumber, false);
this.doBlockingRequest(accountId, personId, appNumber, false,
formJson['blockedRegion']);
break;
case ApplicationKind.RESET_PASSWORD:
let resetPasswordAccount = new ResetPasswordAccount();
@ -188,15 +192,32 @@ export class UserManagementService extends Behavior {
});
}
private doBlockingRequest(ids: string[], appNumber: number, block: boolean): void {
const url = window.location.origin + UserManagementService.USER_BLOCK_PATH;
private doBlockingRequest(accountId: string, personId: string, appNumber: number, block: boolean,
blockedRegion?: string): void {
let ids;
let path;
if (!block && blockedRegion != BlockedRegion.ACCOUNT) {
ids = [personId];
path = UserManagementService.PERSON_BLOCK_PATH;
}
else {
ids = [accountId];
path = UserManagementService.ACCOUNT_BLOCK_PATH;
}
const url = window.location.origin + path;
let method = block ? 'delete' : 'post';
this.httpClient.request(method, url, { body: ids, observe: 'response' }).toPromise()
.then((response: any) => {
if (response.ok) {
this.rpc.saveAcceptedStatus(appNumber)
.then(() => this.statusUpdateService.publishStatus(appNumber, true))
.catch(err => console.log('failed to update application status', err));
if (blockedRegion == BlockedRegion.BOTH) {
this.doBlockingRequest(accountId, personId, appNumber, block, BlockedRegion.ACCOUNT);
}
else {
this.rpc.saveAcceptedStatus(appNumber)
.then(() => this.statusUpdateService.publishStatus(appNumber, true))
.catch(err => console.log('failed to update application status', err));
}
}
else {
let reason = response.body ? 'Reason: ' + response.body.toString() : '';