Skip to content

Commit

Permalink
UPDATE: id check
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremiahUy committed Oct 31, 2024
1 parent 0560881 commit 7db17ec
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public ResponseEntity<PvkDokumentResponse> getPvkDokumentByEtterlevelseDokumentI
@PostMapping
public ResponseEntity<PvkDokumentResponse> createPvkDokumente(@RequestBody PvkDokumentRequest request) {
log.info("Create PvkDokument");

var pvkDokument = pvkDokumentService.save(request.convertToPvkDokument(), request.isUpdate());

return new ResponseEntity<>(PvkDokumentResponse.buildFrom(pvkDokument), HttpStatus.CREATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public Optional<PvkDokument> getByEtterlevelseDokumentasjon(String etterlevelseD

@Transactional(propagation = Propagation.REQUIRED)
public PvkDokument save(PvkDokument pvkDokument, boolean isUpdate) {

if (!isUpdate) {
var existingPvkDokument = getByEtterlevelseDokumentasjon(pvkDokument.getEtterlevelseDokumentId());
if (existingPvkDokument.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public PvkDokument convertToPvkDokument() {
.build();

return PvkDokument.builder()
.id(id != null ? UUID.fromString(id) : null)
.id(id != null && !id.isEmpty() ? UUID.fromString(id) : null)
.etterlevelseDokumentId(etterlevelseDokumentId)
.status(status != null ? status : PvkDokumentStatus.AKTIV)
.pvkDokumentData(pkvDokumentData)
Expand Down

0 comments on commit 7db17ec

Please sign in to comment.