Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop' into refac…
Browse files Browse the repository at this point in the history
…tor/#403-nana-pick

# Conflicts:
#	src/main/java/com/jeju/nanaland/domain/nana/repository/NanaRepositoryCustom.java
#	src/main/java/com/jeju/nanaland/domain/nana/repository/NanaRepositoryImpl.java
  • Loading branch information
Te-H0 committed Sep 19, 2024
2 parents 9e5288d + 4d48681 commit f2a215b
Show file tree
Hide file tree
Showing 93 changed files with 3,122 additions and 1,886 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Data
@SuperBuilder
public class PostCardDto {
public class PostPreviewDto {

@Schema(description = "게시물 id")
private Long id;
Expand All @@ -22,16 +22,18 @@ public class PostCardDto {
private ImageFileDto firstImage;

@QueryProjection
public PostCardDto(Long id, String title, String originUrl, String thumbnailUrl) {
public PostPreviewDto(Long id, String title, String originUrl, String thumbnailUrl) {
this.id = id;
this.title = title;
this.firstImage = new ImageFileDto(originUrl, thumbnailUrl);
}

public PostCardDto(Long id, String title, String category, ImageFileDto firstImage) {
this.id = id;
this.title = title;
this.category = category;
this.firstImage = firstImage;
public PostPreviewDto(PostPreviewDto postPreviewDto) {
this.id = postPreviewDto.getId();
this.title = postPreviewDto.getTitle();
this.category = postPreviewDto.getCategory();
this.firstImage = postPreviewDto.getFirstImage();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.jeju.nanaland.domain.common.service;

import static com.jeju.nanaland.global.exception.ErrorCode.MAIL_FAIL_ERROR;

import com.jeju.nanaland.domain.report.entity.Report;
import com.jeju.nanaland.global.exception.ServerErrorException;
import jakarta.mail.Message.RecipientType;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import java.io.UnsupportedEncodingException;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring6.SpringTemplateEngine;

@Service
@RequiredArgsConstructor
@Slf4j
public class MailService {

// TODO: 관리자 계정으로 바꾸기
private static final String ADMIN_EMAIL = "[email protected]";
private final Environment env;
private final JavaMailSender javaMailSender;
private final SpringTemplateEngine templateEngine;

/**
* 메일 전송
*
* @param report 요청 (InfoFixReport, ClaimReport)
* @param urls 파일 URL 리스트
* @throws ServerErrorException 메일 전송이 실패한 경우
*/
@Async("mailExecutor")
public void sendEmailReport(Report report, List<String> urls) {
try {
MimeMessage mimeMessage = createReportMail(report, urls);
javaMailSender.send(mimeMessage);
} catch (Exception e) {
log.error(e.getMessage());
throw new ServerErrorException(MAIL_FAIL_ERROR.getMessage());
}
}

/**
* 메일 생성
*
* @param report 요청 (InfoFixReport, ClaimReport)
* @param urls 파일 URL 리스트
* @return MimeMessage
* @throws MessagingException 메일 관련 오류가 발생한 경우
* @throws UnsupportedEncodingException 인코딩 오류가 발생한 경우
*/
private MimeMessage createReportMail(Report report, List<String> urls)
throws MessagingException, UnsupportedEncodingException {
MimeMessage message = javaMailSender.createMimeMessage();
String senderEmail = env.getProperty("spring.mail.username");
message.setFrom(new InternetAddress(senderEmail, "Jeju in Nanaland"));
message.setRecipients(RecipientType.TO, ADMIN_EMAIL);

Context context = new Context();
String templateName = report.setReportContextAndGetTemplate(message, context);

for (int i = 0; i < urls.size(); i++) {
context.setVariable("image_" + i, urls.get(i));
}
message.setText(templateEngine.process(templateName, context), "utf-8", "html");

return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.jeju.nanaland.domain.common.data.Category;
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.PostCardDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.common.entity.Post;
import com.jeju.nanaland.global.exception.NotFoundException;

Expand All @@ -19,13 +19,13 @@ public interface PostService {
Post getPost(Long postId, Category category);

/**
* 카드 정보 조회 - (postId, category, imageFile, title)
* 게시물 preview 정보 조회 - (postId, category, imageFile, title)
*
* @param postId 게시물 id
* @param category 게시물 카테고리
* @param language 언어 정보
* @return PostCardDto
* @return PostPreviewDto
* @throws NotFoundException (게시물 id, 카테고리, 언어)에 해당하는 게시물 정보가 없는 경우
*/
PostCardDto getPostCardDto(Long postId, Category category, Language language);
PostPreviewDto getPostPreviewDto(Long postId, Category category, Language language);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.jeju.nanaland.domain.common.data.Category;
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.PostCardDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.common.entity.Post;
import com.jeju.nanaland.domain.experience.service.ExperienceService;
import com.jeju.nanaland.domain.festival.service.FestivalService;
Expand Down Expand Up @@ -48,7 +48,7 @@ public Post getPost(Long postId, Category category) {
}

/**
* 카드 정보 조회 - (postId, category, imageFile, title)
* preview 정보 조회 - (postId, category, imageFile, title)
*
* @param postId 게시물 id
* @param category 게시물 카테고리
Expand All @@ -57,7 +57,7 @@ public Post getPost(Long postId, Category category) {
* @throws NotFoundException (게시물 id, 카테고리, 언어)에 해당하는 게시물 정보가 없는 경우
*/
@Override
public PostCardDto getPostCardDto(Long postId, Category category, Language language) {
return serviceMap.get(category).getPostCardDto(postId, category, language);
public PostPreviewDto getPostPreviewDto(Long postId, Category category, Language language) {
return serviceMap.get(category).getPostPreviewDto(postId, category, language);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jeju.nanaland.domain.experience.repository;

import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.PostCardDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.experience.dto.ExperienceCompositeDto;
import com.jeju.nanaland.domain.experience.dto.ExperienceResponse.ExperienceThumbnail;
import com.jeju.nanaland.domain.experience.entity.enums.ExperienceType;
Expand Down Expand Up @@ -29,5 +29,5 @@ Page<ExperienceThumbnail> findExperienceThumbnails(Language language,

List<Long> findAllIds();

PostCardDto findPostCardDto(Long postId, Language language);
PostPreviewDto findPostPreviewDto(Long postId, Language language);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import com.jeju.nanaland.domain.common.data.Category;
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.PostCardDto;
import com.jeju.nanaland.domain.common.dto.QPostCardDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.common.dto.QPostPreviewDto;
import com.jeju.nanaland.domain.experience.dto.ExperienceCompositeDto;
import com.jeju.nanaland.domain.experience.dto.ExperienceResponse.ExperienceThumbnail;
import com.jeju.nanaland.domain.experience.dto.QExperienceCompositeDto;
Expand Down Expand Up @@ -192,9 +192,9 @@ public List<Long> findAllIds() {
}

@Override
public PostCardDto findPostCardDto(Long postId, Language language) {
public PostPreviewDto findPostPreviewDto(Long postId, Language language) {
return queryFactory
.select(new QPostCardDto(
.select(new QPostPreviewDto(
experience.id,
experienceTrans.title,
imageFile.originUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.data.PostCategory;
import com.jeju.nanaland.domain.common.dto.ImageFileDto;
import com.jeju.nanaland.domain.common.dto.PostCardDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.common.entity.Post;
import com.jeju.nanaland.domain.common.repository.ImageFileRepository;
import com.jeju.nanaland.domain.common.service.PostService;
Expand Down Expand Up @@ -61,22 +61,22 @@ public Post getPost(Long postId, Category category) {
}

/**
* 카드 정보 조회 - (postId, category, imageFile, title)
* 게시물 preview 정보 조회 - (postId, category, imageFile, title)
*
* @param postId 게시물 id
* @param category 게시물 카테고리
* @param language 언어 정보
* @return PostCardDto
* @return PostPreviewDto
* @throws NotFoundException (게시물 id, langugae)를 가진 이색체험 정보가 존재하지 않는 경우
*/
@Override
public PostCardDto getPostCardDto(Long postId, Category category, Language language) {
PostCardDto postCardDto = experienceRepository.findPostCardDto(postId, language);
Optional.ofNullable(postCardDto)
public PostPreviewDto getPostPreviewDto(Long postId, Category category, Language language) {
PostPreviewDto postPreviewDto = experienceRepository.findPostPreviewDto(postId, language);
Optional.ofNullable(postPreviewDto)
.orElseThrow(() -> new NotFoundException("해당 게시물을 찾을 수 없습니다."));

postCardDto.setCategory(PostCategory.EXPERIENCE.toString());
return postCardDto;
postPreviewDto.setCategory(PostCategory.EXPERIENCE.toString());
return postPreviewDto;
}

// 이색체험 리스트 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public class FavoriteController {
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/all/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getAllFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getAllFavorites(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllFavorites(memberInfoDto, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "이색체험 찜리스트 조회", description = "이색체험 찜리스트 조회")
Expand All @@ -64,14 +64,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getAllFavoriteList(
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/experience/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getExperienceFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getExperienceFavorites(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, EXPERIENCE, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "7대자연 찜리스트 조회", description = "7대자연 찜리스트 조회")
Expand All @@ -81,14 +81,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getExperienceFavoriteL
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/nature/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getNatureFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getNatureFavoriteList(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, NATURE, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "축제 찜리스트 조회", description = "축제 찜리스트 조회")
Expand All @@ -98,14 +98,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getNatureFavoriteList(
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/festival/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getFestivalFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getFestivalFavoriteList(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, FESTIVAL, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "전통시장 찜리스트 조회", description = "전통시장 찜리스트 조회")
Expand All @@ -115,14 +115,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getFestivalFavoriteLis
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/market/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getMarketFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getMarketFavoriteList(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, MARKET, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "나나스픽 찜리스트 조회", description = "나나스픽 찜리스트 조회")
Expand All @@ -132,14 +132,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getMarketFavoriteList(
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/nana/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getNanaFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getNanaFavoriteList(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, NANA, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "맛집 찜리스트 조회", description = "맛집 찜리스트 조회")
Expand All @@ -149,14 +149,14 @@ public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getNanaFavoriteList(
@ApiResponse(responseCode = "500", description = "서버측 에러", content = @Content)
})
@GetMapping("/restaurant/list")
public BaseResponse<FavoriteResponse.FavoriteCardPageDto> getRestaurantFavoriteList(
public BaseResponse<FavoriteResponse.PreviewPageDto> getRestaurantFavoriteList(
@AuthMember MemberInfoDto memberInfoDto,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "12") int size) {

FavoriteResponse.FavoriteCardPageDto favoriteCardPageDto =
FavoriteResponse.PreviewPageDto favoritePreviewPageDto =
favoriteService.getAllCategoryFavorites(memberInfoDto, RESTAURANT, page, size);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoriteCardPageDto);
return BaseResponse.success(SuccessCode.GET_FAVORITE_LIST_SUCCESS, favoritePreviewPageDto);
}

@Operation(summary = "좋아요 토글", description = "좋아요 토글 기능 (좋아요 상태 -> 좋아요 취소 상태, 좋아요 취소 상태 -> 좋아요 상태)")
Expand Down

This file was deleted.

Loading

0 comments on commit f2a215b

Please sign in to comment.