-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎨 receive MQTT message to create consumption marking
- Loading branch information
Showing
3 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
server/src/shared/infra/mqtt/topics/CreateConsumptionMarkingTopic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { container } from 'tsyringe' | ||
|
||
import { CreateConsumptionMarkingUseCase } from '@modules/consumptionMarkings/useCases/createConsumptionMarking/CreateConsumptionMarkingUseCase' | ||
|
||
export class CreateConsumptionMarkingTopic { | ||
public async receiveMessage(message: string) { | ||
const [hydrometer_id, hydrometer_password, consumption] = message.split('|') | ||
|
||
const createConsumptionMarkingUseCase = container.resolve(CreateConsumptionMarkingUseCase) | ||
|
||
await createConsumptionMarkingUseCase.execute({ | ||
consumption: Number(consumption), | ||
hydrometer_id: Number(hydrometer_id), | ||
hydrometer_password, | ||
}) | ||
} | ||
} |