fase(5): findings module complete
Some checks failed
ABE Exploratory Testing / explore (push) Has been cancelled
Some checks failed
ABE Exploratory Testing / explore (push) Has been cancelled
This commit is contained in:
35
dist/modules/findings/application/commands/ResolveFindingCommand.js
vendored
Normal file
35
dist/modules/findings/application/commands/ResolveFindingCommand.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ResolveFindingCommand = void 0;
|
||||
const Result_1 = require("../../../../shared/domain/Result");
|
||||
class ResolveFindingCommand {
|
||||
constructor(repository, eventBus) {
|
||||
this.repository = repository;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
async execute(request) {
|
||||
const finding = await this.repository.findById(request.findingId);
|
||||
if (!finding) {
|
||||
return (0, Result_1.Err)(`Finding not found: ${request.findingId}`);
|
||||
}
|
||||
switch (request.action) {
|
||||
case 'resolve':
|
||||
finding.resolve();
|
||||
break;
|
||||
case 'close':
|
||||
finding.close();
|
||||
break;
|
||||
case 'investigate':
|
||||
finding.investigate();
|
||||
break;
|
||||
}
|
||||
await this.repository.update(finding);
|
||||
const events = finding.domainEvents;
|
||||
for (const event of events) {
|
||||
await this.eventBus.publish(event);
|
||||
}
|
||||
finding.clearEvents();
|
||||
return (0, Result_1.Ok)({ findingId: finding.id.toString(), status: finding.status.value });
|
||||
}
|
||||
}
|
||||
exports.ResolveFindingCommand = ResolveFindingCommand;
|
||||
Reference in New Issue
Block a user