Skip to content

Commit

Permalink
feat : 이력서 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SIWON990327 committed Nov 21, 2024
1 parent 4be5842 commit 07fa424
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum ErrorCode {
NOT_FOUND_LOGIN_USER(40401, HttpStatus.NOT_FOUND, "로그인한 사용자가 존재하지 않습니다."),
NOT_FOUND_AUTHORIZATION_HEADER(40401, HttpStatus.NOT_FOUND, "Authorization 헤더가 존재하지 않습니다."),
NOT_FOUND_MEMBER(40402, HttpStatus.NOT_FOUND, "해당 사용자가 존재하지 않습니다."),
NOT_FOUND_RESUME(40403, HttpStatus.BAD_REQUEST, "해당 이력이 존재하지 않습니다."),

// Invalid Argument Error
MISSING_REQUEST_PARAMETER(40000, HttpStatus.BAD_REQUEST, "필수 요청 파라미터가 누락되었습니다."),
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/com/groom/orbit/resume/app/ResumeCommendService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import org.springframework.transaction.annotation.Transactional;

import com.groom.orbit.common.dto.CommonSuccessDto;
import com.groom.orbit.common.exception.CommonException;
import com.groom.orbit.common.exception.ErrorCode;
import com.groom.orbit.member.app.MemberQueryService;
import com.groom.orbit.member.dao.jpa.entity.Member;
import com.groom.orbit.resume.app.dto.CreateResumeRequestDto;
import com.groom.orbit.resume.app.dto.ResumeRequestDto;
import com.groom.orbit.resume.dao.ResumeRepository;
import com.groom.orbit.resume.dao.entity.Resume;

Expand All @@ -20,18 +22,23 @@ public class ResumeCommendService {
private final ResumeRepository resumeRepository;
private final MemberQueryService memberQueryService;

public CommonSuccessDto createResume(Long memberId, CreateResumeRequestDto request) {
public CommonSuccessDto createResume(Long memberId, ResumeRequestDto request) {

Member member = memberQueryService.findMember(memberId);

resumeRepository.save(request.toResume(member));

return CommonSuccessDto.fromEntity(true);
}

public CommonSuccessDto updateResume(Long resumeId, ResumeRequestDto requestDto) {

Resume resume =
Resume.builder()
.resumeCategory(request.resumeCategory())
.content(request.content())
.startDate(request.startDate())
.endDate(request.endDate())
.member(member)
.build();
resumeRepository
.findById(resumeId)
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_RESUME));

resume.updateResume(requestDto);

resumeRepository.save(resume);

Expand Down

This file was deleted.

22 changes: 22 additions & 0 deletions src/main/java/com/groom/orbit/resume/app/dto/ResumeRequestDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.groom.orbit.resume.app.dto;

import java.util.Date;

import com.groom.orbit.member.dao.jpa.entity.Member;
import com.groom.orbit.resume.dao.entity.Resume;
import com.groom.orbit.resume.dao.entity.ResumeCategory;

public record ResumeRequestDto(
ResumeCategory resumeCategory, String title, String content, Date startDate, Date endDate) {

public Resume toResume(Member member) {
return Resume.builder()
.resumeCategory(this.resumeCategory)
.title(this.title)
.content(this.content)
.startDate(this.startDate)
.endDate(this.endDate)
.member(member)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.groom.orbit.resume.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import com.groom.orbit.common.annotation.AuthMember;
import com.groom.orbit.common.dto.CommonSuccessDto;
import com.groom.orbit.common.dto.ResponseDto;
import com.groom.orbit.resume.app.ResumeCommendService;
import com.groom.orbit.resume.app.dto.CreateResumeRequestDto;
import com.groom.orbit.resume.app.dto.ResumeRequestDto;

import lombok.RequiredArgsConstructor;

Expand All @@ -22,7 +19,15 @@ public class ResumeCommandController {

@PostMapping()
public ResponseDto<CommonSuccessDto> createResume(
@AuthMember Long memberId, @RequestBody CreateResumeRequestDto requestDto) {
@AuthMember Long memberId, @RequestBody ResumeRequestDto requestDto) {
return ResponseDto.ok(resumeCommandService.createResume(memberId, requestDto));
}

@PatchMapping("/{resumeId}")
public ResponseDto<CommonSuccessDto> updateResume(
@AuthMember Long memberId,
@PathVariable Long resumeId,
@RequestBody ResumeRequestDto requestDto) {
return ResponseDto.ok(resumeCommandService.updateResume(resumeId, requestDto));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.groom.orbit.resume.dao;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import com.groom.orbit.resume.dao.entity.Resume;

public interface ResumeRepository extends JpaRepository<Resume, Long> {}
public interface ResumeRepository extends JpaRepository<Resume, Long> {

Optional<Resume> findById(Long resumeId);
}
12 changes: 12 additions & 0 deletions src/main/java/com/groom/orbit/resume/dao/entity/Resume.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jakarta.persistence.*;

import com.groom.orbit.member.dao.jpa.entity.Member;
import com.groom.orbit.resume.app.dto.ResumeRequestDto;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -28,6 +29,9 @@ public class Resume {
@Enumerated(EnumType.STRING)
private ResumeCategory resumeCategory;

@Column(name = "title")
private String title;

@Column(name = "content")
private String content;

Expand All @@ -40,4 +44,12 @@ public class Resume {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;

public void updateResume(ResumeRequestDto requestDto) {
this.resumeCategory = requestDto.resumeCategory();
this.title = requestDto.title();
this.content = requestDto.content();
this.startDate = requestDto.startDate();
this.endDate = requestDto.endDate();
}
}

0 comments on commit 07fa424

Please sign in to comment.