Skip to content

Commit

Permalink
Merge branch 'feat/#10-resumesPOST' into feat/#13-resumeGET
Browse files Browse the repository at this point in the history
  • Loading branch information
chaentopia committed May 18, 2024
2 parents b2088f6 + 9ca4040 commit 4177969
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .idea/jpa-buddy.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions jumpit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ build/
!**/src/test/**/build/
*.yaml

*.yaml

### STS ###
.apt_generated
.classpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public enum ErrorMessage {
SEARCH_FAILED(HttpStatus.BAD_REQUEST.value(), "[ERROR] 채용 공고 검색에 실패하였습니다."),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR.value(), "[ERROR] 서버 내부 오류가 발생하였습니다."),
COMPANY_NOT_FOUND_BY_ID_EXCEPTION(HttpStatus.NOT_FOUND.value(), "[ERROR] ID에 해당하는 기업이 없습니다."),
SKILL_NOT_FOUND_BY_ID_EXCEPTION(HttpStatus.NOT_FOUND.value(), "[ERROR] ID에 해당하는 기술스택이 없습니다.")
SKILL_NOT_FOUND_BY_ID_EXCEPTION(HttpStatus.NOT_FOUND.value(), "[ERROR] ID에 해당하는 기술스택이 없습니다."),
USER_NOT_FOUND_BY_ID_EXCEPTION(HttpStatus.NOT_FOUND.value(), "[ERROR] ID에 해당하는 유저를 찾을 수 없습니다.")
;

private final int status;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sopt.jumpit.resume.controller;


import lombok.RequiredArgsConstructor;
import org.sopt.jumpit.global.common.dto.SuccessResponse;
import org.sopt.jumpit.resume.dto.ResumeCreateRequest;
import org.sopt.jumpit.resume.service.ResumeService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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 java.net.URI;

@RestController
@RequestMapping("/api/v1/resumes")
@RequiredArgsConstructor
public class ResumeController {
private final ResumeService resumeService;

@PostMapping
public ResponseEntity<SuccessResponse> createResume (
@RequestBody ResumeCreateRequest resumeCreateRequest
) {
resumeService.createResume(resumeCreateRequest);
return ResponseEntity.ok()
.build();
}
}
15 changes: 15 additions & 0 deletions jumpit/src/main/java/org/sopt/jumpit/resume/domain/Resume.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.sopt.jumpit.resume.domain;

import jakarta.persistence.*;
import lombok.Builder;
import org.sopt.jumpit.resume.dto.ResumeCreateRequest;
import org.sopt.jumpit.user.domain.User;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -28,4 +30,17 @@ public class Resume {
@Column(name = "createdAt")
private LocalDateTime createdAt;

@Builder
private Resume(User owner, String title) {
this.owner = owner;
this.title = title;
this.isPrivate = false;
}

public static Resume create(User owner, String title) {
return Resume.builder()
.title(title)
.owner(owner)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.jumpit.resume.dto;

public record ResumeCreateRequest(
String title,
Long userId
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sopt.jumpit.resume.service;

import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.sopt.jumpit.global.common.dto.message.ErrorMessage;
import org.sopt.jumpit.global.exception.BusinessException;
import org.sopt.jumpit.resume.domain.Resume;
import org.sopt.jumpit.resume.dto.ResumeCreateRequest;
import org.sopt.jumpit.resume.repository.ResumeRepository;
import org.sopt.jumpit.user.domain.User;
import org.sopt.jumpit.user.repository.UserRepository;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ResumeService {
private final ResumeRepository resumeRepository;
private final UserRepository userRepository;

@Transactional
public void createResume(
ResumeCreateRequest resumeCreateRequest
) {
User findUser = userRepository.findById(resumeCreateRequest.userId()).orElseThrow(
() -> new BusinessException(ErrorMessage.USER_NOT_FOUND_BY_ID_EXCEPTION)
);
Resume resume = Resume.create(findUser, "내 이력서");
resumeRepository.save(resume);
}
}

0 comments on commit 4177969

Please sign in to comment.