Skip to content

Commit

Permalink
Refactor : Controller, Service 주석 설명 추가
Browse files Browse the repository at this point in the history
1. Controller, Service 주석 설명 추가
2. ServiceImpl의 log.info 제거
  • Loading branch information
daydeuk committed Apr 17, 2023
1 parent c9bfef4 commit 3a7311a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public SingleResult<CommitResponseDto> checkDateUserCommit(@RequestParam Long us
return responseService.getSingleResult(challengeService.checkDateUserCommit(userId, selectDate));
}

/** 신대득
/**
* @author 신대득
* 현재 user가 참가중인 챌린지 개수 반환
*/
@GetMapping("/challengeInfo/users/{userId}")
Expand All @@ -112,7 +113,8 @@ public SingleResult<UserChallengeInfoResponseDto> userChallengeInfo(@PathVariabl
}

/**
* 스케줄링으로 실행되는 메서드의 테스트
* @author 신대득
* 스케줄러로 실행되는 일일 기록 저장의 테스트 API
* @return
*/
@GetMapping("/test/record")
Expand All @@ -121,6 +123,11 @@ public Result testRecord (){
return responseService.getSuccessResult();
}

/**
* @author 신대득
* 스케줄러로 실행되는 일일 정산의 테스트 API
* @return
*/
@GetMapping("/test/payment")
public Result testPayment (){
challengeService.culcDailyPayment();
Expand All @@ -135,6 +142,12 @@ public String updateDefaultImage(@RequestParam("file") MultipartFile multipartFi
return s3Service.upload(multipartFile,dir);
}

/**
* @author 신대득
* 챌린지내에서 1등부터 차례대로 랭킹을 반환하는 API
* @param challengeId : 검색할 챌린지의 방 id
* @return
*/
@GetMapping("baekjoon/rank/{challengeId}")
public ListResult<RankResponseDto> getTopRank(@PathVariable String challengeId){
return responseService.getListResult(challengeService.getTopRank(Long.parseLong(challengeId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class CommitController {
* 신대득
* 유저 깃허브 아이디를 통해 해당 유저의 커밋 찾기 (크롤링)
* 나온 결과를 계산해서 user에 넣어줘야한다.
* Todo : 반환 타입 등 다시 만들 예정
* Todo : userId로 commit 가져오는걸로 바꾸기
*/
@GetMapping("/github/{githubId}")
public SingleResult<CommitCountResponseDto> getGithubList(@PathVariable("githubId") String githubId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

public interface ChallengeService {



/** 깃허브 커밋 리스트 찾기 **/
CommitCountResponseDto getGithubCommit(String githubId);
/** 푼 문제 리스트 찾기 **/
Expand All @@ -25,22 +23,27 @@ public interface ChallengeService {
void updateChallengeRoom(Long challengeRoomId);
/** 해당 유저가 해당 날짜에 푼 알고리즘 리스트 조회 **/
SolvedListResponseDto checkDateUserBaekjoon(Long userId, String selectDate);
/** 해당 유저가 해당 날짜에 커밋한 개수를 조회 **/
CommitResponseDto checkDateUserCommit(Long userId, String selectDate);
/** 해당 유저가 최근 5일 동안 푼 문제를 조회 **/
SolvedMapResponseDto getRecentUserBaekjoon(Long userId);
/** 해당 유저가 최근 5일 동안의 커밋 개수 조회 **/
SolvedMapResponseDto getRecentUserCommit(Long userId);

/** 스케줄러 저장 메서드 **/
void createDailyRecord();
/** 알고리즘 인증 기록 생성하기 **/
void createAlgoRecord(ChallengeRecordRequestDto requestDto) throws IOException;

/** 해당 방의 하루 정산 **/
void oneDayCulc(ChallengeRoom challengeRoom);
/** 하루정산을 시키는 스케줄러 **/
void culcDailyPayment();
/** 유저의 커밋리스트 업데이트 **/
void updateUserCommit(Long userId);
/** 커밋 인증 기록을 저장 **/
void createCommitRecord(ChallengeRecordRequestDto requestDto);
/** 나의 현재 진행상황 보기 **/
ProgressResponseDto getProgressUserBaekjoon(Long userId, Long challengeId);

/** 챌린지내에서 1등부터 차례대로 랭킹을 반환 **/
List<RankResponseDto> getTopRank(Long challengeId);
/** 유저가 선택한 챌린지에 대한 증명서 정보를 반환하는 메서드 **/
CertificationResponseDto getCertification(Long userId, Long challengeRoomId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public SolvedListResponseDto solvedProblemList(String baekjoonId) {
solvedList.add(problem.text());
count++;
}
log.info("총 %d 문제 풀이하셨습니다\n", count);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -118,11 +117,9 @@ public void updateChallengeRoom(Long challengeRoomId){
}

/** 유저의 백준리스트 업데이트
* Todo : 예외처리 추가
* **/
public void updateUserBaekjoon(Long userId){
SingleResult<UserResponseDto> userResponseDtoTemp = userServiceClient.getUserInfo(userId);
log.info("userResponseDto is : {}",userResponseDtoTemp);
UserResponseDto userResponseDto=userResponseDtoTemp.getData();
SingleResult<BaekjoonListResponseDto> baekjoonListResponseDto = userServiceClient.getUserBaekjoonList(userResponseDto.getUserId());

Expand All @@ -146,21 +143,17 @@ public void updateUserBaekjoon(Long userId){
userServiceClient.createProblem(userId, ProblemRequestDto.from(diffSolvedList));
}

/** 유저의 커밋리스트 업데이트
* Todo : 예외처리 추가
* **/
/** 유저의 커밋리스트 업데이트 **/
public void updateUserCommit(Long userId) {
SingleResult<UserResponseDto> userResponseDtoTemp = userServiceClient.getUserInfo(userId);
UserResponseDto userResponseDto = userResponseDtoTemp.getData();

String today = commonService.getDate();
// 오늘 날짜의 유저의 커밋 수 조회
CommitCountResponseDto commitCountResponseDto=getGithubCommit(userResponseDto.getGithub());
log.info("commitCountResponseDto is : {}", commitCountResponseDto);

// if(commitCountResponseDto.getCommitCount()==0){
// return;
// }
if(commitCountResponseDto.getCommitCount()==0){
return;
}
userServiceClient.updateCommitCount(userResponseDto.getUserId(), new CommitRequestDto(today, commitCountResponseDto.getCommitCount()));
}

Expand Down Expand Up @@ -217,7 +210,6 @@ public SolvedMapResponseDto getRecentUserBaekjoon(Long userId) {
public SolvedMapResponseDto getRecentUserCommit(Long userId) {
String today=commonService.getDate();
String pastDay=commonService.getPastDay(5, today);
log.info("today is {} , pastDay is {}", today, pastDay);
List<CommitResponseDto> dateCommitList = userServiceClient.getDateCommitList(userId, pastDay, today).getData();

Map<String, Integer> myMap = new HashMap<>();
Expand All @@ -234,9 +226,6 @@ public SolvedMapResponseDto getRecentUserCommit(Long userId) {
* **/
@Scheduled(cron = "0 50 23 * * ?") // 매일 오후 11시 50분
public void createDailyRecord(){
log.info("createDailyRecord 시작");
// 현재 진행중인 UserChallenge 중에 Category가 ALGO인 것들을 조회해서 저장시킨다.

String today=commonService.getDate();

// 현재 진행중인 알고리즘 챌린지 리스트 조회
Expand All @@ -259,11 +248,9 @@ public void createDailyRecord(){
/**
* 신대득
* 하루정산 시키기 (1일전 인증기록을 통해서)
*
*/
@Scheduled(cron = "0 1 0 * * ?") // 매일 오후 0시 1분
public void culcDailyPayment(){
log.info("culcDailyPayment 시작");
List<ChallengeRoom> challengingRoomList = challengeRoomRepository.findChallengingRoomByDate(commonService.getPastDay(0,commonService.getDate()));
for(ChallengeRoom challengeRoom: challengingRoomList){
oneDayCulc(challengeRoom);
Expand All @@ -278,8 +265,6 @@ public void culcDailyPayment(){
@Override
@Transactional
public void createAlgoRecord(ChallengeRecordRequestDto requestDto) {

log.info("챌린지id " + requestDto.getChallengeRoomId() + "유저아이디id" + requestDto.getUserId());
ChallengeRoom challengeRoom = basicChallengeService.getChallengeRoomEntity(requestDto.getChallengeRoomId());

UserResponseDto user = userServiceClient.getUserInfo(requestDto.getUserId()).getData();
Expand Down Expand Up @@ -333,7 +318,6 @@ public void createCommitRecord(ChallengeRecordRequestDto requestDto) {

UserChallenge userChallenge = userChallengeRepository.findByChallengeRoomIdAndUserId(requestDto.getChallengeRoomId(), requestDto.getUserId())
.orElseThrow(() -> new ApiException(ExceptionEnum.USER_CHALLENGE_NOT_EXIST_EXCEPTION));
log.info("[userChallenge id값]" + userChallenge.getId());


Optional<ChallengeRecord> commitRecordResponseDto = challengeRecordRepository.findByCreateAtAndUserChallenge(date, userChallenge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class SchedulerServiceImpl implements SchedulerService{
private final CommonService commonService;
@Override
public void endChallengeCalculate() {


payServiceClient.requestChallengeSettlement(new ChallengeSettlementRequest(challengeRoomRepository.findClosedChallengeUser(commonService.getPastDay(0,commonService.getDate()))));
}
}

0 comments on commit 3a7311a

Please sign in to comment.