Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 새 기능 : 이력서 삭제 추가 및 SwaggerUI 형식에 맞게 에러 어노테이션 수정 #196

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ResumeController {
description = "이력서 생성 시 객체 리스트에 존재하는 값만 validation check"
)
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations(CommonExceptionCode.BAD_REQUEST)
@ExceptionCodeAnnotations(CommonExceptionCode.NOT_FOUND_USER)
@PostMapping(value = "")
public CreateResumeResponse createResume(@Valid @RequestBody CreateResumeRequest request, @AuthenticationPrincipal CustomUserDetails user) {

Expand All @@ -58,7 +58,7 @@ public CreateResumeResponse createResume(@Valid @RequestBody CreateResumeRequest
description = "이력서 수정 시 객체 리스트에 존재하는 값 체크"
)
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations(CommonExceptionCode.BAD_REQUEST)
@ExceptionCodeAnnotations({CommonExceptionCode.NOT_FOUND_USER, CommonExceptionCode.NOT_MATCH_RESUME_USERID, CommonExceptionCode.FILE_NOT_FOUND_ERROR})
@PatchMapping("")
public UpdateResumeResponse updateResume(@SwaggerRequestBody(description = "이력서 수정 정보", content = @Content(
schema = @Schema(implementation = UpdateResumeRequest.class)
Expand All @@ -71,6 +71,8 @@ public UpdateResumeResponse updateResume(@SwaggerRequestBody(description = "이
summary = "이력서 전체 조회",
description = "사용자 이력서 전체 조회"
)
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations(CommonExceptionCode.JOB_INFO_NOT_FOUND)
@GetMapping("/search")
public Page<SearchResumeResponse> searchResume(@Parameter(description = "검색어") @RequestParam(value = "search", required = false) String search, @Parameter(description = "Size : 페이지당 출력할 항목의 개수 (기본값: 10) \n sort`: 정렬 기준 필드 (기본값: `modifyDate`) \n direction`: 정렬 순서 (기본값: 내림차순 `DESC`)") @PageableDefault(size = 10, sort = "modifyDate", direction = Sort.Direction.DESC) Pageable pageable) {
List<SearchResumeResponse> searchResumeResponses = resumeReadService.searchResumeInfos(search, pageable);
Expand All @@ -82,9 +84,23 @@ public Page<SearchResumeResponse> searchResume(@Parameter(description = "검색
summary = "이력서 상세 조화",
description = "사용자 상세 조회"
)
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations({CommonExceptionCode.NOT_MATCH_RESUME_USERID, CommonExceptionCode.NOT_FOUND_RESUME})
@GetMapping("/details/{id}")
public GetResumeDetailsResponse getResumeDetails(@Parameter(description = "이력서 아이디", example = "1") @PathVariable Long id, @AuthenticationPrincipal CustomUserDetails user) {
return resumeReadService.getResumeDetails(id, user);
}

@Operation(
summary = "이력서 삭제",
description = "해당 사용자 이력서를 삭제한다."
)
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations({CommonExceptionCode.NOT_FOUND_USER, CommonExceptionCode.NOT_MATCH_RESUME_USERID})
@DeleteMapping("{id}")
public String deleteResume(@Parameter(description = "이력서 아이디", example = "1") @PathVariable Long id, @AuthenticationPrincipal CustomUserDetails user) {
service.delete(id, user);
return "성공";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import darkoverload.itzip.feature.resume.domain.resume.Resume;
import darkoverload.itzip.feature.resume.service.resume.port.resume.ResumeRepository;
import darkoverload.itzip.global.config.response.code.CommonExceptionCode;
import darkoverload.itzip.global.config.response.exception.RestApiException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

Expand All @@ -24,8 +22,8 @@ public Resume update(Resume resume) {
}

@Override
public Resume findById(long id) {
return repository.findById(id).orElseThrow(() -> new RestApiException(CommonExceptionCode.NOT_FOUND_RESUME)).convertToDomain();
public void delete(Resume resume) {
repository.delete(resume.toEntity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public interface ResumeService {

UpdateResumeResponse update(UpdateResumeRequest request, CustomUserDetails user);

void delete(Long id, CustomUserDetails user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import darkoverload.itzip.feature.resume.service.resume.port.myskill.MySkillCommandRepository;
import darkoverload.itzip.feature.resume.service.resume.port.qualification.QualificationReadRepository;
import darkoverload.itzip.feature.resume.service.resume.port.qualification.QualificationCommandRepository;
import darkoverload.itzip.feature.resume.service.resume.port.resume.ResumeReadRepository;
import darkoverload.itzip.feature.resume.service.resume.port.resume.ResumeRepository;
import darkoverload.itzip.feature.user.entity.UserEntity;
import darkoverload.itzip.feature.user.repository.UserRepository;
import darkoverload.itzip.global.config.response.code.CommonExceptionCode;
import darkoverload.itzip.global.config.response.exception.RestApiException;
Expand All @@ -59,6 +61,7 @@ public class ResumeServiceImpl implements ResumeService {

private final UserRepository userRepository;
private final ResumeRepository resumeRepository;
private final ResumeReadRepository resumeReadRepository;

private final EducationCommandRepository educationCommandRepository;
private final EducationReadRepository educationReadRepository;
Expand Down Expand Up @@ -159,19 +162,29 @@ private ResumeDetails create(CreateResumeRequest request, Resume resume) {


@Override
public UpdateResumeResponse update(UpdateResumeRequest request, CustomUserDetails customUserDetails) {
long dataUserId = userRepository.findByEmail(customUserDetails.getEmail()).orElseThrow(() -> new RestApiException(CommonExceptionCode.NOT_FOUND_USER)).getId();
public UpdateResumeResponse update(UpdateResumeRequest request, CustomUserDetails user) {
long dataUserId = userRepository.findByEmail(user.getEmail()).orElseThrow(() -> new RestApiException(CommonExceptionCode.NOT_FOUND_USER)).getId();

Resume.checkUserIdEquals(request.getUserId(), dataUserId);

Resume updateResume = Resume.update(request.getResume(), request.getResumeId(), request.getUserId());

Resume databaseResume = resumeRepository.findById(request.getResumeId());
Resume databaseResume = resumeReadRepository.getReferenceById(request.getResumeId());
awsService.deleteDocumentFiles(updateResume.notExistFileUrls(databaseResume.getFileUrls()), Resume.FEATURE_DIR);

return UpdateResumeResponse.from(update(request, resumeRepository.update(updateResume)));
}

@Override
public void delete(Long id, CustomUserDetails user) {
long dataUserId = userRepository.findByEmail(user.getEmail()).orElseThrow(() -> new RestApiException(CommonExceptionCode.NOT_FOUND_USER)).getId();

Resume resume = resumeReadRepository.getReferenceById(id).checkIdNull();
Resume.checkUserIdEquals(resume.getUserId(), dataUserId);

resumeRepository.delete(resume);
}

/**
* 제공된 업데이트 요청을 기반으로 이력서 세부 정보를 업데이트합니다.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public interface ResumeRepository {

Resume update(Resume resume);

Resume findById(long id);
void delete(Resume resume);

}
Loading