Selaa lähdekoodia

add createdBy to note response

Daniel Bohry 1 viikko sitten
vanhempi
sitoutus
943ef32f79

+ 5 - 0
src/main/java/com/lhamacorp/knotes/api/dto/NoteResponse.java

@@ -8,6 +8,7 @@ import java.time.Instant;
 public record NoteResponse(
         String id,
         String content,
+        String createdBy,
         Instant createdAt,
         Instant modifiedAt,
         EncryptionMode encryptionMode,
@@ -18,6 +19,7 @@ public record NoteResponse(
         return new NoteResponse(
                 note.id(),
                 note.content(),
+                note.createdBy(),
                 note.createdAt(),
                 note.modifiedAt(),
                 note.encryptionMode() != null ? note.encryptionMode() : EncryptionMode.PUBLIC,
@@ -29,6 +31,7 @@ public record NoteResponse(
         return new NoteResponse(
                 note.id(),
                 note.content(requestingUserId, null),
+                note.createdBy(),
                 note.createdAt(),
                 note.modifiedAt(),
                 note.encryptionMode() != null ? note.encryptionMode() : EncryptionMode.PUBLIC,
@@ -40,6 +43,7 @@ public record NoteResponse(
         return new NoteResponse(
                 note.id(),
                 note.content(null, password),
+                note.createdBy(),
                 note.createdAt(),
                 note.modifiedAt(),
                 note.encryptionMode() != null ? note.encryptionMode() : EncryptionMode.PUBLIC,
@@ -51,6 +55,7 @@ public record NoteResponse(
         return new NoteResponse(
                 note.id(),
                 note.content(requestingUserId, password),
+                note.createdBy(),
                 note.createdAt(),
                 note.modifiedAt(),
                 note.encryptionMode() != null ? note.encryptionMode() : EncryptionMode.PUBLIC,

+ 1 - 0
src/main/java/com/lhamacorp/knotes/service/NoteService.java

@@ -93,6 +93,7 @@ public class NoteService {
         return update(id, content, note.encryptionMode(), null);
     }
 
+    @CacheEvict(value = {"content", "metadata"}, key = "#id")
     public void delete(String id) {
         Note note = repository.findById(id).orElseThrow(() -> new NotFoundException("Note not found"));
         String userId = UserContextHolder.get().id();