Skip to content

Commit

Permalink
adding log message in app service and controller class
Browse files Browse the repository at this point in the history
  • Loading branch information
varunkumar139 committed Mar 5, 2025
1 parent 1b1387f commit 2479200
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.resource

import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
Expand All @@ -22,6 +23,10 @@ import java.util.*
@RequestMapping("v1")
class AppController(var appService: AppService) {

companion object {
private val logger = LoggerFactory.getLogger(AppController::class.java)
}

@PostMapping(
"prisoners/{prisoner-id}/apps",
produces = [MediaType.APPLICATION_JSON_VALUE],
Expand All @@ -34,6 +39,7 @@ class AppController(var appService: AppService) {
authentication: Authentication,
): ResponseEntity<AppResponseDto> {
authentication as AuthAwareAuthenticationToken
logger.info("Request received for submitting app for $prisonerId by ${authentication.principal}")
val appResponseDto = appService.submitApp(prisonerId, authentication.principal, appRequestDto)
return ResponseEntity.status(HttpStatus.CREATED).body(appResponseDto)
}
Expand All @@ -49,6 +55,8 @@ class AppController(var appService: AppService) {
@RequestParam(required = false) assignedGroup: Boolean,
authentication: Authentication,
): ResponseEntity<AppResponseDto> {
authentication as AuthAwareAuthenticationToken
logger.info("Request received for get app for $prisonerId by ${authentication.principal}")
val appResponseDto = appService.getAppsById(prisonerId, id, requestedBy, assignedGroup)
return ResponseEntity.status(HttpStatus.OK).body(appResponseDto)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.service

import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.stereotype.Service
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.dto.AppRequestDto
Expand All @@ -12,6 +13,7 @@ import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.AppType
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.Prisoner
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.Staff
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.repository.AppRepository
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.resource.AppController
import java.time.LocalDateTime
import java.util.*

Expand All @@ -22,6 +24,10 @@ class AppServiceImpl(
var staffService: StaffService,
) : AppService {

companion object {
private val logger = LoggerFactory.getLogger(AppController::class.java)
}

fun saveApp(app: App): App = appRepository.save(app)

fun updateApp(app: App): App = appRepository.save(app)
Expand Down Expand Up @@ -57,6 +63,7 @@ class AppServiceImpl(
null,
null,
)
logger.info("App created for $prisonerId for app type ${app.appType}")
return convertAppToAppResponseDto(prisonerId, app, prisonerId, assignedGroup)
}

Expand Down

0 comments on commit 2479200

Please sign in to comment.