Skip to content

Commit

Permalink
Merge pull request #54 from LetsCareer-A/feat/#53
Browse files Browse the repository at this point in the history
#53 [feat] 4.7 지원공고 상태 수정
  • Loading branch information
pkl0912 authored Sep 3, 2024
2 parents 9311270 + b245bde commit 684ba15
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum SuccessCode {
SELF_INTRO_SAVE_SUCCESS(HttpStatus.CREATED, "자기소개 추가 성공"),
APPEAL_CAREERS_ADD_SUCCESS(HttpStatus.CREATED, "어필할 커리어 추가 성공"),
STAGE_ADD_SUCCESS(HttpStatus.CREATED, "전형 단계 추가 성공"),
STAGE_UPDATE_SUCCESS(HttpStatus.OK, "전형 단계 상태 변경 성공");
STAGE_UPDATE_SUCCESS(HttpStatus.OK, "전형 단계 상태 변경 성공"),
UPDATE_SCHEDULE_PROGRESS_SUCCESS(HttpStatus.OK, "일정 진행 상태 변경 성공"),;

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.example.letscareer.common.exception.model.BadRequestException;
import com.example.letscareer.common.exception.model.NotFoundException;
import com.example.letscareer.schedule.dto.request.SchedulePostRequest;
import com.example.letscareer.schedule.dto.request.UpdateScheduleProgressRequest;
import com.example.letscareer.schedule.dto.response.*;
import com.example.letscareer.schedule.service.ScheduleService;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -100,4 +101,18 @@ public ApiResponse postNewSchedule(
return ErrorResponse.error(e.getErrorCode());
}
}

@PutMapping("/{scheduleId}/progress")
public ApiResponse updateScheduleProgress(
@RequestHeader("userId") Long userId,
@PathVariable Long scheduleId,
@RequestBody UpdateScheduleProgressRequest request
){
try{
scheduleService.updateScheduleProgress(userId, scheduleId, request);
return SuccessNonDataResponse.success(SuccessCode.UPDATE_SCHEDULE_PROGRESS_SUCCESS);
}catch (NotFoundException | BadRequestException e) {
return ErrorResponse.error(e.getErrorCode());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.letscareer.schedule.dto.request;

import com.example.letscareer.schedule.domain.Progress;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;

public record UpdateScheduleProgressRequest(
@Enumerated(EnumType.STRING)
Progress progress
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.example.letscareer.schedule.domain.Schedule;
import com.example.letscareer.schedule.dto.*;
import com.example.letscareer.schedule.dto.request.SchedulePostRequest;
import com.example.letscareer.schedule.dto.request.UpdateScheduleProgressRequest;
import com.example.letscareer.schedule.dto.response.*;
import com.example.letscareer.schedule.repository.ScheduleRepository;
import com.example.letscareer.stage.domain.Stage;
Expand All @@ -25,6 +26,7 @@
import java.time.Period;
import java.util.*;

import static com.example.letscareer.common.exception.enums.ErrorCode.SCHEDULE_NOT_FOUND_EXCEPTION;
import static com.example.letscareer.common.exception.enums.ErrorCode.USER_NOT_FOUND_EXCEPTION;

@Service
Expand Down Expand Up @@ -349,6 +351,19 @@ public void postSchedule(Long userId,SchedulePostRequest request){
}

}

@Transactional
public void updateScheduleProgress(Long userId, Long scheduleId, UpdateScheduleProgressRequest request) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
Schedule schedule = scheduleRepository.findByUserAndScheduleId(user, scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));

schedule.setProgress(request.progress());
scheduleRepository.save(schedule);
}


private int calculateDday(LocalDate deadline) {
int dday = Period.between(LocalDate.now(), deadline).getDays();
return dday;
Expand Down

0 comments on commit 684ba15

Please sign in to comment.