Skip to content

Commit

Permalink
Merge pull request #82 from minseok1015/dev
Browse files Browse the repository at this point in the history
build : yml 파일 dev 추가
  • Loading branch information
minseok1015 authored Aug 12, 2024
2 parents ed2efc0 + 7d25266 commit 33e9474
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public enum BaseExceptionResponseStatus implements ResponseStatus {
* 8000: Reference 오류
*/
INVALID_REFERENCE(8000,HttpStatus.BAD_REQUEST.value(),"잘못된 관련자료 요청입니다"),
EMPTY_REFERENCE(8001,HttpStatus.BAD_REQUEST.value(),"관련자료가 비어있습니다");
NO_Search_REFERENCE(8001,HttpStatus.BAD_REQUEST.value(),"관련자료를 뉴스에서 검색하지 못하였습니다"),

EMPTY_REFERENCE(8002,HttpStatus.BAD_REQUEST.value(),"해당 키워드의 관련자료를 찾지 못하였습니다");






Expand Down
14 changes: 4 additions & 10 deletions src/main/java/store/itpick/backend/controller/RankController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import store.itpick.backend.common.exception.ReferenceException;
import store.itpick.backend.common.response.BaseErrorResponse;
import store.itpick.backend.common.response.BaseResponse;
import store.itpick.backend.common.response.status.ResponseStatus;
Expand All @@ -22,7 +23,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.BAD_REQUEST;
import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.*;

@RestController
@RequestMapping("/rank")
Expand All @@ -45,9 +46,6 @@ public RankController(RankService rankService) {
@Autowired
private KeywordService keywordService;

@Autowired
private SchedulerService schedulerService;


// 최대 재시도 횟수와 재시도 간격 (초)
private static final int MAX_RETRIES = 5;
Expand Down Expand Up @@ -99,8 +97,7 @@ public BaseResponse<RankResponseDTO> getReference(
RankResponseDTO rankResponse = rankService.getReferenceByKeyword(community, period, keyword);

if (rankResponse == null) {
// 키워드가 없거나 커뮤니티/기간이 없을 경우 적절한 응답 처리
return new BaseResponse<>(null);
throw new ReferenceException(EMPTY_REFERENCE);
}

return new BaseResponse<>(rankResponse);
Expand All @@ -121,10 +118,7 @@ public void updateZum() {
keywordService.performDailyTasksZum();
}

@GetMapping("/update")
public void update() {
schedulerService.performHourlyTasks();
}


@GetMapping("/naver")
public List<Reference> getRankFromSignal() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/store/itpick/backend/service/RankService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;
import java.util.Optional;

import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.EMPTY_REFERENCE;
import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.NO_Search_REFERENCE;


//관련자료 조회하는 Service
Expand Down Expand Up @@ -71,7 +71,7 @@ public RankResponseDTO getReferenceByKeyword(String community, String period, St
}
private void isValidReference(String newsTitle){
if(newsTitle.equals("No search")){
throw new ReferenceException(EMPTY_REFERENCE);
throw new ReferenceException(NO_Search_REFERENCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.TimeoutException;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -18,6 +19,7 @@
@Slf4j
@Component
@RequiredArgsConstructor
@Profile("!local") // 'localDB' 프로파일에서는 이 빈이 로드되지 않습니다.
public class SchedulerService {

private final SeleniumService seleniumService;
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ spring:
url: ${DATASOURCE_URL_DEV}?serverTimezone=Asia/Seoul
username: ${DATASOURCE_USERNAME}
password: ${DATASOURCE_PASSWORD}
# url: jdbc:h2:tcp://localhost/~/itpick
# username: sa
## password:
driver-class-name: com.mysql.cj.jdbc.Driver
dbcp2:
validation-query: select 1
# hikari:
# driver-class-name: org.h2.Driver
sql:
init:
platform: mysql
Expand All @@ -80,6 +85,22 @@ spring:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
mail:
host: smtp.gmail.com
port: 587
username: ${MAIL_USERNAME}
password: ${MAIL_PASSWORD}
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
connectiontimeout: 5000
timeout: 5000
writetimeout: 5000
auth-code-expiration-millis: 1800000

---

Expand Down

0 comments on commit 33e9474

Please sign in to comment.