From 6a44eae292a75260ee00b6702bf1100a2c57cf14 Mon Sep 17 00:00:00 2001 From: dashaun Date: Sat, 27 Jan 2024 01:18:01 -0600 Subject: [PATCH] add dateVal --- src/main/java/com/javagrunt/service/youtube/YouTubeVideo.java | 1 + .../com/javagrunt/service/youtube/YouTubeVideoController.java | 3 ++- src/main/resources/schema.sql | 3 ++- .../java/com/javagrunt/service/youtube/AbstractAppTests.java | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/javagrunt/service/youtube/YouTubeVideo.java b/src/main/java/com/javagrunt/service/youtube/YouTubeVideo.java index 61a3b0f..eff4bd8 100644 --- a/src/main/java/com/javagrunt/service/youtube/YouTubeVideo.java +++ b/src/main/java/com/javagrunt/service/youtube/YouTubeVideo.java @@ -16,4 +16,5 @@ public class YouTubeVideo { private String title; private String thumbnail; private String date; + private long dateVal; } diff --git a/src/main/java/com/javagrunt/service/youtube/YouTubeVideoController.java b/src/main/java/com/javagrunt/service/youtube/YouTubeVideoController.java index 79429d1..c66b49b 100644 --- a/src/main/java/com/javagrunt/service/youtube/YouTubeVideoController.java +++ b/src/main/java/com/javagrunt/service/youtube/YouTubeVideoController.java @@ -1,6 +1,7 @@ package com.javagrunt.service.youtube; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Sort; import org.springframework.web.bind.annotation.*; @RestController @@ -15,7 +16,7 @@ public YouTubeVideoController(YouTubeVideoRepository youTubeVideoRepository) { @GetMapping public Iterable findAll() { - return youTubeVideoRepository.findAll(); + return youTubeVideoRepository.findAll(Sort.by("dateVal").descending()); } @GetMapping(value = "/{id}") diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 5dad09b..b12e163 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -5,5 +5,6 @@ CREATE TABLE IF NOT EXISTS you_tube_video description text, title varchar(255), thumbnail varchar(255), - date varchar(255) + date varchar(255), + date_val bigint ); \ No newline at end of file diff --git a/src/test/java/com/javagrunt/service/youtube/AbstractAppTests.java b/src/test/java/com/javagrunt/service/youtube/AbstractAppTests.java index cc12e29..4974bbc 100644 --- a/src/test/java/com/javagrunt/service/youtube/AbstractAppTests.java +++ b/src/test/java/com/javagrunt/service/youtube/AbstractAppTests.java @@ -166,7 +166,8 @@ private String youTubeVideoJson() { "description": "the description", "title": "the title", "thumbnail": "the thumbnail", - "date": "the date" + "date": "the date", + "dateVal": 1234567890 } """; }