Skip to content

Commit

Permalink
add dateVal
Browse files Browse the repository at this point in the history
  • Loading branch information
dashaun committed Jan 27, 2024
1 parent 714bf2a commit 6a44eae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public class YouTubeVideo {
private String title;
private String thumbnail;
private String date;
private long dateVal;
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,7 +16,7 @@ public YouTubeVideoController(YouTubeVideoRepository youTubeVideoRepository) {

@GetMapping
public Iterable<YouTubeVideo> findAll() {
return youTubeVideoRepository.findAll();
return youTubeVideoRepository.findAll(Sort.by("dateVal").descending());
}

@GetMapping(value = "/{id}")
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ private String youTubeVideoJson() {
"description": "the description",
"title": "the title",
"thumbnail": "the thumbnail",
"date": "the date"
"date": "the date",
"dateVal": 1234567890
}
""";
}
Expand Down

0 comments on commit 6a44eae

Please sign in to comment.