feat: architecture DDD hexagonale + tooling Vite/TypeScript
Migration complète du monolithe vers une architecture en couches : - Domain : entités, value objects, services purs, ports - Application : CQRS avec CommandBus/QueryBus, 15+ commandes, 9 requêtes - Tooling : Vite + TypeScript strict + Vitest + path aliases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
32
src/application/commands/UpdateWorkflow.ts
Normal file
32
src/application/commands/UpdateWorkflow.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { AppState, StateRepository } from '@domain/ports/StateRepository';
|
||||
import type { WorkflowItem } from '@application/queries/GetWorkflows';
|
||||
|
||||
export interface UpdateWorkflowCommand {
|
||||
type: 'update-workflow';
|
||||
workflowId: number;
|
||||
materialIdx?: number;
|
||||
stepIdx?: number;
|
||||
crossingIdx?: number;
|
||||
done: number;
|
||||
}
|
||||
|
||||
export function createUpdateWorkflowHandler(state: AppState, repo: StateRepository) {
|
||||
return (cmd: UpdateWorkflowCommand): void => {
|
||||
const workflows = state.workflows as WorkflowItem[];
|
||||
const wf = workflows.find(w => w.id === cmd.workflowId);
|
||||
if (!wf) return;
|
||||
|
||||
if (cmd.materialIdx !== undefined) {
|
||||
const mat = wf.materials[cmd.materialIdx];
|
||||
if (mat) mat.done = Math.max(0, cmd.done);
|
||||
} else if (cmd.stepIdx !== undefined && cmd.crossingIdx !== undefined) {
|
||||
const step = wf.steps[cmd.stepIdx];
|
||||
if (step) {
|
||||
const crossing = step.crossings[cmd.crossingIdx];
|
||||
if (crossing) crossing.done = Math.max(0, cmd.done);
|
||||
}
|
||||
}
|
||||
|
||||
repo.save(state);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user