SUPPORT-9136: update application status dynamically
This commit is contained in:
parent
e5280c1a3f
commit
e14d71b5c1
7 changed files with 112 additions and 23 deletions
|
|
@ -28,8 +28,9 @@ public class UserApplicationController {
|
|||
}
|
||||
|
||||
@PutMapping(value = "/status", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public void updateStatus(@RequestBody ProcessResponseDto data) {
|
||||
public Long updateStatus(@RequestBody ProcessResponseDto data) {
|
||||
String traceId = data.traceId();
|
||||
Long appNumber = 0L;
|
||||
|
||||
switch (data.className()) {
|
||||
case UPDATE -> {
|
||||
|
|
@ -38,17 +39,19 @@ public class UserApplicationController {
|
|||
|
||||
if (StringUtils.hasText(tempPass)) {
|
||||
String encryptedPassword = encryptionService.encrypt(tempPass);
|
||||
applicationService.savePassword(traceId, encryptedPassword);
|
||||
appNumber = applicationService.savePassword(traceId, encryptedPassword);
|
||||
}
|
||||
else {
|
||||
applicationService.saveAcceptedStatus(traceId);
|
||||
appNumber = applicationService.saveAcceptedStatus(traceId);
|
||||
}
|
||||
}
|
||||
case PROCESS_ERROR -> {
|
||||
String msg = data.body().msg().message();
|
||||
LOGGER.error("error by traceId = {}, message: {}", traceId, msg);
|
||||
applicationService.saveError(traceId, msg);
|
||||
appNumber = applicationService.saveError(traceId, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return appNumber;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,27 +31,30 @@ public class UserApplicationListDao {
|
|||
.execute();
|
||||
}
|
||||
|
||||
public void savePassword(String traceId, String encodedPass) {
|
||||
dslContext.update(USER_APPLICATION_LIST)
|
||||
public Long savePassword(String traceId, String encodedPass) {
|
||||
return dslContext.update(USER_APPLICATION_LIST)
|
||||
.set(USER_APPLICATION_LIST.APPLICATION_STATUS, ACCEPTED.name())
|
||||
.set(USER_APPLICATION_LIST.USER_PASSWORD, encodedPass)
|
||||
.where(USER_APPLICATION_LIST.TRACE_ID.eq(traceId))
|
||||
.execute();
|
||||
.returning(USER_APPLICATION_LIST.NUMBER_APP)
|
||||
.fetchOneInto(Long.class);
|
||||
}
|
||||
|
||||
public void saveAcceptedStatus(String traceId) {
|
||||
dslContext.update(USER_APPLICATION_LIST)
|
||||
public Long saveAcceptedStatus(String traceId) {
|
||||
return dslContext.update(USER_APPLICATION_LIST)
|
||||
.set(USER_APPLICATION_LIST.APPLICATION_STATUS, ACCEPTED.name())
|
||||
.where(USER_APPLICATION_LIST.TRACE_ID.eq(traceId))
|
||||
.execute();
|
||||
.returning(USER_APPLICATION_LIST.NUMBER_APP)
|
||||
.fetchOneInto(Long.class);
|
||||
}
|
||||
|
||||
public void saveError(String traceId, String errorMsg) {
|
||||
dslContext.update(USER_APPLICATION_LIST)
|
||||
public Long saveError(String traceId, String errorMsg) {
|
||||
return dslContext.update(USER_APPLICATION_LIST)
|
||||
.set(USER_APPLICATION_LIST.APPLICATION_STATUS, AGREED.name())
|
||||
.set(USER_APPLICATION_LIST.EDIT_COMMENT, errorMsg)
|
||||
.where(USER_APPLICATION_LIST.TRACE_ID.eq(traceId))
|
||||
.execute();
|
||||
.returning(USER_APPLICATION_LIST.NUMBER_APP)
|
||||
.fetchOneInto(Long.class);
|
||||
}
|
||||
|
||||
public boolean userExists(String login) {
|
||||
|
|
|
|||
|
|
@ -35,27 +35,30 @@ public class UserApplicationListService {
|
|||
dao.saveTraceId(traceId, appNumber);
|
||||
}
|
||||
|
||||
public void savePassword(String traceId, String encodedPass) {
|
||||
dao.savePassword(traceId, encodedPass);
|
||||
public Long savePassword(String traceId, String encodedPass) {
|
||||
Long appNumber = dao.savePassword(traceId, encodedPass);
|
||||
saveAuditStatusByTraceId(traceId, ACCEPTED.name());
|
||||
return appNumber;
|
||||
}
|
||||
|
||||
public boolean userExists(String login){
|
||||
return dao.userExists(login);
|
||||
}
|
||||
|
||||
public void saveAcceptedStatus(String traceId) {
|
||||
dao.saveAcceptedStatus(traceId);
|
||||
public Long saveAcceptedStatus(String traceId) {
|
||||
Long appNumber = dao.saveAcceptedStatus(traceId);
|
||||
saveAuditStatusByTraceId(traceId, ACCEPTED.name());
|
||||
return appNumber;
|
||||
}
|
||||
|
||||
public void saveAgreedStatus(long appNumber) {
|
||||
dao.saveAgreedStatus(appNumber);
|
||||
}
|
||||
|
||||
public void saveError(String traceId, String errorMsg) {
|
||||
dao.saveError(traceId, errorMsg);
|
||||
public Long saveError(String traceId, String errorMsg) {
|
||||
Long appNumber = dao.saveError(traceId, errorMsg);
|
||||
saveAuditStatusByTraceId(traceId, AGREED.name());
|
||||
return appNumber;
|
||||
}
|
||||
|
||||
private void saveAuditStatusByTraceId(String traceId, String status) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import {AnalyticalScope, Behavior, GridV2, NotNull} from "@webbpm/base-package";
|
||||
import {StatusUpdateService} from "../../../modules/app/service/status-update.service";
|
||||
import {Subscription} from "rxjs";
|
||||
import {OnDestroy} from "@angular/core";
|
||||
|
||||
@AnalyticalScope(GridV2)
|
||||
export class RowUpdateService extends Behavior implements OnDestroy {
|
||||
|
||||
@NotNull()
|
||||
public statusColId: string;
|
||||
|
||||
private updateService: StatusUpdateService;
|
||||
private subscription: Subscription;
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
let grid = this.getScript(GridV2);
|
||||
this.updateService = this.injector.get(StatusUpdateService);
|
||||
this.subscription = this.updateService.statusMessage.subscribe(value => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
grid.gridApi.forEachNode(rowNode => {
|
||||
if (rowNode.id == value.appNumber) {
|
||||
let rowData = rowNode.data;
|
||||
rowData[this.statusColId] = value.status;
|
||||
rowNode.updateData(rowData);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy} from "@angular/core";
|
||||
import {AuthorizationService} from "../service/authorization.service";
|
||||
import {WebsocketService} from "../websocket/websocket.service";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {StatusUpdateService} from "../service/status-update.service";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
|
|
@ -15,7 +15,8 @@ export class AppHeaderComponent implements OnDestroy {
|
|||
realm: string;
|
||||
|
||||
constructor(protected authService: AuthorizationService, protected cd: ChangeDetectorRef,
|
||||
protected websocketService: WebsocketService, protected httpClient: HttpClient) {
|
||||
protected websocketService: WebsocketService,
|
||||
protected statusUpdateService: StatusUpdateService) {
|
||||
authService.onSessionUpdate
|
||||
.subscribe(session => {
|
||||
this.name = session.name;
|
||||
|
|
@ -28,8 +29,7 @@ export class AppHeaderComponent implements OnDestroy {
|
|||
|
||||
if (parsedObj && parsedObj.traceId) {
|
||||
if (parsedObj.className === 'update' || parsedObj.className === 'processError') {
|
||||
this.httpClient.put('status', parsedObj).toPromise()
|
||||
.catch(err => console.log('failed to update application status', err));
|
||||
this.statusUpdateService.update(parsedObj);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
28
frontend/src/ts/modules/app/service/status-update.service.ts
Normal file
28
frontend/src/ts/modules/app/service/status-update.service.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {BehaviorSubject} from "rxjs";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
|
||||
enum ApplicationStatus {
|
||||
AGREED = 'Согласована',
|
||||
ACCEPTED = 'Исполнена'
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class StatusUpdateService {
|
||||
|
||||
constructor(private httpClient: HttpClient) {
|
||||
}
|
||||
|
||||
public statusMessage = new BehaviorSubject<any>(null);
|
||||
|
||||
public update(responseObj: any): void {
|
||||
this.httpClient.put<number>('status', responseObj)
|
||||
.toPromise()
|
||||
.then(appNumber => this.statusMessage.next(
|
||||
{
|
||||
appNumber: appNumber,
|
||||
status: responseObj.className === 'update' ? ApplicationStatus.ACCEPTED : ApplicationStatus.AGREED
|
||||
}))
|
||||
.catch(err => console.log('failed to update application status', err));
|
||||
}
|
||||
}
|
||||
|
|
@ -4832,6 +4832,22 @@
|
|||
</entry>
|
||||
</properties>
|
||||
</scripts>
|
||||
<scripts id="f1c2e3ed-5672-4ef9-844c-71ba5e0f36ba">
|
||||
<classRef type="TS">
|
||||
<className>RowUpdateService</className>
|
||||
<packageName>account_applications.component.grid</packageName>
|
||||
</classRef>
|
||||
<enabled>true</enabled>
|
||||
<expanded>true</expanded>
|
||||
<properties>
|
||||
<entry>
|
||||
<key>statusColId</key>
|
||||
<value>
|
||||
<simple>"user_application_list$application_status"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</properties>
|
||||
</scripts>
|
||||
<children id="695a9110-b72a-4abe-99bc-66166b5fa864">
|
||||
<prototypeId>364c8faa-5e56-46cd-9203-d2ec6ef2dc74</prototypeId>
|
||||
<componentRootId>695a9110-b72a-4abe-99bc-66166b5fa864</componentRootId>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue