Skip to content

Commit

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

# Conflicts:
#	build.gradle
#	build/classes/java/main/com/example/SeaReaUrl_back/FraudAccount.class
#	build/tmp/compileJava/previous-compilation-data.bin
#	src/main/java/com/example/SeaReaUrl_back/FraudController.java
#	src/main/java/com/example/SeaReaUrl_back/FraudService.java
#	src/main/java/com/example/SeaReaUrl_back/Top5Response.java
  • Loading branch information
born2slayy committed Nov 11, 2023
2 parents be2e653 + ec6a5e4 commit 1e50d6b
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 37 deletions.
22 changes: 6 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,18 @@ repositories {
}

dependencies {
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-groovy-templates'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-mustache'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.session:spring-session-core'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.projectlombok:lombok:1.18.22'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'

implementation 'org.projectlombok:lombok'
testImplementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
}

tasks.named('bootBuildImage') {
Expand Down
Binary file not shown.
4 changes: 3 additions & 1 deletion build/resources/main/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ spring:
username: sa2
password:
jpa:

hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
show_sql: true
Expand All @@ -18,6 +19,7 @@ spring:
ansi:
enabled: always


# 파라미터 확인을 위한 trace
logging:
level:
Expand Down
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
8 changes: 2 additions & 6 deletions src/main/java/com/example/SeaReaUrl_back/FraudController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ public class FraudController {
private final FraudService fraudService;

@GetMapping("/account/view")
public List<Top5Response> getTop5AccountView(){
public Top5Response getTop5AccountView(){
return fraudService.getTop5AccountView();
}
@GetMapping("/hello")
public StringResponse test(){
return new StringResponse("hello");
}
// @GetMapping("/url/view")
// public Top5Response getTop5UrlView(){
// return fraudService.getTop5UrlView();
Expand Down Expand Up @@ -52,7 +48,7 @@ public StringResponse test(){
// public IsFraudAccountResponse checkAccountValidation(@RequestParam String accountName){
// return fraudService.checkAccountValidation(accountName);
// }
//




Expand Down
26 changes: 17 additions & 9 deletions src/main/java/com/example/SeaReaUrl_back/FraudService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,27 @@
@Service
@RequiredArgsConstructor
public class FraudService {

private final FraudUrlRepository fraudUrlRepository;
private final FraudAccountRepository fraudAccountRepository;
private final FraudUrlRepository fraudUrlRepository;

@Transactional
public List<Top5Response> getTop5AccountView() {
List<Top5Response> dtos = new ArrayList<>();
public Top5Response getTop5AccountView() {
List<FraudAccount> top5Accounts = fraudAccountRepository.findTop5ByOrderByViewDesc();
for (FraudAccount fraudAccount : top5Accounts){
dtos.add(new Top5Response(fraudAccount.getAccountName()));
}
return dtos;
List<Top5AccountResponse> top5AccountResponses = top5Accounts.stream()
.map(Top5AccountResponse::new)
.collect(Collectors.toList());
return new Top5Response(top5AccountResponses);
}

// private Top5Response convertToTop5Response(List<FraudAccount> top5Accounts) {
// List<Top5Response> responses = top5Accounts.stream()
// .map(account -> new Top5Response(account.getId(), account.getUrl(), account.getIsFraud(), account.getView(), account.getReport()))
// .collect(Collectors.toList());
//
// // 상위 5개의 계정을 담은 단일 Top5Response를 반환하려면
// return new Top5Response(responses);
// }

// @Transactional
// public Top5Response getTop5AccountView(){
// return new Top5Response();
Expand All @@ -51,7 +59,7 @@ public List<Top5Response> getTop5AccountView() {
// public StringResponse reportUrl(){
// return new StringResponse();
// }

//
// @Transactional
// public IsFraudUrlResponse checkUrlValidation(String url){
// List<String> responseList = new ArrayList<>();
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/example/SeaReaUrl_back/Top5AccountResponse.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 Top5AccountResponse {
private Long id;
private String url;
private Boolean isFraud;
private Long view;
private Long report;

public Top5AccountResponse(FraudAccount account) {
this.id = account.getId();
this.url = account.getUrl();
this.isFraud = account.getIsFraud();
this.view = account.getView();
this.report = account.getReport();
}
}
37 changes: 33 additions & 4 deletions src/main/java/com/example/SeaReaUrl_back/Top5Response.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
package com.example.SeaReaUrl_back;


import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Top5Response {
private String fraudName;

private List<Top5AccountResponse> top5Accounts;

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

// 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();
// }

}
4 changes: 3 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ spring:
username: sa2
password:
jpa:

hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
show_sql: true
Expand All @@ -18,6 +19,7 @@ spring:
ansi:
enabled: always


# 파라미터 확인을 위한 trace
logging:
level:
Expand Down

0 comments on commit 1e50d6b

Please # to comment.