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

Commit

Permalink
allowedHeaders 주석처리(test)
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 committed Jan 19, 2024
1 parent 101f8a0 commit 6548a27
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 258 deletions.
Empty file modified gradlew
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,7 @@ public AuthRes kakaoLogin(KakaoProfile kakaoProfile) {
Token savedToken = tokenRepository.save(token);


// 쿠키 생성 및 설정
// Cookie refreshTokenCookie = new Cookie("refreshToken", tokenMapping.getRefreshToken());
// refreshTokenCookie.setMaxAge(14 * 24 * 60 * 60); // 유효기간 2주일
// refreshTokenCookie.setHttpOnly(true);
// refreshTokenCookie.setPath("/");
// refreshTokenCookie.setSecure(true);

// response.addCookie(refreshTokenCookie);


return AuthRes.builder()
Expand All @@ -230,6 +223,8 @@ public AuthRes kakaoLogin(KakaoProfile kakaoProfile) {
.build();
}



@Transactional
public Message signOut(final RefreshTokenReq tokenRefreshRequest) {
Token token = tokenRepository.findByRefreshToken(tokenRefreshRequest.getRefreshToken())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class AuthController {
// kakaoService.accessRequest();
// }


@Operation(summary = "유저 정보 확인", description = "현재 접속 중인 유저의 정보를 확인합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "유저 확인 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = User.class) ) } ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.finfellows.global.payload.Message;
import com.finfellows.global.payload.ResponseCustom;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -31,6 +32,7 @@

@Service
@RequiredArgsConstructor
@Slf4j
public class FinancialProductBookmarkServiceImpl implements BookmarkService{
private final FinancialProductBookmarkRepository financialProductBookmarkRepository;
private final UserRepository userRepository;
Expand Down Expand Up @@ -144,11 +146,17 @@ public Message cmaDelete(UserPrincipal userPrincipal, Long cmaId) {
CMA cma = cmaRepository.findById(cmaId)
.orElseThrow(RuntimeException::new);

log.info(String.valueOf(user));
log.info(String.valueOf(cma));


CmaBookmark cmaBookmark = CmaBookmark.builder()
.user(user)
.cma(cma)
.build();

log.info(cmaBookmark.toString());

cmaBookmarkRepository.delete(cmaBookmark);

return Message.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
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;
import com.finfellows.domain.educontent.dto.response.EduContentResponse;
import com.finfellows.domain.post.domain.Post;
import com.finfellows.domain.post.domain.repository.PostRepository;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class EduContentService {
private final EduContentRepository eduContentRepository;
private final PostRepository postRepository;
private final EduContentBookmarkRepository eduContentBookmarkRepository;

@Transactional
public EduContent createEduContent(EduContentRequest request) {
Post post = new Post();
postRepository.save(post);

// 빌더 패턴을 사용하여 EduContent 생성하면서 Post 엔터티를 설정
EduContent eduContent = EduContent.builder()
.title(request.getTitle())
.content(request.getContent())
.post(post) // Post 엔터티를 설정
.build();

// EduContent 저장
EduContent savedContent = eduContentRepository.save(eduContent);
return savedContent;
}

public Page<EduContentResponse> getAllEduContents(Long userId, Pageable pageable) {
Page<EduContent> eduContentPage = eduContentRepository.findAll(pageable);

List<EduContentResponse> eduContentResponses = eduContentPage.getContent().stream()
.map(eduContent -> EduContentResponse.builder()
.id(eduContent.getId())
.title(eduContent.getTitle())
.content(eduContent.getContent())
.bookmarked(checkBookmarked(userId, eduContent.getId()))
.build())
.collect(Collectors.toList());

return new PageImpl<>(eduContentResponses, pageable, eduContentPage.getTotalElements());
}

public EduContentResponse getEduContent(Long id) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

return EduContentResponse.builder()
.id(eduContent.getId())
.title(eduContent.getTitle())
.content(eduContent.getContent())
.build();
}

@Transactional
public void deleteEduContent(Long id) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

eduContentRepository.delete(eduContent);
}

@Transactional
public EduContentResponse updateEduContent(Long id, EduContentRequest request) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

eduContent.updateContent(request.getTitle(), request.getContent());

EduContent updatedContent = eduContentRepository.save(eduContent);

return EduContentResponse.builder()
.id(updatedContent.getId())
.title(updatedContent.getTitle())
.content(updatedContent.getContent())
.build();
}


private boolean checkBookmarked(Long userId, Long eduContentId) {
return eduContentBookmarkRepository.existsByUser_IdAndEduContent_Id(userId, eduContentId);
}
}
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;
import com.finfellows.domain.educontent.dto.response.EduContentResponse;
import com.finfellows.domain.post.domain.Post;
import com.finfellows.domain.post.domain.repository.PostRepository;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class EduContentService {
private final EduContentRepository eduContentRepository;
private final PostRepository postRepository;
private final EduContentBookmarkRepository eduContentBookmarkRepository;

@Transactional
public EduContent createEduContent(EduContentRequest request) {
Post post = new Post();
postRepository.save(post);

// 빌더 패턴을 사용하여 EduContent 생성하면서 Post 엔터티를 설정
EduContent eduContent = EduContent.builder()
.title(request.getTitle())
.content(request.getContent())
.post(post) // Post 엔터티를 설정
.build();

// EduContent 저장
EduContent savedContent = eduContentRepository.save(eduContent);
return savedContent;
}

public Page<EduContentResponse> getAllEduContents(Long userId, Pageable pageable) {
Page<EduContent> eduContentPage = eduContentRepository.findAll(pageable);

List<EduContentResponse> eduContentResponses = eduContentPage.getContent().stream()
.map(eduContent -> EduContentResponse.builder()
.id(eduContent.getId())
.title(eduContent.getTitle())
.content(eduContent.getContent())
.bookmarked(checkBookmarked(userId, eduContent.getId()))
.build())
.collect(Collectors.toList());

return new PageImpl<>(eduContentResponses, pageable, eduContentPage.getTotalElements());
}

public EduContentResponse getEduContent(Long id) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

return EduContentResponse.builder()
.id(eduContent.getId())
.title(eduContent.getTitle())
.content(eduContent.getContent())
.build();
}

@Transactional
public void deleteEduContent(Long id) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

eduContentRepository.delete(eduContent);
}

@Transactional
public EduContentResponse updateEduContent(Long id, EduContentRequest request) {
EduContent eduContent = eduContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("EduContent not found with id: " + id));

eduContent.updateContent(request.getTitle(), request.getContent());

EduContent updatedContent = eduContentRepository.save(eduContent);

return EduContentResponse.builder()
.id(updatedContent.getId())
.title(updatedContent.getTitle())
.content(updatedContent.getContent())
.build();
}


private boolean checkBookmarked(Long userId, Long eduContentId) {
return eduContentBookmarkRepository.existsByUser_IdAndEduContent_Id(userId, eduContentId);
}
}
Loading

0 comments on commit 6548a27

Please sign in to comment.