Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add content getter and setter, and update post endpoint #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/com/liatrio/dojo/devopsknowledgeshareapi/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,14 @@ public boolean validatePostLink(String postLink) {
String pattern = "\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
return postLink.matches(pattern);
}

public Object getContent() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getContent'");
}

public void setContent(Object content) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setContent'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ public void deletePost(@PathVariable("id") String id) {
log.info("{}: recieved a DELETE request", deploymentType);
repository.deleteById(Long.parseLong(id));
}

@PutMapping("/posts/{id}")
public Post updatePost(@PathVariable("id") String id, @RequestBody Post post) {
log.info("{}: received a PUT request", deploymentType);
Post existingPost = repository.findById(Long.parseLong(id)).orElseThrow();
existingPost.setTitle(post.getTitle());
existingPost.setContent(post.getContent());
return repository.save(existingPost);
}
}
Loading