Skip to content
Open

Dev #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ repositories {
mavenCentral()
}

jar {
enabled = false
}


dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface PostRepository extends JpaRepository<Post, Long> {

Page<Post> findByPostType(PostType postType, Pageable pageable);
Page<Post> findAllByPostType(PostType postType, Pageable pageable);

Page<Post> findByUserId(Long userId, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -52,7 +53,7 @@ public ResponseEntity<Void> updatePost(
@GetMapping("")
public ResponseEntity<Page<SimplePostResponseDto>> getPosts(
@LoginUser SessionUser sessionUser,
@RequestParam(value = "category") PostType postType,
@RequestParam(value = "category") @Nullable PostType postType,
@PageableDefault(
size = 12,
sort = "id",
Expand Down Expand Up @@ -83,7 +84,7 @@ public ResponseEntity<PostResponseDto> getPost(
return ResponseEntity.ok(postResponse);
}

@GetMapping("/{keyword}")
@GetMapping("/search/{keyword}")
public ResponseEntity<Page<SimplePostResponseDto>> searchPosts(
@LoginUser SessionUser sessionUser,
@PathVariable String keyword,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public void deletePost(Long postId) {
public Page<SimplePostResponseDto> findAllPostByPostType(Long userId,
PostType postType,
Pageable pageable) {
Page<Post> posts = postRepository.findByPostType(postType, pageable);
Page<Post> posts = postType == null
? postRepository.findAll(pageable)
: postRepository.findAllByPostType(postType, pageable);
Map<Long, PostFavorInfoResponseDto> favorMap = new HashMap<>();
posts.forEach(post -> {
favorMap.put(
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/kr/or/cola/backend/util/CustomMailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

Expand All @@ -28,7 +29,7 @@ public void sendAuthenticationToken(String authToken, String receiverEmail) {
mailMessage.setTo(receiverEmail);
mailMessage.setSubject("νšŒμ›κ°€μž… 이메일 인증");
mailMessage.setText(authToken);

mailMessage.setFrom(managerEmail);
sendEmail(mailMessage);
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.properties.mail.ssl.enable=true
spring.mail.properties.mail.ssl.trust=true

spring.data.web.pageable.default-page-size=12

Expand Down