Skip to content

Commit

Permalink
[feat] 메소드 PUT 으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
oosedus committed Sep 2, 2024
1 parent d09c7e2 commit f3ab993
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SelfIntroController {

private final SelfIntroService selfIntroService;

@PostMapping("/schedules/{scheduleId}/stages/{stageId}/self-intro")
@PutMapping("/schedules/{scheduleId}/stages/{stageId}/self-intro")
public ApiResponse saveSelfIntro(
@RequestHeader("userId") Long userId,
@PathVariable Long scheduleId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.example.letscareer.self_intro.repository;

import com.example.letscareer.self_intro.domain.SelfIntro;
import com.example.letscareer.stage.domain.Stage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface SelfIntroRepository extends JpaRepository<SelfIntro, Long> {
void deleteByStage(Stage stage);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.example.letscareer.common.exception.enums.ErrorCode.*;

@Service
Expand All @@ -37,7 +36,11 @@ public void saveSelfIntro(Long userId, Long scheduleId, Long stageId, SaveSelfIn
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));

for(SelfIntroDTO selfIntroDTO : request.selfIntros()) {
// 현재 stage에 있는 모든 SelfIntro를 삭제한다.
selfIntroRepository.deleteByStage(stage);

// 새로 들어온 자기소개서 항목을 저장한다.
for (SelfIntroDTO selfIntroDTO : request.selfIntros()) {
SelfIntro selfIntro = SelfIntro.builder()
.title(selfIntroDTO.title())
.sequence(selfIntroDTO.sequence())
Expand Down

0 comments on commit f3ab993

Please sign in to comment.