Skip to content

Commit

Permalink
BE: [fix] 공지글 생성 후 postId 반환 CSID-DGU#83
Browse files Browse the repository at this point in the history
  • Loading branch information
Seoyoung2222 committed Dec 7, 2024
1 parent 277f796 commit 6595b98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class CrewController {
public ResponseEntity<Integer> createCrew(@RequestParam String title, @RequestPart MultipartFile certificationImage,@RequestPart MultipartFile profileImage) {
CrewCreateCommandDto crewCreateCommandDto = CrewCreateCommandDto.builder()
.title(title)
.certificationImage(certificationImage)
.profileImage(profileImage)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class NoticePostController {
@PostMapping
public ResponseEntity<Long> createNoticePost(@PathVariable Long crewId, @RequestBody NoticePostCreateRequestDto requestDto) {
User currentUser = authCommandService.getCurrentUser();
noticePostCommandService.createNoticePost(crewId, currentUser, requestDto);
return ResponseEntity.ok(crewId);
Long crewPostId = noticePostCommandService.createNoticePost(crewId, currentUser, requestDto);
return ResponseEntity.ok(crewPostId);
}

@GetMapping("/{crewPostId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NoticePostCommandService {
private final CrewRepository crewRepository;

@Transactional
public void createNoticePost(Long crewId, User user, NoticePostCreateRequestDto noticePostCreateRequestDto) {
public Long createNoticePost(Long crewId, User user, NoticePostCreateRequestDto noticePostCreateRequestDto) {
Crew crew = validateCrew(crewId);
validateLeader(crew, user);

Expand All @@ -34,7 +34,8 @@ public void createNoticePost(Long crewId, User user, NoticePostCreateRequestDto
.user(user)
.build();

crewPostRepository.save(crewPost);
CrewPost savedPost = crewPostRepository.save(crewPost);
return savedPost.getId();
}

private Crew validateCrew(Long crewId) {
Expand Down

0 comments on commit 6595b98

Please sign in to comment.