diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 4e2fb75..43b130b 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/com/example/SeaReaUrl_back/FraudController.java b/src/main/java/com/example/SeaReaUrl_back/FraudController.java index 81ba58b..4e9c774 100644 --- a/src/main/java/com/example/SeaReaUrl_back/FraudController.java +++ b/src/main/java/com/example/SeaReaUrl_back/FraudController.java @@ -15,12 +15,13 @@ public class FraudController { @GetMapping("/account/view") public Top5Response getTop5AccountView(){ - return fraudService.getTop5AccountView(); +// return fraudService.getTop5AccountView(); + return fraudService.getTop5AccountAndView(); + } + @GetMapping("/url/view") + public Top5Response getTop5UrlView(){ + return fraudService.getTop5AccountAndView(); } -// @GetMapping("/url/view") -// public Top5Response getTop5UrlView(){ -// return fraudService.getTop5UrlView(); -// } // @GetMapping("/account/report") // public Top5Response getTop5AccountReports(){ // return fraudService.getTop5AccountReports(); diff --git a/src/main/java/com/example/SeaReaUrl_back/FraudService.java b/src/main/java/com/example/SeaReaUrl_back/FraudService.java index d3a4132..6592d78 100644 --- a/src/main/java/com/example/SeaReaUrl_back/FraudService.java +++ b/src/main/java/com/example/SeaReaUrl_back/FraudService.java @@ -22,13 +22,37 @@ public class FraudService { private final FraudAccountRepository fraudAccountRepository; private final FraudUrlRepository fraudUrlRepository; +// @Transactional +// public Top5Response getTop5AccountView() { +// List top5Accounts = fraudAccountRepository.findTop5ByOrderByViewDesc(); +// List top5AccountResponses = top5Accounts.stream() +// .map(Top5AccountResponse::new) +// .collect(Collectors.toList()); +// return new Top5Response(top5AccountResponses); +// } +// +// @Transactional +// public Top5Response getTop5UrlView(){ +// List top5Urls = fraudUrlRepository.findTop5ByOrderByViewDesc(); +// List top5UrlResponses = top5Urls.stream() +// .map(Top5UrlResponse::new) +// .collect(Collectors.toList()); +// return new Top5Response(top5UrlResponses); +// } + @Transactional - public Top5Response getTop5AccountView() { + public Top5Response getTop5AccountAndView() { List top5Accounts = fraudAccountRepository.findTop5ByOrderByViewDesc(); List top5AccountResponses = top5Accounts.stream() .map(Top5AccountResponse::new) .collect(Collectors.toList()); - return new Top5Response(top5AccountResponses); + + List top5Urls = fraudUrlRepository.findTop5ByOrderByViewDesc(); + List top5UrlResponses = top5Urls.stream() + .map(Top5UrlResponse::new) + .collect(Collectors.toList()); + + return new Top5Response(top5AccountResponses, top5UrlResponses); } // private Top5Response convertToTop5Response(List top5Accounts) { @@ -44,10 +68,7 @@ public Top5Response getTop5AccountView() { // public Top5Response getTop5AccountView(){ // return new Top5Response(); // } -// @Transactional -// public Top5Response getTop5UrlView(){ -// return new Top5Response(); -// } + // @Transactional // public Top5Response getTop5AccountReports(){ // return new Top5Response(); diff --git a/src/main/java/com/example/SeaReaUrl_back/FraudUrlRepository.java b/src/main/java/com/example/SeaReaUrl_back/FraudUrlRepository.java index edd14be..3b51168 100644 --- a/src/main/java/com/example/SeaReaUrl_back/FraudUrlRepository.java +++ b/src/main/java/com/example/SeaReaUrl_back/FraudUrlRepository.java @@ -2,5 +2,8 @@ import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + public interface FraudUrlRepository extends JpaRepository { + List findTop5ByOrderByViewDesc(); } diff --git a/src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.java b/src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.java index 6a30e3a..4fa8ebd 100644 --- a/src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.java +++ b/src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.java @@ -7,14 +7,14 @@ @AllArgsConstructor public class Top5AccountResponse { private Long id; - private String url; + private String accountName; private Boolean isFraud; private Long view; private Long report; public Top5AccountResponse(FraudAccount account) { this.id = account.getId(); - this.url = account.getAccountName(); + this.accountName = account.getAccountName(); this.isFraud = account.getIsFraud(); this.view = account.getView(); this.report = account.getReport(); diff --git a/src/main/java/com/example/SeaReaUrl_back/Top5Response.java b/src/main/java/com/example/SeaReaUrl_back/Top5Response.java index 64507d9..bcb984c 100644 --- a/src/main/java/com/example/SeaReaUrl_back/Top5Response.java +++ b/src/main/java/com/example/SeaReaUrl_back/Top5Response.java @@ -14,30 +14,15 @@ public class Top5Response { private List top5Accounts; + private List top5Urls; - public Top5Response(List top5Accounts) { + public Top5Response(List top5Accounts, List top5Urls) { this.top5Accounts = top5Accounts; + this.top5Urls = top5Urls; } -// private List top5Accounts; -// -// public Top5Response(List top5Accounts) { -// this.top5Accounts = top5Accounts; -// } -// -// public List getTop5Accounts() { -// return top5Accounts; -// } -// private Long id; -// private String url; -// private Boolean IsFraud; -// private Long view; -// private Long report; -// -// public static Top5Response { -// return Top5Response.builder() -// .id() -// .build(); +// public Top5Response(List top5Urls) { +// this.top5Urls = top5Urls; // } } diff --git a/src/main/java/com/example/SeaReaUrl_back/Top5UrlResponse.java b/src/main/java/com/example/SeaReaUrl_back/Top5UrlResponse.java new file mode 100644 index 0000000..ca8b8e9 --- /dev/null +++ b/src/main/java/com/example/SeaReaUrl_back/Top5UrlResponse.java @@ -0,0 +1,22 @@ +package com.example.SeaReaUrl_back; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class Top5UrlResponse { + private Long id; + private String url; + private Boolean isFraud; + private Long view; + private Long report; + + public Top5UrlResponse(FraudUrl url) { + this.id = url.getId(); + this.url = url.getUrl(); + this.isFraud = url.getIsFraud(); + this.view = url.getView(); + this.report = url.getReport(); + } +}