Skip to content

implements #54: implements note service - #86

Merged
alexander-wudy merged 2 commits into
mainfrom
feature/54-crud-for-notes
Jul 10, 2026
Merged

implements #54: implements note service#86
alexander-wudy merged 2 commits into
mainfrom
feature/54-crud-for-notes

Conversation

@alexander-wudy

Copy link
Copy Markdown
Collaborator

Note Service Implementation

This PR implements the core backend features and integration tests for the Note Service, making it ready for production.

Highlights

  • Core CRUD & Auditing: Completed all CRUD operations with automatic creation and modification timestamping.
  • Security & Ownership: Secured all API endpoints using JWT authentication and enforced strict ownership checks so users can only access their own notes.
  • Database & Indexing: Created the initial database schema with non-null constraints and added database indexing on owner queries for optimized performance.
  • OpenAPI Compliance & Tests: Added 21 integration tests validating that all controller endpoints conform strictly to the OpenAPI schema.

@alexander-wudy alexander-wudy self-assigned this Jul 8, 2026
@alexander-wudy alexander-wudy linked an issue Jul 8, 2026 that may be closed by this pull request

@w-richter w-richter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review — Note Service implementation


// Specific mappers

Note toNote(CreateNoteRequest request, long userId);

@w-richter w-richter Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note toNote(CreateNoteRequest request, long userId) has no explicit @Mapping for userId. Relies on implicit parameter-name matching that breaks silently if the parameter is renamed.

private final NoteMapper mapper;

@Override
public CreateNoteResponse createNote(CreateNoteRequest request, long userId) {

@w-richter w-richter Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write methods (createNote, updateNote, deleteNote) are not annotated with @Transactional. repository.save() commits before the subsequent mapper call, and entities loaded via getNoteEntity() may detach between findById() and save()/delete().

@alexander-wudy alexander-wudy Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added @Transactional(readOnly = true) to read methods. Thanks for the heads up


public record IllegalAccessPair(long ownerId, long noteId) {

@Override

@w-richter w-richter Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalAccessPair.toString() is dead code. The parent constructor builds its message from pair.noteId and pair.ownerId directly, never calling toString().

Comment thread api/note-service.yaml
required:
- title
- content
CreateNoteResponse:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateNoteResponse, GetNoteResponse, and UpdateNoteResponse wrap IdentifiedTimestampedNote in allOf with an empty type: object that adds no constraints.

private Long userId;

@Column(nullable = false)
private String title;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title column is VARCHAR(255) in Liquibase and content is TEXT, but the entity has no Bean Validation annotations (@Size, @NotBlank). A title exceeding 255 characters would produce a database constraint violation (500) instead of a validation error (400). Consider adding @Size(max = 255) on title and @NotBlank on both fields in a follow-up.

private Long userId;

@Column(nullable = false)
private String title;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title column is VARCHAR(255) in Liquibase and content is TEXT, but the entity has no Bean Validation annotations (@Size, @NotBlank). A title exceeding 255 characters would produce a database constraint violation (500) instead of a validation error (400). Consider adding @Size(max = 255) on title and @NotBlank on both fields in a follow-up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description should be able to be left blank, in case someone just wants to set some title to a note

@w-richter

Copy link
Copy Markdown
Collaborator

lgtm now

@alexander-wudy
alexander-wudy merged commit 5555d6b into main Jul 10, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRUD for notes

3 participants