Skip to content

Commit

Permalink
Merge pull request #111 from DEPthes/develop
Browse files Browse the repository at this point in the history
V.4.2.0 Deploy
  • Loading branch information
phonil authored Aug 19, 2024
2 parents 13bd349 + 900f6fc commit 80b2ff1
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mvp.deplog.domain.member.domain.Role;
import mvp.deplog.domain.member.dto.Avatar;
import mvp.deplog.domain.post.domain.Post;
import mvp.deplog.domain.post.domain.Stage;
import mvp.deplog.domain.post.domain.repository.PostRepository;
import mvp.deplog.domain.post.dto.response.AnonymousPostDetailRes;
import mvp.deplog.domain.post.dto.response.MemberPostDetailRes;
Expand Down Expand Up @@ -35,7 +36,7 @@ public boolean supports(UserDetailsImpl userDetails) {
@Override
@Transactional
public SuccessResponse<AnonymousPostDetailRes> getPostDetail(UserDetailsImpl userDetails, Long postId) {
Post post = postRepository.findById(postId)
Post post = postRepository.findByIdAndStage(postId, Stage.PUBLISHED)
.orElseThrow(() -> new ResourceNotFoundException("해당 id의 게시글을 찾을 수 없습니다: " + postId));

// Tagging Entity에 Tag 목록 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import mvp.deplog.domain.member.domain.repository.MemberRepository;
import mvp.deplog.domain.member.dto.Avatar;
import mvp.deplog.domain.post.domain.Post;
import mvp.deplog.domain.post.domain.Stage;
import mvp.deplog.domain.post.domain.repository.PostRepository;
import mvp.deplog.domain.post.dto.response.AnonymousPostDetailRes;
import mvp.deplog.domain.post.dto.response.MemberPostDetailRes;
import mvp.deplog.domain.post.exception.ResourceNotFoundException;
import mvp.deplog.domain.scrap.domain.repository.ScrapRepository;
Expand Down Expand Up @@ -42,7 +42,7 @@ public boolean supports(UserDetailsImpl userDetails) {
@Transactional
public SuccessResponse<MemberPostDetailRes> getPostDetail(UserDetailsImpl userDetails, Long postId) {
Long memberId = userDetails.getMember().getId();
Post post = postRepository.findById(postId)
Post post = postRepository.findByIdAndStage(postId, Stage.PUBLISHED)
.orElseThrow(() -> new ResourceNotFoundException("해당 id의 게시글을 찾을 수 없습니다: " + postId));
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new IllegalArgumentException("해당 id의 멤버를 찾을 수 없습니다: " + memberId));
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/mvp/deplog/domain/post/application/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import mvp.deplog.domain.post.dto.request.CreatePostReq;
import mvp.deplog.domain.post.dto.response.TempListRes;
import mvp.deplog.domain.post.dto.response.PostListRes;
import mvp.deplog.domain.post.dto.response.TempPostDetailRes;
import mvp.deplog.domain.post.exception.ResourceNotFoundException;
import mvp.deplog.domain.post.exception.UnauthorizedException;
import mvp.deplog.domain.scrap.domain.repository.ScrapRepository;
Expand All @@ -24,6 +25,7 @@
import mvp.deplog.global.common.PageInfo;
import mvp.deplog.global.common.PageResponse;
import mvp.deplog.global.common.SuccessResponse;
import mvp.deplog.global.security.UserDetailsImpl;
import mvp.deplog.infrastructure.markdown.MarkdownUtil;
import mvp.deplog.infrastructure.s3.application.FileService;
import mvp.deplog.infrastructure.s3.dto.response.FileUrlRes;
Expand Down Expand Up @@ -348,6 +350,33 @@ public SuccessResponse<List<TempListRes>> getAllTempPosts(Long memberId) {
return SuccessResponse.of(tempList);
}

@Transactional
public SuccessResponse<TempPostDetailRes> getTempPostDetails(UserDetailsImpl userDetails, Long postId) {
Long memberId = userDetails.getMember().getId();
Post post = postRepository.findByIdAndStage(postId, Stage.TEMP)
.orElseThrow(() -> new ResourceNotFoundException("해당 id의 게시글을 찾을 수 없습니다: " + postId));
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new IllegalArgumentException("해당 id의 멤버를 찾을 수 없습니다: " + memberId));

Member writer = post.getMember();
if(!member.equals(writer)) {
throw new UnauthorizedException("본인이 작성한 임시저장 게시글만 조회할 수 있습니다.");
}

List<String> tagNameList = taggingRepository.findByPost(post).stream()
.map(tagging -> tagging.getTag().getName())
.collect(Collectors.toList());

TempPostDetailRes tempPostDetailRes = TempPostDetailRes.builder()
.postId(post.getId())
.title(post.getTitle())
.content(post.getContent())
.tagNameList(tagNameList)
.build();

return SuccessResponse.of(tempPostDetailRes);
}

@Transactional
public SuccessResponse<CreatePostRes> modifyPost(Long memberId, Long postId, CreatePostReq createPostReq) {
Post post = postRepository.findById(postId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public interface PostRepository extends JpaRepository<Post, Long> {

Optional<Post> findById(Long id);
Optional<Post> findByIdAndStage(Long id, Stage stage);

Page<Post> findAllByStage(Stage stage, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mvp.deplog.domain.post.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class TempPostDetailRes {

@Schema(type = "Long", example = "1", description = "게시글 아이디입니다.")
private Long postId;

@Schema(type = "String", example = "게시글 제목", description = "게시글 제목입니다.")
private String title;

@Schema(type = "Sting", example = "**게시글 상세 내용**", description = "게시글 내용입니다. 마크다운 형식으로 반환됩니다.")
private String content;

@Schema(type = "List<String>", example = "[Spring, Java]", description = "태그 이름 리스트입니다.")
private List<String> tagNameList;

}
23 changes: 18 additions & 5 deletions src/main/java/mvp/deplog/domain/post/presentation/PostApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import mvp.deplog.domain.member.domain.Part;
import mvp.deplog.domain.post.dto.response.AnonymousPostDetailRes;
import mvp.deplog.domain.post.dto.response.CreatePostRes;
import mvp.deplog.domain.post.dto.response.*;
import mvp.deplog.domain.post.dto.request.CreatePostReq;
import mvp.deplog.domain.post.dto.response.MemberPostDetailRes;
import mvp.deplog.domain.post.dto.response.TempListRes;
import mvp.deplog.domain.post.dto.response.PostListRes;
import mvp.deplog.global.common.Message;
import mvp.deplog.global.common.PageResponse;
import mvp.deplog.global.common.SuccessResponse;
Expand Down Expand Up @@ -241,6 +237,23 @@ ResponseEntity<SuccessResponse<List<TempListRes>>> getAllTempPosts(
@Parameter(description = "Access Token을 입력하세요.", required = true) @AuthenticationPrincipal UserDetailsImpl userDetails
);

@Operation(summary = "임시 저장 게시글 상세 조회 API", description = "해당 아이디의 임시 저장 게시글을 상세 조회합니다.")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200", description = "임시 저장 게시글 상세 조회 성공",
content = {@Content(mediaType = "application/json", schema = @Schema(implementation = TempPostDetailRes.class))}
),
@ApiResponse(
responseCode = "400", description = "임시 저장 게시글 상세 조회 실패",
content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}
)
})
@GetMapping("/temps/details/{postId}")
ResponseEntity<SuccessResponse<TempPostDetailRes>> getTempPostDetails(
@Parameter(description = "Access Token을 입력하세요.", required = true) @AuthenticationPrincipal UserDetailsImpl userDetails,
@Parameter(description = "임시 저장 게시글의 아이디를 입력하세요.", required = true) @PathVariable Long postId
);

@Operation(summary = "게시글 수정 API", description = "해당 아이디의 게시글을 수정합니다.")
@ApiResponses(value = {
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mvp.deplog.domain.post.dto.response.CreatePostRes;
import mvp.deplog.domain.post.dto.request.CreatePostReq;
import mvp.deplog.domain.post.dto.response.TempListRes;
import mvp.deplog.domain.post.dto.response.TempPostDetailRes;
import mvp.deplog.global.common.Message;
import mvp.deplog.global.common.PageResponse;
import mvp.deplog.global.common.SuccessResponse;
Expand Down Expand Up @@ -114,6 +115,13 @@ public ResponseEntity<SuccessResponse<List<TempListRes>>> getAllTempPosts(@Authe
return ResponseEntity.ok(postService.getAllTempPosts(userDetails.getMember().getId()));
}

@Override
@GetMapping("/temps/details/{postId}")
public ResponseEntity<SuccessResponse<TempPostDetailRes>> getTempPostDetails(@AuthenticationPrincipal UserDetailsImpl userDetails,
@PathVariable(value = "postId") Long postId) {
return ResponseEntity.ok(postService.getTempPostDetails(userDetails, postId));
}

@Override
@PutMapping("/edits/{postId}")
public ResponseEntity<SuccessResponse<CreatePostRes>> modifyPosts(@AuthenticationPrincipal UserDetailsImpl userDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class SecurityConfig {
"/likes/**",
"/members/**",
"/scraps/**",
"/posts/{postId:[0-9]+}", "/posts/temps", "/posts", "/posts/uploadImages", "/posts/temps", "/posts/publishing/{postId:[0-9]+}", "/posts/edits/{postId:[0-9]+}"
"/posts/{postId:[0-9]+}", "/posts/temps", "/posts", "/posts/uploadImages", "/posts/temps", "/posts/publishing/{postId:[0-9]+}", "/posts/edits/{postId:[0-9]+}", "/posts/temps/details/{postId:[0-9]+}"
};

@Bean
Expand Down
Binary file removed src/main/resources/static/images/deplog-airplane.png
Binary file not shown.
Binary file added src/main/resources/static/images/deplog_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/static/images/fail_animal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions src/main/resources/templates/fail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>이메일 인증 실패</title>
<style>
body {
background-color: #ADBBC8;
background-color: #E5E9EC;
font-family: Arial, sans-serif;
color: #000000;
margin: 0;
Expand All @@ -18,23 +18,27 @@
.container {
text-align: center;
}
.logo {
width: 462px;
height: 170px;
.icon {
width: 150px;
height: 150px;
margin-bottom: 20px;
}
.message {
font-size: 21.33px;
.title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.message {
font-size: 16px;
color: #000000;
}
</style>
</head>
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<body>
<div class="container">
<img src="/images/deplog-airplane.png" alt="DEP Logo" class="logo">
<div class="message">이메일 인증에 실패했습니다.</div>
<img src="/images/fail_animal.png" alt="Success Icon" class="icon">
<div class="title">메일 인증 실패</div>
<div class="message">메일 인증에 실패하였습니다.<br>잠시 후에 다시 시도해주세요.</div>
</div>
</body>
</html>
24 changes: 14 additions & 10 deletions src/main/resources/templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>이메일 인증 완료</title>
<title>이메일 인증 성공</title>
<style>
body {
background-color: #ADBBC8;
background-color: #E5E9EC;
font-family: Arial, sans-serif;
color: #000000;
margin: 0;
Expand All @@ -18,23 +18,27 @@
.container {
text-align: center;
}
.logo {
width: 462px;
height: 170px;
.icon {
width: 150px;
height: 150px;
margin-bottom: 20px;
}
.message {
font-size: 21.33px;
.title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.message {
font-size: 16px;
color: #000000;
}
</style>
</head>
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<body>
<div class="container">
<img src="/images/deplog-airplane.png" alt="DEP Logo" class="logo">
<div class="message">DEPlog 페이지로 돌아가 인증 완료 버튼을 클릭해주세요.</div>
<img src="/images/success_animal.png" alt="Success Icon" class="icon">
<div class="title">메일 인증 성공</div>
<div class="message">메일 인증에 성공하였습니다.<br>DEPlog 페이지로 돌아가 인증 완료 버튼을 클릭해주세요.</div>
</div>
</body>
</html>
78 changes: 70 additions & 8 deletions src/main/resources/templates/verification-email.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,80 @@

<!-- -->

<!--<!DOCTYPE html>-->
<!--<html xmlns:th="http://www.thymeleaf.org">-->
<!--<head>-->
<!-- <title>Email Verification</title>-->
<!--</head>-->
<!--<body style="background-color: #F3F4F6; font-family: 'Verdana', sans-serif; margin: 0; padding: 0;">-->
<!--<div style="margin: 100px auto; padding: 20px; max-width: 600px; background-color: #ADBBC8; border-radius: 10px; text-align: center; color: #FFFFFF; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">-->
<!-- <h1 style="font-size: 2.2em; margin-bottom: 20px; color: #000000;">DEPlog 인증 메일</h1>-->
<!-- <p style="font-size: 1.2em; line-height: 1.6; color: #000000;">인증을 완료하려면 아래 버튼을 클릭해주세요</p>-->
<!-- <div style="margin-top: 30px;">-->
<!-- <a href="#" th:href="@{${verificationUrl}(code=${code})}" style="background-color: #000000; color: #FFFFFF; padding: 15px 25px; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 1.2em; font-weight: bold; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: background-color 0.3s ease;">이메일 인증하기</a>-->
<!-- </div>-->
<!--</div>-->
<!--</body>-->
<!--</html>-->

<!--<!DOCTYPE html>-->
<!--<html xmlns:th="http://www.thymeleaf.org">-->
<!--<head>-->
<!-- <title>Email Verification</title>-->
<!--</head>-->
<!--<body style="background-color: #ADBBC8; font-family: 'Arial', sans-serif; margin: 0; padding: 0;">-->
<!--&lt;!&ndash;<div style="margin: 100px auto; padding: 20px; max-width: 600px; background-color: #ADBBC8; border-radius: 10px; text-align: center; color: #000000; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">&ndash;&gt;-->
<!--<div style="margin: 100px auto; padding: 20px; text-align: center; background-color: #ADBBC8; color: #000000;">-->
<!-- <img src="https://deplog-image-bucket.s3.ap-northeast-2.amazonaws.com/mail/deplog-logo.png" alt="DEP Logo" style="width: 462px; height: 74px; margin-bottom: 20px;">-->
<!-- <h1 style="font-size: 2.2em; margin-bottom: 20px; color: #000000;">DEPlog 인증 메일</h1>-->
<!-- <p style="font-size: 1.2em; line-height: 1.6; color: #000000;">인증을 완료하려면 아래 버튼을 클릭해주세요.</p>-->
<!-- <div style="margin-top: 30px;">-->
<!-- <a href="#" th:href="@{${verificationUrl}(code=${code})}" style="background-color: #1D1D1D; color: #FFFFFF; padding: 15px 25px; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 1.2em; font-weight: bold; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: background-color 0.3s ease;">이메일 인증하기</a>-->
<!-- </div>-->
<!--</div>-->
<!--</body>-->
<!--</html>-->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Email Verification</title>
</head>
<body style="background-color: #F3F4F6; font-family: 'Verdana', sans-serif; margin: 0; padding: 0;">
<div style="margin: 100px auto; padding: 20px; max-width: 600px; background-color: #ADBBC8; border-radius: 10px; text-align: center; color: #FFFFFF; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<h1 style="font-size: 2.2em; margin-bottom: 20px; color: #000000;">DEPlog 인증 메일</h1>
<p style="font-size: 1.2em; line-height: 1.6; color: #000000;">인증을 완료하려면 아래 버튼을 클릭해주세요</p>
<div style="margin-top: 30px;">
<a href="#" th:href="@{${verificationUrl}(code=${code})}" style="background-color: #000000; color: #FFFFFF; padding: 15px 25px; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 1.2em; font-weight: bold; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: background-color 0.3s ease;">이메일 인증하기</a>
</div>
</div>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #E5E9EC;">

<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #E5E9EC; margin: 0; padding: 0;">
<tr>
<td align="center" valign="top">
<!-- Main container for the content -->
<table width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 100px auto; padding: 20px; background-color: #E5E9EC; text-align: center;">
<tr>
<td style="padding-bottom: 20px;">
<img src="https://deplog-image-bucket.s3.ap-northeast-2.amazonaws.com/mail/deplog-logo.png" alt="DEP Logo" style="width: 462px; height: 74px;">
</td>
</tr>
<tr>
<td style="padding-bottom: 20px;">
<h1 style="font-size: 24px; color: #000000;">DEPlog 인증 메일</h1>
</td>
</tr>
<tr>
<td style="padding-bottom: 30px;">
<p style="font-size: 16px; line-height: 24px; color: #000000;">인증을 완료하려면 아래 버튼을 클릭해주세요.</p>
</td>
</tr>
<tr>
<td>
<a href="#" th:href="@{${verificationUrl}(code=${code})}" style="background-color: #050C20; color: #FFFFFF; padding: 15px 25px; text-decoration: none; border-radius: 2px; font-size: 16px; font-weight: bold; display: inline-block; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: background-color 0.3s ease;">
이메일 인증하기
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>

</body>
</html>

0 comments on commit 80b2ff1

Please sign in to comment.