Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…eaurl_back into feat/#1

# Conflicts:
#	build/classes/java/main/com/example/SeaReaUrl_back/FraudAccount.class
#	build/tmp/compileJava/previous-compilation-data.bin
#	src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.java
  • Loading branch information
born2slayy committed Nov 11, 2023
2 parents 44b5ad9 + 91f49ab commit bbd835b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 33 deletions.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
11 changes: 6 additions & 5 deletions src/main/java/com/example/SeaReaUrl_back/FraudController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/com/example/SeaReaUrl_back/FraudService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,37 @@ public class FraudService {
private final FraudAccountRepository fraudAccountRepository;
private final FraudUrlRepository fraudUrlRepository;

// @Transactional
// public Top5Response getTop5AccountView() {
// List<FraudAccount> top5Accounts = fraudAccountRepository.findTop5ByOrderByViewDesc();
// List<Top5AccountResponse> top5AccountResponses = top5Accounts.stream()
// .map(Top5AccountResponse::new)
// .collect(Collectors.toList());
// return new Top5Response(top5AccountResponses);
// }
//
// @Transactional
// public Top5Response getTop5UrlView(){
// List<FraudUrl> top5Urls = fraudUrlRepository.findTop5ByOrderByViewDesc();
// List<Top5UrlResponse> top5UrlResponses = top5Urls.stream()
// .map(Top5UrlResponse::new)
// .collect(Collectors.toList());
// return new Top5Response(top5UrlResponses);
// }

@Transactional
public Top5Response getTop5AccountView() {
public Top5Response getTop5AccountAndView() {
List<FraudAccount> top5Accounts = fraudAccountRepository.findTop5ByOrderByViewDesc();
List<Top5AccountResponse> top5AccountResponses = top5Accounts.stream()
.map(Top5AccountResponse::new)
.collect(Collectors.toList());
return new Top5Response(top5AccountResponses);

List<FraudUrl> top5Urls = fraudUrlRepository.findTop5ByOrderByViewDesc();
List<Top5UrlResponse> top5UrlResponses = top5Urls.stream()
.map(Top5UrlResponse::new)
.collect(Collectors.toList());

return new Top5Response(top5AccountResponses, top5UrlResponses);
}

// private Top5Response convertToTop5Response(List<FraudAccount> top5Accounts) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface FraudUrlRepository extends JpaRepository<FraudUrl, Long> {
List<FraudUrl> findTop5ByOrderByViewDesc();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 5 additions & 20 deletions src/main/java/com/example/SeaReaUrl_back/Top5Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,15 @@
public class Top5Response {

private List<Top5AccountResponse> top5Accounts;
private List<Top5UrlResponse> top5Urls;

public Top5Response(List<Top5AccountResponse> top5Accounts) {
public Top5Response(List<Top5AccountResponse> top5Accounts, List<Top5UrlResponse> top5Urls) {
this.top5Accounts = top5Accounts;
this.top5Urls = top5Urls;
}

// private List<FraudAccount> top5Accounts;
//
// public Top5Response(List<FraudAccount> top5Accounts) {
// this.top5Accounts = top5Accounts;
// }
//
// public List<FraudAccount> 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<Top5UrlResponse> top5Urls) {
// this.top5Urls = top5Urls;
// }

}
22 changes: 22 additions & 0 deletions src/main/java/com/example/SeaReaUrl_back/Top5UrlResponse.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit bbd835b

Please # to comment.