Skip to content

Commit

Permalink
Rapport de patrouille - connect export controller to usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Mar 13, 2024
1 parent 3ad07d8 commit ea6f70f
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package fr.gouv.dgampa.rapportnav.infrastructure.bff

import fr.gouv.dgampa.rapportnav.domain.entities.mission.MissionActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export.MissionExportEntity
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.*
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.FakeMissionData
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetEnvMissions
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetMissionById
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetNavMissionById
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.export.ExportMission
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.AddOrUpdateMissionGeneralInfo
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.GetMissionGeneralInfoByMissionId
Expand All @@ -19,7 +22,6 @@ import org.springframework.graphql.data.method.annotation.SchemaMapping
import org.springframework.stereotype.Controller
import java.time.ZoneId
import java.time.ZonedDateTime
import java.util.*


@Controller
Expand All @@ -32,6 +34,7 @@ class MissionController(
private val addOrUpdateMissionGeneralInfo: AddOrUpdateMissionGeneralInfo,
private val getControlUnitsForUser: GetControlUnitsForUser,
private val fakeMissionData: FakeMissionData,
private val exportMission: ExportMission
) {

private val logger = LoggerFactory.getLogger(MissionController::class.java)
Expand Down Expand Up @@ -104,12 +107,11 @@ class MissionController(
@QueryMapping
fun missionExport(@Argument missionId: Int): MissionExportEntity {
try {
val fileContent = null
if (fileContent != null) {
val encodedFileContent = Base64.getEncoder().encodeToString(fileContent)
val file = exportMission.exportOdt(missionId)
if (file != null) {
return MissionExportEntity(
fileName = "rapport-de-patrouille-$missionId.odt",
fileContent = encodedFileContent
fileContent = file.fileContent
)
} else {
throw RuntimeException("Error - can't send rapport de patrouille to client as it is null")
Expand Down

0 comments on commit ea6f70f

Please sign in to comment.