diff --git a/src/main/java/com/dife/api/controller/ReportController.java b/src/main/java/com/dife/api/controller/ReportController.java index 23f42dba..8ef33816 100644 --- a/src/main/java/com/dife/api/controller/ReportController.java +++ b/src/main/java/com/dife/api/controller/ReportController.java @@ -21,7 +21,7 @@ public class ReportController { public ResponseEntity createDeclaration( @RequestBody ReportRequestDto requestDto, Authentication auth) { - ReportResponseDto responseDto = reportService.createDeclaration(requestDto, auth.getName()); + ReportResponseDto responseDto = reportService.createReport(requestDto, auth.getName()); return ResponseEntity.status(CREATED).body(responseDto); } } diff --git a/src/main/java/com/dife/api/model/Member.java b/src/main/java/com/dife/api/model/Member.java index 7c2a1277..7fddfb7c 100644 --- a/src/main/java/com/dife/api/model/Member.java +++ b/src/main/java/com/dife/api/model/Member.java @@ -27,7 +27,7 @@ public class Member extends BaseTimeEntity { @NotNull private String password = ""; - private String username = ""; + private String username = "Diver"; private String name = ""; diff --git a/src/main/java/com/dife/api/model/Notification.java b/src/main/java/com/dife/api/model/Notification.java index 939646d6..e2f5099d 100644 --- a/src/main/java/com/dife/api/model/Notification.java +++ b/src/main/java/com/dife/api/model/Notification.java @@ -21,8 +21,6 @@ public class Notification extends BaseTimeEntity { private String message; - private Boolean isRead = false; - @ManyToOne @JoinColumn(name = "notification_token_id") @JsonIgnore diff --git a/src/main/java/com/dife/api/service/ChatService.java b/src/main/java/com/dife/api/service/ChatService.java index 8c8eee78..87a3c88e 100644 --- a/src/main/java/com/dife/api/service/ChatService.java +++ b/src/main/java/com/dife/api/service/ChatService.java @@ -35,6 +35,7 @@ public class ChatService { private final DisconnectHandler disconnectHandler; private final NotificationHandler notificationHandler; private final MemberService memberService; + private final NotificationService notificationService; private final ModelMapper modelMapper; public void sendMessage(ChatRequestDto dto, SimpMessageHeaderAccessor headerAccessor) @@ -80,19 +81,10 @@ public void enter(ChatRequestDto dto, SimpMessageHeaderAccessor headerAccessor) Set chatroomMembers = chatroom.getMembers(); for (Member chatroomMember : chatroomMembers) { - if (!Objects.equals(chatroomMember.getId(), member.getId())) { - List notificationTokens = chatroomMember.getNotificationTokens(); - - for (NotificationToken notificationToken : notificationTokens) { - Notification notification = new Notification(); - notification.setNotificationToken(notificationToken); - notification.setType(NotificationType.CHAT); - notification.setMessage( - "WELCOME! 😊 " + chatroom.getName() + "방에 " + member.getEmail() + "λ‹˜μ΄ μž…μž₯ν•˜μ…¨μŠ΅λ‹ˆλ‹€!"); - notification.setIsRead(false); - notificationToken.getNotifications().add(notification); - } - } + + String message = + "WELCOME! 😊 " + chatroom.getName() + "방에 " + member.getUsername() + "λ‹˜μ΄ μž…μž₯ν•˜μ…¨μŠ΅λ‹ˆλ‹€!"; + notificationService.addNotifications(chatroomMember, member, message, NotificationType.CHAT); } ChatRedisDto chatRedisDto = modelMapper.map(chat, ChatRedisDto.class); @@ -129,8 +121,9 @@ public void chat(ChatRequestDto dto) throws JsonProcessingException { message = message.substring(0, 30) + "..."; } notification.setMessage(message); - notification.setIsRead(false); notificationToken.getNotifications().add(notification); + + notificationService.sendPushNotification(notificationToken.getPushToken(), message); } } } diff --git a/src/main/java/com/dife/api/service/CommentService.java b/src/main/java/com/dife/api/service/CommentService.java index 37e049c3..38edb6b7 100644 --- a/src/main/java/com/dife/api/service/CommentService.java +++ b/src/main/java/com/dife/api/service/CommentService.java @@ -3,9 +3,7 @@ import com.dife.api.exception.CommentDuplicateException; import com.dife.api.exception.MemberNotFoundException; import com.dife.api.exception.PostNotFoundException; -import com.dife.api.model.Comment; -import com.dife.api.model.Member; -import com.dife.api.model.Post; +import com.dife.api.model.*; import com.dife.api.model.dto.CommentCreateRequestDto; import com.dife.api.model.dto.CommentResponseDto; import com.dife.api.repository.CommentRepository; @@ -17,6 +15,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; +import org.springframework.http.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,6 +31,8 @@ public class CommentService { private final CommentRepository commentRepository; private final LikeCommentRepository likeCommentRepository; + private final NotificationService notificationService; + @Transactional(readOnly = true) public List getCommentsByPostId(Long postId, String memberEmail) { Post post = postRepository.findById(postId).orElseThrow(PostNotFoundException::new); @@ -71,8 +72,19 @@ public CommentResponseDto createComment(CommentCreateRequestDto requestDto, Stri commentRepository.save(comment); CommentResponseDto responseDto = modelMapper.map(comment, CommentResponseDto.class); - if (comment.getParentComment() != null) + if (comment.getParentComment() != null) { responseDto.setParentComment(comment.getParentComment()); + List parentCommentTokens = + comment.getParentComment().getWriter().getNotificationTokens(); + String parentMessage = + "WOW!πŸ˜† " + comment.getWriter().getUsername() + "λ‹˜μ΄ νšŒμ›λ‹˜μ΄ λŒ“κΈ€μ„ 남긴 κ²Œμ‹œκΈ€μ— λ‹€λ₯Έ λŒ“κΈ€μ΄ μΆ”κ°€λ˜μ—ˆμ–΄μš”!"; + addNotifications(parentCommentTokens, parentMessage, NotificationType.COMMUNITY); + } + + List postTokens = post.getWriter().getNotificationTokens(); + String postMessage = "WOW!πŸ˜† " + comment.getWriter().getUsername() + "λ‹˜μ΄ νšŒμ›λ‹˜μ˜ κ²Œμ‹œκΈ€μ— λŒ“κΈ€μ΄ μΆ”κ°€λ˜μ—ˆμ–΄μš”!"; + addNotifications(postTokens, postMessage, NotificationType.COMMUNITY); + return responseDto; } @@ -90,4 +102,17 @@ public CommentResponseDto getComment(Comment comment, Member member) { return dto; } + + private void addNotifications( + List tokens, String message, NotificationType type) { + for (NotificationToken token : tokens) { + Notification notification = new Notification(); + notification.setNotificationToken(token); + notification.setType(type); + notification.setMessage(message); + token.getNotifications().add(notification); + + notificationService.sendPushNotification(token.getPushToken(), message); + } + } } diff --git a/src/main/java/com/dife/api/service/ConnectService.java b/src/main/java/com/dife/api/service/ConnectService.java index 29f7e7bf..757b51b8 100644 --- a/src/main/java/com/dife/api/service/ConnectService.java +++ b/src/main/java/com/dife/api/service/ConnectService.java @@ -24,6 +24,8 @@ public class ConnectService { private final ModelMapper modelMapper; + private final NotificationService notificationService; + @Transactional(readOnly = true) public List getConnects(String currentMemberEmail) { Member currentMember = @@ -70,16 +72,9 @@ public ConnectResponseDto saveConnect(ConnectRequestDto dto, String currentMembe connect.setStatus(ConnectStatus.PENDING); connectRepository.save(connect); - List notificationTokens = toMember.getNotificationTokens(); - - for (NotificationToken notificationToken : notificationTokens) { - Notification notification = new Notification(); - notification.setNotificationToken(notificationToken); - notification.setType(NotificationType.CONNECT); - notification.setMessage("Hi!🀝 " + currentMember.getEmail() + "λ‹˜μ΄ νšŒμ›λ‹˜κ³Όμ˜ 컀λ„₯트λ₯Ό λ§Ίκ³  μ‹Άμ–΄ν•΄μš”!"); - notification.setIsRead(false); - notificationToken.getNotifications().add(notification); - } + String message = "Hi!🀝 " + currentMember.getUsername() + "λ‹˜μ΄ νšŒμ›λ‹˜κ³Όμ˜ 컀λ„₯트λ₯Ό λ§Ίκ³  μ‹Άμ–΄ν•΄μš”!"; + notificationService.addNotifications( + toMember, currentMember, message, NotificationType.CONNECT); return modelMapper.map(connect, ConnectResponseDto.class); } @@ -134,13 +129,11 @@ public boolean hasPendingConnect(Member fromMember, Member toMember) { private void createNotifications(Member member, String otherMemberEmail) { List notificationTokens = member.getNotificationTokens(); - for (NotificationToken notificationToken : notificationTokens) { - Notification notification = new Notification(); - notification.setNotificationToken(notificationToken); - notification.setType(NotificationType.CONNECT); - notification.setMessage("YEAH!πŸ™Œ " + otherMemberEmail + "λ‹˜κ³Όμ˜ 컀λ„₯νŠΈκ°€ μ„±μ‚¬λ˜μ—ˆμ–΄μš”!"); - notification.setIsRead(false); - notificationToken.getNotifications().add(notification); - } + + Member otherMember = + memberRepository.findByEmail(otherMemberEmail).orElseThrow(MemberNotFoundException::new); + String message = "YEAH!πŸ™Œ " + otherMember.getUsername() + "λ‹˜κ³Όμ˜ 컀λ„₯νŠΈκ°€ μ„±μ‚¬λ˜μ—ˆμ–΄μš”!"; + + notificationService.addNotifications(member, otherMember, message, NotificationType.CONNECT); } } diff --git a/src/main/java/com/dife/api/service/LikeService.java b/src/main/java/com/dife/api/service/LikeService.java index 851dc18a..1535c2c8 100644 --- a/src/main/java/com/dife/api/service/LikeService.java +++ b/src/main/java/com/dife/api/service/LikeService.java @@ -9,7 +9,6 @@ import com.dife.api.model.dto.PostResponseDto; import com.dife.api.repository.*; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -30,6 +29,7 @@ public class LikeService { private final LikeCommentRepository likeCommentRepository; private final ModelMapper modelMapper; + private final NotificationService notificationService; public List getLikedPosts(String memberEmail) { Member member = @@ -67,19 +67,8 @@ public void createLikePost(Long postId, String memberEmail) { likePostRepository.save(postLike); Member writer = post.getWriter(); - - if (!Objects.equals(writer.getId(), member.getId())) { - List notificationTokens = writer.getNotificationTokens(); - - for (NotificationToken notificationToken : notificationTokens) { - Notification notification = new Notification(); - notification.setNotificationToken(notificationToken); - notification.setType(NotificationType.COMMUNITY); - notification.setMessage("WOW!πŸ˜† " + member.getEmail() + "λ‹˜μ΄ νšŒμ›λ‹˜μ˜ κ²Œμ‹œκΈ€μ„ μ’‹μ•„ν•΄μš”!"); - notification.setIsRead(false); - notificationToken.getNotifications().add(notification); - } - } + String message = "WOW!πŸ˜† " + member.getUsername() + "λ‹˜μ΄ νšŒμ›λ‹˜μ˜ κ²Œμ‹œκΈ€μ„ μ’‹μ•„ν•΄μš”!"; + notificationService.addNotifications(writer, member, message, NotificationType.COMMUNITY); } public void deleteLikePost(LikeCreateRequestDto dto, String memberEmail) { @@ -133,18 +122,7 @@ public void createLikeComment(Long commentId, String memberEmail) { likeCommentRepository.save(likeComment); Member writer = comment.getWriter(); - - if (!Objects.equals(writer.getId(), member.getId())) { - List notificationTokens = writer.getNotificationTokens(); - - for (NotificationToken notificationToken : notificationTokens) { - Notification notification = new Notification(); - notification.setNotificationToken(notificationToken); - notification.setType(NotificationType.COMMUNITY); - notification.setMessage("WOW!πŸ˜† " + member.getEmail() + "λ‹˜μ΄ νšŒμ›λ‹˜μ˜ λŒ“κΈ€μ„ μ’‹μ•„ν•΄μš”!"); - notification.setIsRead(false); - notificationToken.getNotifications().add(notification); - } - } + String message = "WOW!πŸ˜† " + member.getUsername() + "λ‹˜μ΄ νšŒμ›λ‹˜μ˜ λŒ“κΈ€μ„ μ’‹μ•„ν•΄μš”!"; + notificationService.addNotifications(writer, member, message, NotificationType.COMMUNITY); } } diff --git a/src/main/java/com/dife/api/service/NotificationService.java b/src/main/java/com/dife/api/service/NotificationService.java index 7ad15e16..82e8954d 100644 --- a/src/main/java/com/dife/api/service/NotificationService.java +++ b/src/main/java/com/dife/api/service/NotificationService.java @@ -3,19 +3,27 @@ import static java.util.stream.Collectors.toList; import com.dife.api.exception.MemberNotFoundException; +import com.dife.api.exception.NotificationException; import com.dife.api.model.Member; +import com.dife.api.model.Notification; import com.dife.api.model.NotificationToken; +import com.dife.api.model.NotificationType; import com.dife.api.model.dto.NotificationResponseDto; import com.dife.api.model.dto.NotificationTokenRequestDto; import com.dife.api.model.dto.NotificationTokenResponseDto; import com.dife.api.repository.MemberRepository; import com.dife.api.repository.NotificationTokenRepository; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Objects; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; +import org.springframework.http.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; @Service @RequiredArgsConstructor @@ -65,4 +73,44 @@ public List getNotifications(String memberEmail) { .map(n -> modelMapper.map(n, NotificationResponseDto.class)) .collect(toList()); } + + public void sendPushNotification(String expoToken, String message) { + String expoPushUrl = "https://exp.host/--/api/v2/push/send"; + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + Map body = new HashMap<>(); + body.put("to", expoToken); + body.put("sound", "default"); + body.put("body", message); + + HttpEntity> entity = new HttpEntity<>(body, headers); + + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity response = + restTemplate.exchange(expoPushUrl, HttpMethod.POST, entity, String.class); + + if (response.getStatusCode() != HttpStatus.OK) throw new NotificationException(); + } + + public void addNotifications( + Member toMember, Member currentMember, String messageTemplate, NotificationType type) { + if (!Objects.equals(toMember.getId(), currentMember.getId()) + && type != NotificationType.CONNECT) { + List notificationTokens = currentMember.getNotificationTokens(); + + for (NotificationToken notificationToken : notificationTokens) { + Notification notification = new Notification(); + notification.setNotificationToken(notificationToken); + notification.setType(type); + + String message = String.format(messageTemplate, currentMember.getUsername()); + notification.setMessage(message); + notificationToken.getNotifications().add(notification); + + sendPushNotification(notificationToken.getPushToken(), message); + } + } + } } diff --git a/src/main/java/com/dife/api/service/ReportService.java b/src/main/java/com/dife/api/service/ReportService.java index 4a6d22e0..0c874fbe 100644 --- a/src/main/java/com/dife/api/service/ReportService.java +++ b/src/main/java/com/dife/api/service/ReportService.java @@ -25,7 +25,7 @@ public class ReportService { private final ModelMapper modelMapper; - public ReportResponseDto createDeclaration(ReportRequestDto requestDto, String memberEmail) { + public ReportResponseDto createReport(ReportRequestDto requestDto, String memberEmail) { Member member = memberRepository.findByEmail(memberEmail).orElseThrow(MemberNotFoundException::new); diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 1a231c5f..5c180f41 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -4,8 +4,16 @@ spring: on-profile: local jpa: + open-in-view: true hibernate: ddl-auto: create + defer-datasource-initialization: true + + + sql: + init: + mode: always + data-locations: classpath:import.sql aws: access-key: ${AWS_ACCESS_KEY_ID} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5af7c820..5df5624c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,6 @@ spring: jpa: database-platform: org.hibernate.dialect.MySQLDialect - open-in-view: false show-sql: true hibernate: ddl-auto: update diff --git a/src/main/resources/import.sql b/src/main/resources/import.sql new file mode 100644 index 00000000..eeb2e791 --- /dev/null +++ b/src/main/resources/import.sql @@ -0,0 +1,126 @@ +USE dife_local; + +SELECT * FROM member; +SELECT * FROM notification_token; +SELECT * FROM post; +SELECT * FROM comment; +SELECT * FROM post_likes; +SELECT * FROM comment_likes; +SELECT * FROM language; +SELECT * FROM hobby; + + +INSERT INTO member (ID, EMAIL, PASSWORD, USERNAME, NAME, STUDENT_ID, MAJOR, IS_KOREAN, IS_PUBLIC, MBTI, ROLE, BIO, IS_VERIFIED) +VALUES ('1', 'poream3387@kookmin.ac.kr', '$2a$10$Y/3KpS26JfwZl/.MCmpXd.n56NnFwfjkwaHQ5726.j69UQQ/gzgWi', 'poream', '이승호', '20181663', 'μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Ό', 1, 1, 'INTJ', 'ADMIN', 'hiiii', 1); + +INSERT INTO member (ID, EMAIL, PASSWORD, USERNAME, NAME, STUDENT_ID, MAJOR, IS_KOREAN, IS_PUBLIC, MBTI, ROLE, BIO, IS_VERIFIED) +VALUES ('2', '211_0@kookmin.ac.kr', '$2a$10$Y/3KpS26JfwZl/.MCmpXd.n56NnFwfjkwaHQ5726.j69UQQ/gzgWi', '211_0', 'ν•˜μ€μ˜','20210298', 'μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Ό', 1, 1, 'INTJ', 'ADMIN', 'hiiii', 1); + +INSERT INTO member (ID, EMAIL, PASSWORD, USERNAME, NAME, STUDENT_ID, MAJOR, IS_KOREAN, IS_PUBLIC, MBTI, ROLE, BIO, IS_VERIFIED) +VALUES ('3', 'stgood@kookmin.ac.kr', '$2a$10$Y/3KpS26JfwZl/.MCmpXd.n56NnFwfjkwaHQ5726.j69UQQ/gzgWi', 'stgood', 'κ΅¬μˆ˜μ—°', '20211863', 'μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Ό', 1, 1, 'ENTJ', 'ADMIN', 'hiiii', 1); + +INSERT INTO member (ID, EMAIL, PASSWORD, USERNAME, NAME, STUDENT_ID, MAJOR, IS_KOREAN, IS_PUBLIC, MBTI, ROLE, BIO, IS_VERIFIED) +VALUES ('4', 'syr820@kookmin.ac.kr', '$2a$10$Y/3KpS26JfwZl/.MCmpXd.n56NnFwfjkwaHQ5726.j69UQQ/gzgWi', 'syr820', 'μ„œμ˜ˆλ¦°', '20221575', 'κ³΅μ—…λ””μžμΈν•™κ³Ό', 1, 1, 'ENFJ', 'ADMIN', 'hiiii', 1); + +INSERT INTO member (ID, EMAIL, PASSWORD, USERNAME, NAME, STUDENT_ID, MAJOR, IS_KOREAN, IS_PUBLIC, MBTI, ROLE, BIO, IS_VERIFIED) +VALUES ('5', 'gusuyeon23@gmail.com', '$2a$10$Y/3KpS26JfwZl/.MCmpXd.n56NnFwfjkwaHQ5726.j69UQQ/gzgWi', 'sooya', 'κ΅¬μˆ˜μ—°', '20211863', 'μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Ό', 1, 1, 'ENTJ', 'ADMIN', 'Backend Suyeon Test account', 1); + +INSERT INTO language(ID, MEMBER_ID, NAME) +VALUES ('1', '5', 'KOREAN'); +INSERT INTO language(ID, MEMBER_ID, NAME) +VALUES ('2', '5', 'ENGLISH'); +INSERT INTO language(ID, MEMBER_ID, NAME) +VALUES ('3', '5', 'SPANISH'); + +INSERT INTO language(ID, MEMBER_ID, NAME) +VALUES ('4', '2', 'ENGLISH'); +INSERT INTO language(ID, MEMBER_ID, NAME) +VALUES ('5', '3', 'SPANISH'); + +INSERT INTO hobby(ID, MEMBER_ID, NAME) +VALUES ('1', '5', 'SOCCER'); +INSERT INTO hobby(ID, MEMBER_ID, NAME) +VALUES ('2', '5', 'BASEBALL'); +INSERT INTO hobby(ID, MEMBER_ID, NAME) +VALUES ('3', '5', 'MUKBANG'); +INSERT INTO hobby(ID, MEMBER_ID, NAME) +VALUES ('4', '5', 'SOCCER'); + +INSERT INTO notification_token(ID, MEMBER_ID, DEVICE_ID, PUSH_TOKEN) +VALUES ('1', '1', 'XXXX-XXXX-XXXX', 'pushToken1'); +INSERT INTO notification_token(ID, MEMBER_ID, DEVICE_ID, PUSH_TOKEN) +VALUES ('2', '2', 'XXXX-XXXX-XXXX', 'pushToken2'); +INSERT INTO notification_token(ID, MEMBER_ID, DEVICE_ID, PUSH_TOKEN) +VALUES ('3', '3', 'XXXX-XXXX-XXXX', 'pushToken3'); +INSERT INTO notification_token(ID, MEMBER_ID, DEVICE_ID, PUSH_TOKEN) +VALUES ('4', '4', 'XXXX-XXXX-XXXX', 'pushToken4'); +INSERT INTO notification_token(ID, MEMBER_ID, DEVICE_ID, PUSH_TOKEN) +VALUES ('5', '5', 'XXXX-XXXX-XXXX', 'pushToken5'); + +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('1', 1, '5', 'FREE 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 1', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'FREE', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('2', 1, '5', 'FREE 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 2', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'FREE', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('3', 0, '5', 'FREE λΉ„κ³΅κ°œ κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 3', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'FREE', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('4', 0, '3', 'FREE λΉ„κ³΅κ°œ κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 4', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'FREE', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('5', 1, '4', 'FREE 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 5', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'FREE', NOW()); + +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('6', 1, '2', 'TIP 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 1', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'TIP', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('7', 0, '1', 'TIP λΉ„κ³΅κ°œ κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 2', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'TIP', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('8', 1, '5', 'TIP 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 3', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'TIP', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('9', 0, '5', 'TIP λΉ„κ³΅κ°œ κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 4', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'TIP', NOW()); +INSERT INTO post (ID, IS_PUBLIC, MEMBER_ID, TITLE, CONTENT, BOARD_TYPE, CREATED) +VALUES ('10', 1, '5', 'TIP 곡개 κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ 5', 'κ²Œμ‹œκΈ€ ν…ŒμŠ€νŠΈ λ‚΄μš©', 'TIP', NOW()); + +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('1', 1, '5', '1', '곡개 λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('2', 1, '5', '1', '곡개 λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('3', 0, '5', '1', 'λΉ„κ³΅κ°œ λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('4', 0, '5', '2', 'λΉ„κ³΅κ°œ λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('5', 1, '5', '3', '곡개 λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, CONTENT, CREATED) +VALUES ('6', 1, '5', '4', '곡개 λŒ“κΈ€ λ‚΄μš©', NOW()); + +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('7', 1, '5', '1', '1', '곡개 λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('8', 1, '5', '1', '1', '곡개 λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('9', 0, '5', '1', '1', 'λΉ„κ³΅κ°œ λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('10', 0, '5', '1', '2', 'λΉ„κ³΅κ°œ λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); + + +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('11', 0, '5', '2', '1', 'λΉ„κ³΅κ°œ λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); +INSERT INTO comment (ID, IS_PUBLIC, WRITER_ID, POST_ID, PARENT_ID, CONTENT, CREATED) +VALUES ('12', 1, '5', '2', '1', 'λΉ„κ³΅κ°œ λŒ€λŒ“κΈ€ λ‚΄μš©', NOW()); + +INSERT INTO post_likes(ID, MEMBER_ID, POST_ID, CREATED) +VALUES ('1', '5', '1', NOW()); +INSERT INTO post_likes(ID, MEMBER_ID, POST_ID, CREATED) +VALUES ('2', '4', '1', NOW()); +INSERT INTO post_likes(ID, MEMBER_ID, POST_ID, CREATED) +VALUES ('3', '2', '1', NOW()); +INSERT INTO post_likes(ID, MEMBER_ID, POST_ID, CREATED) +VALUES ('4', '5', '2', NOW()); + +INSERT INTO comment_likes(ID, MEMBER_ID, COMMENT_ID, CREATED) +VALUES ('1', '5', '1', NOW()); +INSERT INTO comment_likes(ID, MEMBER_ID, COMMENT_ID, CREATED) +VALUES ('2', '5', '3', NOW()); +INSERT INTO comment_likes(ID, MEMBER_ID, COMMENT_ID, CREATED) +VALUES ('3', '5', '7', NOW()); +INSERT INTO comment_likes(ID, MEMBER_ID, COMMENT_ID, CREATED) +VALUES ('4', '2', '1', NOW()); diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index d430bd6f..a3921f1a 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -8,6 +8,12 @@ spring: hibernate: ddl-auto: create show-sql: true + defer-datasource-initialization: true + + sql: + init: + mode: always + main: allow-bean-definition-overriding: true aws: