Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #70 from FinFellows/develop
Browse files Browse the repository at this point in the history
[DEPLOY]: 중간 배포
  • Loading branch information
sejineer authored Jan 8, 2024
2 parents 99a11d8 + d25e22f commit ab33ee6
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public class AuthController {
private final KakaoService kakaoService;


@Operation(summary = "카카오 code 발급", description = "카카오 API 서버에 접근 권한을 인가하는 code를 발급받습니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "code 발급 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = AuthRes.class))}),
@ApiResponse(responseCode = "400", description = "code 발급 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping(value = "/login")
public void socialLoginRedirect() throws IOException {
kakaoService.accessRequest();
}
// @Operation(summary = "카카오 code 발급", description = "카카오 API 서버에 접근 권한을 인가하는 code를 발급받습니다.")
// @ApiResponses(value = {
// @ApiResponse(responseCode = "200", description = "code 발급 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = AuthRes.class))}),
// @ApiResponse(responseCode = "400", description = "code 발급 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
// })
// @GetMapping(value = "/login")
// public void socialLoginRedirect() throws IOException {
// kakaoService.accessRequest();
// }

@Operation(summary = "유저 정보 확인", description = "현재 접속 중인 유저의 정보를 확인합니다.")
@ApiResponses(value = {
Expand Down Expand Up @@ -123,6 +123,7 @@ public ResponseCustom<?> deleteAccount(
@ApiResponse(responseCode = "200", description = "토큰 갱신 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = AuthRes.class) ) } ),
@ApiResponse(responseCode = "400", description = "토큰 갱신 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@PostMapping("/refresh")
public ResponseEntity<?> refresh(
@Parameter(description = "Schemas의 RefreshTokenReq를 참고해주세요.", required = true) @Valid @RequestBody RefreshTokenReq refreshTokenReq
) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.finfellows.domain.bookmark.application;

import com.finfellows.domain.bookmark.domain.EduContentBookmark;
import com.finfellows.domain.bookmark.domain.FinancialProductBookmark;
import com.finfellows.domain.bookmark.domain.repository.EduContentBookmarkRepository;
import com.finfellows.domain.bookmark.domain.repository.FinancialProductBookmarkRepository;
import com.finfellows.domain.bookmark.dto.EduContentBookmarkRes;
import com.finfellows.domain.bookmark.dto.FinancialProductBookmarkRes;
import com.finfellows.domain.product.domain.FinancialProduct;
import com.finfellows.domain.product.domain.repository.FinancialProductRepository;
import com.finfellows.domain.user.domain.User;
Expand All @@ -13,7 +11,6 @@
import com.finfellows.global.payload.Message;
import com.finfellows.global.payload.ResponseCustom;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -26,7 +23,6 @@ public class FinancialProductBookmarkServiceImpl implements BookmarkService{
private final FinancialProductBookmarkRepository financialProductBookmarkRepository;
private final UserRepository userRepository;
private final FinancialProductRepository financialProductRepository;
private final EduContentBookmarkRepository eduContentBookmarkRepository;


@Transactional
Expand Down Expand Up @@ -70,18 +66,18 @@ public Message delete(UserPrincipal userPrincipal, Long id) {
.build();
}

public ResponseCustom<List<EduContentBookmarkRes>> findBookmarks(UserPrincipal userPrincipal) {
public ResponseCustom<List<FinancialProductBookmarkRes>> findBookmarks(UserPrincipal userPrincipal) {
Optional<User> optionalUser = userRepository.findByEmail(userPrincipal.getEmail());

User user = optionalUser.get();

List<EduContentBookmark> bookmarks = eduContentBookmarkRepository.findAllByUser(user);
List<FinancialProductBookmark> bookmarks = financialProductBookmarkRepository.findAllByUser(user);


List<EduContentBookmarkRes> eduContentBookmarkResList = EduContentBookmarkRes.toDto(bookmarks);
List<FinancialProductBookmarkRes> financialProductBookmarkResList = FinancialProductBookmarkRes.toDto(bookmarks);


return ResponseCustom.OK(eduContentBookmarkResList);
return ResponseCustom.OK(financialProductBookmarkResList);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface EduContentBookmarkRepository extends JpaRepository<EduContentBo
Optional<EduContentBookmark> findByUserAndEduContent(User user, EduContent eduContent);

List<EduContentBookmark> findAllByUser(User user);

boolean existsByUser_IdAndEduContent_Id(Long userId, Long id);
}
15 changes: 0 additions & 15 deletions src/main/java/com/finfellows/domain/bookmark/dto/BookmarkRes.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.finfellows.domain.bookmark.presentation;

import com.finfellows.domain.bookmark.application.EduContentBookmarkServiceImpl;
import com.finfellows.domain.bookmark.application.FinancialProductBookmarkServiceImpl;
import com.finfellows.domain.bookmark.application.PolicyInfoBookmarkServiceImpl;
import com.finfellows.domain.bookmark.application.PostBookmarkServiceImpl;
Expand Down Expand Up @@ -28,7 +27,6 @@
@RestController
@RequestMapping("/bookmarks")
public class BookmarkController {
private final EduContentBookmarkServiceImpl eduContentBookmarkService;
private final FinancialProductBookmarkServiceImpl financialProductBookmarkService;
private final PolicyInfoBookmarkServiceImpl policyInfoBookmarkService;
private final PostBookmarkServiceImpl postBookmarkService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.finfellows.domain.educontent.application;

import com.finfellows.domain.bookmark.domain.repository.EduContentBookmarkRepository;
import com.finfellows.domain.educontent.domain.EduContent;
import com.finfellows.domain.educontent.domain.repository.EduContentRepository;
import com.finfellows.domain.educontent.dto.request.EduContentRequest;
Expand All @@ -20,6 +21,7 @@
public class EduContentService {
private final EduContentRepository eduContentRepository;
private final PostRepository postRepository;
private final EduContentBookmarkRepository eduContentBookmarkRepository;

@Transactional
public EduContent createEduContent(EduContentResponse request) {
Expand All @@ -38,13 +40,14 @@ public EduContent createEduContent(EduContentResponse request) {
return savedContent;
}

public List<EduContentResponse> getAllEduContents() {
public List<EduContentResponse> getAllEduContents(Long userId) {
List<EduContent> eduContents = eduContentRepository.findAll();
return eduContents.stream()
.map(eduContent -> EduContentResponse.builder()
.id(eduContent.getId())
.title(eduContent.getTitle())
.content(eduContent.getContent())
.bookmarked(checkBookmarked(userId, eduContent.getId()))
.build())
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -83,4 +86,9 @@ public EduContentResponse updateEduContent(Long id, EduContentRequest request) {
.content(updatedContent.getContent())
.build();
}


private boolean checkBookmarked(Long userId, Long eduContentId) {
return eduContentBookmarkRepository.existsByUser_IdAndEduContent_Id(userId, eduContentId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public class EduContentResponse {
private LocalDateTime created_at;
private String title;
private String content;
private boolean bookmarked;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.finfellows.domain.educontent.domain.EduContent;
import com.finfellows.domain.educontent.dto.request.EduContentRequest;
import com.finfellows.domain.educontent.dto.response.EduContentResponse;
import com.finfellows.global.config.security.token.CurrentUser;
import com.finfellows.global.config.security.token.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -39,8 +41,8 @@ public ResponseEntity<EduContent> saveEduContent(@RequestBody EduContentResponse
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = EduContentResponse.class)))
})
@GetMapping
public ResponseEntity<List<EduContentResponse>> getAllEduContents() {
List<EduContentResponse> responseList = eduContentService.getAllEduContents();
public ResponseEntity<List<EduContentResponse>> getAllEduContents(@CurrentUser UserPrincipal userPrincipal) {
List<EduContentResponse> responseList = eduContentService.getAllEduContents(userPrincipal.getId());
return new ResponseEntity<>(responseList, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.finfellows.domain.newscontent.application;

import com.finfellows.domain.bookmark.domain.repository.EduContentBookmarkRepository;
import com.finfellows.domain.educontent.domain.EduContent;
import com.finfellows.domain.newscontent.domain.NewsContent;
import com.finfellows.domain.newscontent.domain.repository.NewsContentRepository;
import com.finfellows.domain.newscontent.dto.request.NewsContentRequest;
import com.finfellows.domain.newscontent.dto.response.NewsContentResponse;
import com.finfellows.domain.post.domain.Post;
import com.finfellows.domain.post.domain.repository.PostRepository;
import com.finfellows.domain.user.domain.repository.UserRepository;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -20,6 +23,7 @@
public class NewsContentService {
private final NewsContentRepository newsContentRepository;
private final PostRepository postRepository;
private final EduContentBookmarkRepository eduContentBookmarkRepository;

@Transactional
public NewsContent createNewsContent(NewsContentResponse request) {
Expand All @@ -38,13 +42,14 @@ public NewsContent createNewsContent(NewsContentResponse request) {
return savedContent;
}

public List<NewsContentResponse> getAllNewsContents() {
public List<NewsContentResponse> getAllNewsContents(Long userId) {
List<NewsContent> newsContents = newsContentRepository.findAll();
return newsContents.stream()
.map(newsContent -> NewsContentResponse.builder()
.id(newsContent.getId())
.title(newsContent.getTitle())
.content(newsContent.getContent())
.bookmarked(checkBookmarked(userId, newsContent.getId())) // 북마크 여부 확인
.build())
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -83,4 +88,9 @@ public NewsContentResponse updateNewsContent(Long id, NewsContentRequest request
.content(updatedContent.getContent())
.build();
}

// 특정 뉴스 콘텐츠에 대한 북마크 여부 확인
private boolean checkBookmarked(Long userId, Long newsContentId) {
return eduContentBookmarkRepository.existsByUser_IdAndEduContent_Id(userId, newsContentId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class NewsContentResponse {
private Long id;
private String title;
private String content;
private boolean bookmarked;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.finfellows.domain.newscontent.domain.NewsContent;
import com.finfellows.domain.newscontent.dto.request.NewsContentRequest;
import com.finfellows.domain.newscontent.dto.response.NewsContentResponse;
import com.finfellows.global.config.security.token.CurrentUser;
import com.finfellows.global.config.security.token.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -39,8 +41,8 @@ public ResponseEntity<NewsContent> saveNewsContent(@RequestBody NewsContentRespo
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = NewsContentResponse.class)))
})
@GetMapping
public ResponseEntity<List<NewsContentResponse>> getAllNewsContents() {
List<NewsContentResponse> responseList = newsContentService.getAllNewsContents();
public ResponseEntity<List<NewsContentResponse>> getAllNewsContents(@CurrentUser UserPrincipal userPrincipal) {
List<NewsContentResponse> responseList = newsContentService.getAllNewsContents(userPrincipal.getId());
return new ResponseEntity<>(responseList, HttpStatus.OK);
}

Expand Down
Loading

0 comments on commit ab33ee6

Please sign in to comment.