SUPPORT-9296: fix unblocking

This commit is contained in:
gulnaz 2025-08-01 15:26:42 +03:00
parent 992e2c9a8a
commit ddc5f40362
6 changed files with 434 additions and 11 deletions

View file

@ -83,11 +83,12 @@ public class AccountGridLoadService extends Behavior implements GridService {
for (Account account : accounts) { for (Account account : accounts) {
GridRow gridRow = new GridRow(); GridRow gridRow = new GridRow();
gridRow.put("row_uid", account.getId() != null ? account.getId() : ""); gridRow.put("row_uid", account.getId() != null ? account.getId() : "");
gridRow.put("enabled", !account.isBlocked()); gridRow.put("accountEnabled", !account.isBlocked());
Person person = account.getPerson(); Person person = account.getPerson();
if (person != null) { if (person != null) {
gridRow.put("login", person.getLogin()); gridRow.put("login", person.getLogin());
gridRow.put("snils", person.getSnils()); gridRow.put("snils", person.getSnils());
gridRow.put("personEnabled", !person.isBlocked());
String fullName = person.getFullName(); String fullName = person.getFullName();
if (fullName != null) { if (fullName != null) {

View file

@ -0,0 +1,13 @@
package ru.micord.ervu.account_applications.enums;
import ru.cg.webbpm.modules.webkit.annotations.Model;
/**
* @author gulnaz
*/
@Model
public enum BlockedRegion {
ACCOUNT,
PERSON,
BOTH
}

View file

@ -33,6 +33,8 @@ import ru.micord.ervu.account_applications.service.constant.PathConstant;
import ru.cg.webbpm.modules.standard_annotations.editor.ObjectRef; import ru.cg.webbpm.modules.standard_annotations.editor.ObjectRef;
import static ru.micord.ervu.account_applications.enums.BlockedRegion.*;
/** /**
* @author Adel Kalimullin * @author Adel Kalimullin
*/ */
@ -42,6 +44,9 @@ public class AccountFetchService implements EntityFetchService<Account> {
private static final String FIELD_IP_ADDRESSES = "ipAddresses"; private static final String FIELD_IP_ADDRESSES = "ipAddresses";
private static final String FIELD_SNILS = "snils"; private static final String FIELD_SNILS = "snils";
private static final String FIELD_ROLES = "roles"; private static final String FIELD_ROLES = "roles";
private static final String FIELD_ACCOUNT_BLOCKED = "blocked";
private static final String FIELD_PERSON_BLOCKED = "person.blocked";
private static final String FIELD_BLOCKED_REGION = "blockedRegion";
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final ObjectMapper mapper; private final ObjectMapper mapper;
private final SecurityContext securityContext; private final SecurityContext securityContext;
@ -140,7 +145,9 @@ public class AccountFetchService implements EntityFetchService<Account> {
} }
private Map<String, Object> objectToFlatMap(Object obj) { private Map<String, Object> objectToFlatMap(Object obj) {
return objectToFlatMapInternal(obj, ""); Map<String, Object> result = objectToFlatMapInternal(obj, "");
putBlockedValue(result);
return result;
} }
private Map<String, Object> objectToFlatMapInternal(Object obj, String prefix) { private Map<String, Object> objectToFlatMapInternal(Object obj, String prefix) {
@ -224,4 +231,14 @@ public class AccountFetchService implements EntityFetchService<Account> {
private boolean isSimple(Class<?> type) { private boolean isSimple(Class<?> type) {
return ClassUtils.isPrimitiveOrWrapper(type) || type == String.class; return ClassUtils.isPrimitiveOrWrapper(type) || type == String.class;
} }
private void putBlockedValue(Map<String, Object> result) {
boolean accountBlocked = Boolean.parseBoolean(String.valueOf(result.get(FIELD_ACCOUNT_BLOCKED)));
boolean personBlocked = Boolean.parseBoolean(String.valueOf(result.get(FIELD_PERSON_BLOCKED)));
String value = accountBlocked && personBlocked
? BOTH.toString() : accountBlocked
? ACCOUNT.toString() : personBlocked
? PERSON.toString() : null;
result.put(FIELD_BLOCKED_REGION, value);
}
} }

View file

@ -27,12 +27,14 @@ import {ResetPasswordAccount} from "./dto/password/ResetPasswordAccount";
import {ResetPasswordData} from "./dto/password/ResetPasswordData"; import {ResetPasswordData} from "./dto/password/ResetPasswordData";
import {ProcessRequest} from "./dto/ProcessRequest"; import {ProcessRequest} from "./dto/ProcessRequest";
import {StatusUpdateService} from "../../../modules/app/service/status-update.service"; import {StatusUpdateService} from "../../../modules/app/service/status-update.service";
import {BlockedRegion} from "../../../generated/ru/micord/ervu/account_applications/enums/BlockedRegion";
@AnalyticalScope(SaveButton) @AnalyticalScope(SaveButton)
export class UserManagementService extends Behavior { export class UserManagementService extends Behavior {
private static PROCESS_START_PATH = '/service/wf/service/start'; 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() @NotNull()
@ObjectRef() @ObjectRef()
@ -127,7 +129,7 @@ export class UserManagementService extends Behavior {
this.doBlockingRequest([accountId], appNumber, true); this.doBlockingRequest([accountId], appNumber, true);
break; break;
case ApplicationKind.UNBLOCK_USER: case ApplicationKind.UNBLOCK_USER:
this.doBlockingRequest([accountId], appNumber, false); this.doBlockingRequest([accountId], appNumber, false, formJson['blockedRegion']);
break; break;
case ApplicationKind.RESET_PASSWORD: case ApplicationKind.RESET_PASSWORD:
let resetPasswordAccount = new ResetPasswordAccount(); let resetPasswordAccount = new ResetPasswordAccount();
@ -188,16 +190,24 @@ export class UserManagementService extends Behavior {
}); });
} }
private doBlockingRequest(ids: string[], appNumber: number, block: boolean): void { private doBlockingRequest(ids: string[], appNumber: number, block: boolean, blockedRegion?: string): void {
const url = window.location.origin + UserManagementService.USER_BLOCK_PATH; let path = !block && blockedRegion != BlockedRegion.ACCOUNT
? UserManagementService.PERSON_BLOCK_PATH
: UserManagementService.ACCOUNT_BLOCK_PATH;
const url = window.location.origin + path;
let method = block ? 'delete' : 'post'; let method = block ? 'delete' : 'post';
this.httpClient.request(method, url, { body: ids, observe: 'response' }).toPromise() this.httpClient.request(method, url, { body: ids, observe: 'response' }).toPromise()
.then((response: any) => { .then((response: any) => {
if (response.ok) { if (response.ok) {
if (blockedRegion == BlockedRegion.BOTH) {
this.doBlockingRequest(ids, appNumber, block, BlockedRegion.ACCOUNT);
}
else {
this.rpc.saveAcceptedStatus(appNumber) this.rpc.saveAcceptedStatus(appNumber)
.then(() => this.statusUpdateService.publishStatus(appNumber, true)) .then(() => this.statusUpdateService.publishStatus(appNumber, true))
.catch(err => console.log('failed to update application status', err)); .catch(err => console.log('failed to update application status', err));
} }
}
else { else {
let reason = response.body ? 'Reason: ' + response.body.toString() : ''; let reason = response.body ? 'Reason: ' + response.body.toString() : '';
let errorMsg = `Failed to execute blocking request. Http status: ${response.status}. ${reason}`; let errorMsg = `Failed to execute blocking request. Http status: ${response.status}. ${reason}`;

View file

@ -2495,6 +2495,7 @@
<componentRootId>b838c4d9-b8f2-4142-96fe-240540a4802e</componentRootId> <componentRootId>b838c4d9-b8f2-4142-96fe-240540a4802e</componentRootId>
<name>Номер</name> <name>Номер</name>
<container>false</container> <container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered> <childrenReordered>false</childrenReordered>
<scripts id="a6c37a96-2bfd-40f4-bd4a-a97c3443b9c0"> <scripts id="a6c37a96-2bfd-40f4-bd4a-a97c3443b9c0">
<properties> <properties>
@ -2557,6 +2558,7 @@
<componentRootId>a410163c-e804-4bff-9d0a-28e4853f4a58</componentRootId> <componentRootId>a410163c-e804-4bff-9d0a-28e4853f4a58</componentRootId>
<name>Фамилия</name> <name>Фамилия</name>
<container>false</container> <container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered> <childrenReordered>false</childrenReordered>
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c"> <scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties> <properties>
@ -3205,6 +3207,138 @@
<simple>"snils"</simple> <simple>"snils"</simple>
</value> </value>
</entry> </entry>
</properties>
</scripts>
</children>
<children id="3fb4a21f-d13c-4854-a837-df07f5f3090e">
<prototypeId>133ca212-09a6-413a-ac66-e2f6ce188f1f</prototypeId>
<componentRootId>3fb4a21f-d13c-4854-a837-df07f5f3090e</componentRootId>
<name>Блокировка</name>
<container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties>
<entry>
<key>collectible</key>
<value>
<simple>false</simple>
</value>
</entry>
<entry>
<key>cssClasses</key>
<value>
<item id="764eafb4-4209-49f7-9d40-b25f0005438b" removed="false">
<value>
<simple>"width-full"</simple>
</value>
</item>
</value>
</entry>
<entry>
<key>disabled</key>
<value>
<simple>true</simple>
</value>
</entry>
<entry>
<key>label</key>
<value>
<simple>"Блокировка"</simple>
</value>
</entry>
<entry>
<key>mask</key>
<value>
<simple>null</simple>
</value>
</entry>
<entry>
<key>unMaskValue</key>
<value>
<simple>false</simple>
</value>
</entry>
<entry>
<key>visible</key>
<value>
<simple>false</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="5ba072f6-3017-4f32-9a6a-1ca5e690e1dd"/>
<scripts id="ef53357a-6f68-4479-9a05-d37cfb44b6ba">
<properties>
<entry>
<key>defaultValueColumn</key>
<value>
<simple>{"schema":"public","table":"user_list","entity":"user_list","name":"phone"}</simple>
</value>
</entry>
<entry>
<key>loadType</key>
<value>
<simple>null</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="2e66508a-de36-4816-b32c-18f8c7c39830"/>
<scripts id="cd632c24-f994-46fd-a0fd-3d113f9c81c1">
<properties>
<entry>
<key>columnForSave</key>
<value>
<simple>{"schema":"public","table":"user_application_list","entity":"user_application_list","name":"blocked_region"}</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0">
<properties>
<entry>
<key>textFieldService</key>
<value>
<complex>
<entry>
<key>displayColumn</key>
<value>
<simple>{"schema":"public","table":"user_application_list","entity":"user_application_list","name":"blocked_region"}</simple>
</value>
</entry>
<entry>
<key>loadDao</key>
<value>
<complex>
<entry>
<key>graph</key>
<value>
<simple>{"conditionGroup":{"operator":"AND","conditions":[],"groups":[]},"nodeByIndex":{"0":{"tableName":"user_application_list","schemaName":"public","x":370.0,"y":295.0,"alias":"user_application_list","conditionGroup":{"operator":"AND","conditions":[],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}},"nodes":[{"tableName":"user_application_list","schemaName":"public","x":370.0,"y":295.0,"alias":"user_application_list","conditionGroup":{"operator":"AND","conditions":[],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}],"nodeByEntityName":{"user_application_list":{"tableName":"user_application_list","schemaName":"public","x":370.0,"y":295.0,"alias":"user_application_list","conditionGroup":{"operator":"AND","conditions":[],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}},"matrix":[[null]],"mainNodeIndex":0}</simple>
</value>
</entry>
</complex>
</value>
</entry>
</complex>
</value>
</entry>
</properties>
</scripts>
<scripts id="bcf7261b-3951-4594-bd3a-92fa96f20a50">
<classRef type="TS">
<className>FormField</className>
<packageName>account_applications.component.field</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>name</key>
<value>
<simple>"blockedRegion"</simple>
</value>
</entry>
</properties> </properties>
</scripts> </scripts>
</children> </children>

View file

@ -2280,6 +2280,56 @@
</value> </value>
</entry> </entry>
</complex> </complex>
</value>
</entry>
</complex>
</value>
</item>
<item id="b3545550-6351-47e7-b51e-39ae323a7d53" removed="false">
<value>
<complex>
<entry>
<key>behavior</key>
<value>
<simple>{"objectId":"2ad7edcd-a3d0-4ac8-aab2-72ad28e20d7e","packageName":"component.field","className":"TextField","type":"TS"}</simple>
</value>
</entry>
<entry>
<key>method</key>
<value>
<simple>"setValue"</simple>
</value>
</entry>
<entry>
<key>value</key>
<value>
<complex>
<entry>
<key>objectValue</key>
<value>
<complex>
<entry>
<key>argument</key>
<value>
<simple>null</simple>
</value>
</entry>
<entry>
<key>behavior</key>
<value>
<simple>{"objectId":"d8984d37-f505-4c23-a805-44a44213a4ca","packageName":"component.field","className":"TextField","type":"TS"}</simple>
</value>
</entry>
<entry>
<key>method</key>
<value>
<simple>"getValue"</simple>
</value>
</entry>
</complex>
</value>
</entry>
</complex>
</value> </value>
</entry> </entry>
</complex> </complex>
@ -2360,6 +2410,52 @@
</value> </value>
</entry> </entry>
</properties> </properties>
</scripts>
</children>
<children id="d8984d37-f505-4c23-a805-44a44213a4ca">
<prototypeId>133ca212-09a6-413a-ac66-e2f6ce188f1f</prototypeId>
<componentRootId>d8984d37-f505-4c23-a805-44a44213a4ca</componentRootId>
<name>Блокировка load_1</name>
<container>false</container>
<childrenReordered>false</childrenReordered>
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties>
<entry>
<key>label</key>
<value>
<simple>"Блокировка load_1"</simple>
</value>
</entry>
<entry>
<key>visible</key>
<value>
<simple>false</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="5ba072f6-3017-4f32-9a6a-1ca5e690e1dd"/>
<scripts id="ef53357a-6f68-4479-9a05-d37cfb44b6ba"/>
<scripts id="2e66508a-de36-4816-b32c-18f8c7c39830"/>
<scripts id="cd632c24-f994-46fd-a0fd-3d113f9c81c1">
<enabled>false</enabled>
</scripts>
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0"/>
<scripts id="6d00f861-5645-4cff-8902-bc1d7047d6a4">
<classRef type="JAVA">
<className>ErvuFormLoadComponent</className>
<packageName>ru.micord.ervu.account_applications.component.field.persist</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>fieldName</key>
<value>
<simple>"blockedRegion"</simple>
</value>
</entry>
</properties>
</scripts> </scripts>
</children> </children>
<children id="d3196840-53cf-41ab-b00c-678cbf9032ad"> <children id="d3196840-53cf-41ab-b00c-678cbf9032ad">
@ -4059,6 +4155,13 @@
<removed>true</removed> <removed>true</removed>
</children> </children>
</children> </children>
<children id="2ad7edcd-a3d0-4ac8-aab2-72ad28e20d7e">
<prototypeId>133ca212-09a6-413a-ac66-e2f6ce188f1f</prototypeId>
<componentRootId>2ad7edcd-a3d0-4ac8-aab2-72ad28e20d7e</componentRootId>
<name>person_id</name>
<container>false</container>
<removed>true</removed>
</children>
</children> </children>
<children id="ad5ed255-1755-47a6-89e0-38e60d2f1018"> <children id="ad5ed255-1755-47a6-89e0-38e60d2f1018">
<prototypeId>b310f98a-69c6-4e7b-8cdb-f1ab9f9c0d94</prototypeId> <prototypeId>b310f98a-69c6-4e7b-8cdb-f1ab9f9c0d94</prototypeId>
@ -4484,6 +4587,84 @@
<key>fieldName</key> <key>fieldName</key>
<value> <value>
<simple>"personId"</simple> <simple>"personId"</simple>
</value>
</entry>
</properties>
</scripts>
</children>
<children id="2ad7edcd-a3d0-4ac8-aab2-72ad28e20d7e">
<prototypeId>133ca212-09a6-413a-ac66-e2f6ce188f1f</prototypeId>
<componentRootId>2ad7edcd-a3d0-4ac8-aab2-72ad28e20d7e</componentRootId>
<name>blocked_region</name>
<container>false</container>
<childrenReordered>false</childrenReordered>
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties>
<entry>
<key>cssClasses</key>
<value>
<item id="287616fa-ec3b-475d-a629-f511bde88984" removed="false">
<value>
<simple>"width-full"</simple>
</value>
</item>
</value>
</entry>
<entry>
<key>label</key>
<value>
<simple>"blocked_region"</simple>
</value>
</entry>
<entry>
<key>visible</key>
<value>
<simple>false</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="5ba072f6-3017-4f32-9a6a-1ca5e690e1dd"/>
<scripts id="ef53357a-6f68-4479-9a05-d37cfb44b6ba">
<properties>
<entry>
<key>defaultValueColumn</key>
<value>
<simple>{"schema":"public","table":"user_list","entity":"user_list","name":"middlename"}</simple>
</value>
</entry>
<entry>
<key>loadType</key>
<value>
<simple>null</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="2e66508a-de36-4816-b32c-18f8c7c39830"/>
<scripts id="cd632c24-f994-46fd-a0fd-3d113f9c81c1">
<properties>
<entry>
<key>columnForSave</key>
<value>
<simple>{"schema":"public","table":"user_application_list","entity":"user_application_list","name":"blocked_region"}</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0"/>
<scripts id="1d2946e1-344f-43c9-afd5-ce79791600d4">
<classRef type="JAVA">
<className>ErvuFormLoadComponent</className>
<packageName>ru.micord.ervu.account_applications.component.field.persist</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>fieldName</key>
<value>
<simple>"blockedRegion"</simple>
</value> </value>
</entry> </entry>
</properties> </properties>
@ -7497,7 +7678,7 @@
<entry> <entry>
<key>displayName</key> <key>displayName</key>
<value> <value>
<simple>"Активен"</simple> <simple>"Персона активна"</simple>
</value> </value>
</entry> </entry>
<entry> <entry>
@ -7507,7 +7688,74 @@
<entry> <entry>
<key>column</key> <key>column</key>
<value> <value>
<simple>"enabled"</simple> <simple>"personEnabled"</simple>
</value>
</entry>
<entry>
<key>filterType</key>
<value>
<simple>"TEXT"</simple>
</value>
</entry>
<entry>
<key>type</key>
<value>
<simple>"java.lang.String"</simple>
</value>
</entry>
</complex>
</value>
</entry>
<entry>
<key>hidden</key>
<value>
<simple>true</simple>
</value>
</entry>
<entry>
<key>sortable</key>
<value>
<simple>false</simple>
</value>
</entry>
</properties>
</scripts>
</children>
<children id="0385b14c-91ef-4f02-8ebf-5d064d3f65ea">
<prototypeId>d4f69cb0-864e-4895-b6fd-152072774909</prototypeId>
<componentRootId>0385b14c-91ef-4f02-8ebf-5d064d3f65ea</componentRootId>
<name>StaticColumn</name>
<container>false</container>
<childrenReordered>false</childrenReordered>
<scripts id="bc6afb28-7884-477d-b425-2c2001be8379">
<properties>
<entry>
<key>valueFormatter</key>
<value>
<implRef type="TS">
<className>DefaultValueFormatter</className>
<packageName>component.grid.formatters</packageName>
</implRef>
</value>
</entry>
</properties>
</scripts>
<scripts id="a930059f-1e14-40ed-a4de-3dec3d03f9a7">
<properties>
<entry>
<key>displayName</key>
<value>
<simple>"Аккаунт активен"</simple>
</value>
</entry>
<entry>
<key>field</key>
<value>
<complex>
<entry>
<key>column</key>
<value>
<simple>"accountEnabled"</simple>
</value> </value>
</entry> </entry>
<entry> <entry>