diff --git a/pom.xml b/pom.xml index 569769b..771e1be 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,10 @@ 5.10.0 test + + org.springframework.boot + spring-boot-starter-actuator + @@ -68,5 +72,4 @@ - diff --git a/src/main/java/com/ad/markalive/controller/BookmarkController.java b/src/main/java/com/ad/markalive/controller/BookmarkController.java index 221bdc1..7369a08 100644 --- a/src/main/java/com/ad/markalive/controller/BookmarkController.java +++ b/src/main/java/com/ad/markalive/controller/BookmarkController.java @@ -20,8 +20,8 @@ public List 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){ diff --git a/src/main/java/com/ad/markalive/model/Bookmark.java b/src/main/java/com/ad/markalive/model/Bookmark.java index 3c22436..3b2f17d 100644 --- a/src/main/java/com/ad/markalive/model/Bookmark.java +++ b/src/main/java/com/ad/markalive/model/Bookmark.java @@ -1,6 +1,8 @@ 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 @@ -8,9 +10,21 @@ public class Bookmark { 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; @@ -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; + } } diff --git a/src/main/java/com/ad/markalive/service/BookmarkService.java b/src/main/java/com/ad/markalive/service/BookmarkService.java index 36bb026..c77e744 100644 --- a/src/main/java/com/ad/markalive/service/BookmarkService.java +++ b/src/main/java/com/ad/markalive/service/BookmarkService.java @@ -21,9 +21,8 @@ public List 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){ diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index dff1205..7e3dd8a 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -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) );