SUPPORT-9104: move user application requests to front
This commit is contained in:
parent
69a2ad479f
commit
d957d33cc7
9 changed files with 248 additions and 19 deletions
|
|
@ -0,0 +1,32 @@
|
|||
package ru.micord.ervu.account_applications.component.rpc;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ru.micord.ervu.account_applications.dao.UserApplicationListDao;
|
||||
|
||||
import ru.cg.webbpm.modules.webkit.annotations.RpcCall;
|
||||
import ru.cg.webbpm.modules.webkit.annotations.RpcService;
|
||||
import ru.cg.webbpm.modules.webkit.beans.Behavior;
|
||||
|
||||
/**
|
||||
* @author gulnaz
|
||||
*/
|
||||
@RpcService
|
||||
public class UserApplicationListRpcService extends Behavior {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserApplicationListRpcService.class);
|
||||
|
||||
@Autowired
|
||||
private UserApplicationListDao applicationListDao;
|
||||
|
||||
@RpcCall
|
||||
public void saveTraceId(String traceId, long appNumber) {
|
||||
LOGGER.info("saving traceId {} for application {}", traceId, appNumber);
|
||||
applicationListDao.saveTraceId(traceId, appNumber);
|
||||
}
|
||||
|
||||
@RpcCall
|
||||
public void saveAgreedStatus(long appNumber) {
|
||||
applicationListDao.saveAgreedStatus(appNumber);
|
||||
}
|
||||
}
|
||||
|
|
@ -69,4 +69,11 @@ public class UserApplicationListDao {
|
|||
Timestamp.valueOf(LocalDateTime.now().minusMinutes(minutes)))))
|
||||
.execute();
|
||||
}
|
||||
|
||||
public void saveAgreedStatus(long appNumber) {
|
||||
dslContext.update(USER_APPLICATION_LIST)
|
||||
.set(USER_APPLICATION_LIST.APPLICATION_STATUS, AGREED.name())
|
||||
.where(USER_APPLICATION_LIST.NUMBER_APP.eq(appNumber))
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ public class UserApplicationListService {
|
|||
dao.saveAcceptedStatus(traceId);
|
||||
}
|
||||
|
||||
public void saveAgreedStatus(long appNumber) {
|
||||
dao.saveAgreedStatus(appNumber);
|
||||
}
|
||||
|
||||
public void saveError(String traceId, String errorMsg) {
|
||||
dao.saveError(traceId, errorMsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,23 @@ import {
|
|||
NotNull,
|
||||
ObjectRef,
|
||||
SaveButton,
|
||||
TextField, Visible
|
||||
TextField,
|
||||
Visible
|
||||
} from "@webbpm/base-package";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {FormField} from "../field/FormField";
|
||||
import {AuthorizationService} from "../../../modules/app/service/authorization.service";
|
||||
import {ApplicationKind} from "../enum/ApplicationKind";
|
||||
import {ProcessRequest} from "./request/ProcessRequest";
|
||||
import {ProcessKey} from "../enum/ProcessKey";
|
||||
import {ProcessResponse} from "./response/ProcessResponse";
|
||||
import {UserApplicationListRpcService} from "../../../generated/ru/micord/ervu/account_applications/component/rpc/UserApplicationListRpcService";
|
||||
|
||||
@AnalyticalScope(SaveButton)
|
||||
export class UserManagementService extends Behavior {
|
||||
|
||||
private static PROCESS_START_PATH = '/service/wf/service/start';
|
||||
|
||||
@NotNull()
|
||||
@ObjectRef()
|
||||
public applicationKind: TextField;
|
||||
|
|
@ -22,42 +29,62 @@ export class UserManagementService extends Behavior {
|
|||
private httpClient: HttpClient;
|
||||
private onClickFunction: Function;
|
||||
private sendToErvu: boolean = false;
|
||||
private rpc: UserApplicationListRpcService;
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.button = this.getScript(SaveButton);
|
||||
this.httpClient = this.injector.get(HttpClient);
|
||||
this.rpc = this.getScript(UserApplicationListRpcService);
|
||||
let authService = this.injector.get(AuthorizationService);
|
||||
this.onClickFunction = () => {
|
||||
if (!authService.hasRole('security_administrator') || !this.sendToErvu) {
|
||||
return;
|
||||
}
|
||||
let jsonObj = this.collectData();
|
||||
let kind = this.applicationKind.getValue();
|
||||
let request;
|
||||
let processKey;
|
||||
|
||||
switch (kind) {
|
||||
case ApplicationKind.CREATE_USER:
|
||||
this.doRequest("user", jsonObj);
|
||||
request = ProcessRequest.CREATE;
|
||||
processKey = ProcessKey.CREATE;
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_MAIN:
|
||||
this.doRequest("user/person", jsonObj);
|
||||
request = ProcessRequest.EDIT_PERSON;
|
||||
processKey = ProcessKey.EDIT_PERSON;
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ACCOUNT:
|
||||
this.doRequest("user/account", jsonObj);
|
||||
request = ProcessRequest.EDIT_ACCOUNT;
|
||||
processKey = ProcessKey.EDIT_ACCOUNT;
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ROLES:
|
||||
this.doRequest("user/roles", jsonObj);
|
||||
request = ProcessRequest.EDIT_ROLES;
|
||||
processKey = ProcessKey.EDIT_ROLES;
|
||||
break;
|
||||
case ApplicationKind.BLOCK_USER:
|
||||
this.doRequest("user/deactivation", jsonObj);
|
||||
request = ProcessRequest.CHANGE_ACTIVATION;
|
||||
processKey = ProcessKey.DEACTIVATE;
|
||||
break;
|
||||
case ApplicationKind.UNBLOCK_USER:
|
||||
this.doRequest("user/activation", jsonObj);
|
||||
request = ProcessRequest.CHANGE_ACTIVATION;
|
||||
processKey = ProcessKey.ACTIVATE;
|
||||
break;
|
||||
case ApplicationKind.RESET_PASSWORD:
|
||||
this.doRequest("user/password/reset", jsonObj);
|
||||
request = ProcessRequest.RESET_PASSWORD;
|
||||
processKey = ProcessKey.RESET_PASSWORD;
|
||||
break;
|
||||
}
|
||||
|
||||
let formJson = this.collectData();
|
||||
this.populateRequest(request, formJson);
|
||||
|
||||
if (request.data.account.id) {
|
||||
request.data.account.id = formJson['accountId'];
|
||||
}
|
||||
request.processKey = processKey;
|
||||
request.userId = authService.getUserId();
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,11 +103,43 @@ export class UserManagementService extends Behavior {
|
|||
return jsonObj;
|
||||
}
|
||||
|
||||
private doRequest(url: string, jsonObj: any): void {
|
||||
this.httpClient.post(url, jsonObj).toPromise()
|
||||
private populateRequest(request: any, jsonObj: any) {
|
||||
Object.keys(request).forEach(key => {
|
||||
if (key === 'rolesList') {
|
||||
if (jsonObj[key]) {
|
||||
request[key] = jsonObj[key].map(id => ({
|
||||
id: id,
|
||||
finish: ''
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if (typeof request[key] === 'object' && !Array.isArray(request[key])) {
|
||||
this.populateRequest(request[key], jsonObj);
|
||||
}
|
||||
else {
|
||||
if (jsonObj[key]) {
|
||||
request[key] = jsonObj[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private doRequest(request: any, appNumber: number): void {
|
||||
const url = window.location.origin + UserManagementService.PROCESS_START_PATH;
|
||||
this.httpClient.post(url, request).toPromise()
|
||||
.then((response: ProcessResponse) => {
|
||||
let code = response.code;
|
||||
|
||||
if (code === '200') {
|
||||
this.rpc.saveTraceId(response.traceId, appNumber);
|
||||
}
|
||||
else {
|
||||
this.rpc.saveAgreedStatus(appNumber);
|
||||
}
|
||||
})
|
||||
.catch(reason => {
|
||||
//TODO change status
|
||||
console.error("Error while executing request:", reason.toString());
|
||||
this.rpc.saveAgreedStatus(appNumber);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,98 @@
|
|||
export class ProcessRequest {
|
||||
public static CREATE = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
credential: {
|
||||
userName: ""
|
||||
},
|
||||
account: {
|
||||
schema: "Account",
|
||||
"user-domain": "",
|
||||
position: "",
|
||||
enabled: true,
|
||||
esiaAccount: false,
|
||||
start: "",
|
||||
finish: ""
|
||||
},
|
||||
person: {
|
||||
id: "",
|
||||
surname: "",
|
||||
firstname: "",
|
||||
middlename: "",
|
||||
email: "",
|
||||
birthdate: "",
|
||||
snils: "",
|
||||
ipAddresses: [],
|
||||
secondFactorEnabled: false,
|
||||
sex: ""
|
||||
},
|
||||
roles: {
|
||||
rolesList: [],
|
||||
removeRoles: []
|
||||
}
|
||||
}
|
||||
};
|
||||
public static EDIT_PERSON = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
accountId: "",
|
||||
personData: {
|
||||
id: "",
|
||||
surname: "",
|
||||
firstname: "",
|
||||
middlename: "",
|
||||
email: "",
|
||||
birthdate: "",
|
||||
snils: "",
|
||||
ipAddresses: [],
|
||||
secondFactorEnabled: false,
|
||||
sex: ""
|
||||
}
|
||||
}
|
||||
};
|
||||
public static EDIT_ACCOUNT = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
account: {
|
||||
id: "",
|
||||
schema: "Account",
|
||||
"user-domain": "",
|
||||
position: "",
|
||||
enabled: true,
|
||||
esiaAccount: false,
|
||||
start: "",
|
||||
finish: ""
|
||||
}
|
||||
}
|
||||
};
|
||||
public static EDIT_ROLES = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
account: {
|
||||
accountId: "",
|
||||
rolesList: [],
|
||||
removeRoles: []
|
||||
}
|
||||
}
|
||||
};
|
||||
public static CHANGE_ACTIVATION = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
accountIdList: []
|
||||
}
|
||||
};
|
||||
public static RESET_PASSWORD = {
|
||||
processKey: "",
|
||||
userId: "",
|
||||
data: {
|
||||
account: {
|
||||
id: ""
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export interface ProcessResponse {
|
||||
code: string,
|
||||
msg: string,
|
||||
traceId: string
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
export enum ProcessKey {
|
||||
CREATE= "milBaseCreateAccountProcess",
|
||||
EDIT_PERSON = "milBaseEditAccountPersonIDMProcess",
|
||||
EDIT_ACCOUNT = "milBaseEditAccountIDMProcess",
|
||||
EDIT_ROLES = "milBaseEditAccountRolesIDMSubProcess",
|
||||
DEACTIVATE = "milBaseMassDeActivateAccountIDMProcess",
|
||||
ACTIVATE = "milBaseMassActivateAccountIDMProcess",
|
||||
RESET_PASSWORD = "milBaseResetPasswordProcess"
|
||||
}
|
||||
|
|
@ -3057,7 +3057,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"username"</simple>
|
||||
<simple>"userName"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -3466,7 +3466,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"userDomain"</simple>
|
||||
<simple>"user-domain"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -3682,7 +3682,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"roles"</simple>
|
||||
<simple>"rolesList"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -8722,6 +8722,14 @@
|
|||
</entry>
|
||||
</properties>
|
||||
</scripts>
|
||||
<scripts id="ae7e90d1-0db9-4cc1-9202-e2dc273ae66d">
|
||||
<classRef type="JAVA">
|
||||
<className>UserApplicationListRpcService</className>
|
||||
<packageName>ru.micord.ervu.account_applications.component.rpc</packageName>
|
||||
</classRef>
|
||||
<enabled>true</enabled>
|
||||
<expanded>true</expanded>
|
||||
</scripts>
|
||||
</children>
|
||||
<children id="7ed531bc-a941-43a9-8cf7-31d32dd6e0cd">
|
||||
<prototypeId>c8dfe691-a84a-48da-b79e-6298d90db71d</prototypeId>
|
||||
|
|
|
|||
|
|
@ -2688,7 +2688,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"username"</simple>
|
||||
<simple>"userName"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -2891,7 +2891,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"userDomain"</simple>
|
||||
<simple>"user-domain"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -3112,7 +3112,7 @@
|
|||
<entry>
|
||||
<key>name</key>
|
||||
<value>
|
||||
<simple>"roles"</simple>
|
||||
<simple>"rolesList"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
|
|
@ -3391,7 +3391,6 @@
|
|||
<componentRootId>2ee6f91b-c4a2-461d-8428-c3a6a13c9244</componentRootId>
|
||||
<name>hidden</name>
|
||||
<container>true</container>
|
||||
<expanded>false</expanded>
|
||||
<childrenReordered>false</childrenReordered>
|
||||
<scripts id="bf098f19-480e-44e4-9084-aa42955c4d0f">
|
||||
<properties>
|
||||
|
|
@ -7780,6 +7779,14 @@
|
|||
</entry>
|
||||
</properties>
|
||||
</scripts>
|
||||
<scripts id="55ae453e-60e1-4988-83b0-36b73289e533">
|
||||
<classRef type="JAVA">
|
||||
<className>UserApplicationListRpcService</className>
|
||||
<packageName>ru.micord.ervu.account_applications.component.rpc</packageName>
|
||||
</classRef>
|
||||
<enabled>true</enabled>
|
||||
<expanded>true</expanded>
|
||||
</scripts>
|
||||
</children>
|
||||
<children id="7ed531bc-a941-43a9-8cf7-31d32dd6e0cd">
|
||||
<prototypeId>c8dfe691-a84a-48da-b79e-6298d90db71d</prototypeId>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue