Skip to content

Commit

Permalink
Add actuator, two fields for Bookmark Model
Browse files Browse the repository at this point in the history
  • Loading branch information
adilk0728 committed Feb 21, 2024
1 parent ec5dbc7 commit b371174
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -68,5 +72,4 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public List<Bookmark> getAllBookmarks(){
return bookmarkService.getAllBookmarks();
}
@PostMapping("/bookmark")
public void addBookmark(@RequestParam String url){
bookmarkService.createBookmark(url);
public void addBookmark(@RequestBody Bookmark bookmark){
bookmarkService.createBookmark(bookmark);
}
@DeleteMapping("/bookmark")
public void deleteBookmark(@RequestParam int id){
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/com/ad/markalive/model/Bookmark.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
package com.ad.markalive.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import java.time.LocalDate;

public class Bookmark {
@Id
private int id;

private String url;

public Bookmark(String url) {
@Column("CREATED")
private LocalDate createdOn;
@Column("REMIND_AFTER_DAY")
private Integer remindAfter;

public Bookmark(){
}
public Bookmark(String url){
this.url = url;
}
public Bookmark(String url, LocalDate createdOn, Integer remindAfter) {
this(url);
this.createdOn = createdOn;
this.remindAfter = remindAfter;
}

public int getId() {
return id;
Expand All @@ -27,4 +41,20 @@ public String getUrl() {
public void setUrl(String url) {
this.url = url;
}

public LocalDate getCreatedOn() {
return createdOn;
}

public void setCreatedOn(LocalDate createdOn) {
this.createdOn = createdOn;
}

public Integer getRemindAfter() {
return remindAfter;
}

public void setRemindAfter(Integer remindAfter) {
this.remindAfter = remindAfter;
}
}
5 changes: 2 additions & 3 deletions src/main/java/com/ad/markalive/service/BookmarkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public List<Bookmark> getAllBookmarks(){
return bookmarkList;
}

public void createBookmark(String url){
Bookmark bookmarkToWrite = new Bookmark(url);
bookmarkRepository.save(bookmarkToWrite);
public void createBookmark(Bookmark bookmark){
bookmarkRepository.save(bookmark);
}

public void deleteBookmark(Integer id){
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
DROP TABLE IF EXISTS Bookmark;

CREATE TABLE IF NOT EXISTS Bookmark (
id int NOT NULL AUTO_INCREMENT,
url varchar(255) NOT NULL,
created date,
remind_after_day int,
PRIMARY KEY(id)
);

0 comments on commit b371174

Please sign in to comment.