Skip to content

Commit

Permalink
Merge branch 'develop' into be/fix/#244
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwanghyeon-k committed Jan 28, 2025
2 parents 848e1e0 + 35a1735 commit 8d89c35
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ public class BookmarkController {

@Operation(summary = "북마크 등록", description = "관심있는 이력서를 북마크로 등록합니다.")
@PostMapping("/{resume_id}")
public CommonResponse<BookmarkResponse> addBookmark(
@PathVariable("resume_id") Long resumeId) {

public CommonResponse<BookmarkResponse> addBookmark(@PathVariable("resume_id") Long resumeId) {
User user = userService.getLoginUser();

Bookmark bookmark = bookmarkService.addBookmark(user, resumeId);
BookmarkResponse bookmarkResponse = BookmarkConverter.toBookmarkResponse(bookmark);

return CommonResponse.of(SuccessCode.CREATED, bookmarkResponse);
BookmarkResponse response = BookmarkConverter.toBookmarkResponse(bookmark);

return CommonResponse.of(SuccessCode.OK, response);
}

@Operation(summary = "북마크 삭제", description = "북마크를 해제합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public static BookmarkResponse toBookmarkResponse(Bookmark bookmark) {
return BookmarkResponse.builder()
.bookmarkId(bookmark.getId())
.resumeId(bookmark.getResume().getId())
.resumeTitle(bookmark.getResume().getName())
.resumeAuthor(bookmark.getResume().getUser().getUsername())
.createdAt(bookmark.getResume().getCreatedAt())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.techeer.backend.api.bookmark.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -10,7 +11,9 @@
@AllArgsConstructor
@ToString
public class BookmarkResponse {
private final Long bookmarkId;
private final Long resumeId;
private final Long userId;
private final Long bookmarkId;
private final Long resumeId;
private final String resumeTitle;
private final String resumeAuthor;
private final LocalDateTime createdAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public class BookmarkService {

@Transactional
public Bookmark addBookmark(User user, Long resumeId) {

Resume resume = resumeRepository.findById(resumeId)
.orElseThrow(() -> new BusinessException(ErrorCode.RESUME_NOT_FOUND));

Bookmark bookmark = BookmarkConverter.toBookmarkEntity(user, resume);

return bookmarkRepository.save(bookmark);
}


@Transactional
public void removeBookmark(User user, Long bookmarkId) {

Expand All @@ -50,5 +50,4 @@ public void removeBookmark(User user, Long bookmarkId) {
public List<Bookmark> getBookmarksByUserId(Long userId) {
return bookmarkRepository.findAllByUserId(userId);
}

}
Loading

0 comments on commit 8d89c35

Please sign in to comment.