Skip to content

Commit

Permalink
Merge pull request #58 from UniBond-jijijin/feature/56-get-liked-letter
Browse files Browse the repository at this point in the history
[feature/56-get-liked-letter] 즐겨찾기 한 편지들 조회
  • Loading branch information
5jisoo authored Dec 31, 2023
2 parents 4c626f5 + 35041f1 commit 69e5c5a
Show file tree
Hide file tree
Showing 15 changed files with 459 additions and 78 deletions.
6 changes: 3 additions & 3 deletions unibond/BOOT-INF/classes/static/docs/disease.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.10">
<meta name="author" content="Lucy Oh">
<title>Member API</title>
<title>Disease API</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
Expand Down Expand Up @@ -440,7 +440,7 @@
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>Member API</h1>
<h1>Disease API</h1>
<div class="details">
<span id="author" class="author">Lucy Oh</span><br>
<span id="revnumber">version 0.0.1-SNAPSHOT</span>
Expand Down Expand Up @@ -622,7 +622,7 @@ <h3 id="_response"><a class="link" href="#_response">Response</a></h3>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-12-31 03:53:40 +0900
Last updated 2023-12-31 04:53:57 +0900
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion unibond/BOOT-INF/classes/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ <h3 id="_letter_rooms"><a class="link" href="#_letter_rooms">Letter Rooms</a></h
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-12-31 04:06:59 +0900
Last updated 2023-12-31 04:53:18 +0900
</div>
</div>
</body>
Expand Down
42 changes: 39 additions & 3 deletions unibond/BOOT-INF/classes/static/docs/letter-rooms.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.10">
<meta name="author" content="Lucy Oh">
<title>Member API</title>
<title>Letter Room API</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
Expand Down Expand Up @@ -440,7 +440,7 @@
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>Member API</h1>
<h1>Letter Room API</h1>
<div class="details">
<span id="author" class="author">Lucy Oh</span><br>
<span id="revnumber">version 0.0.1-SNAPSHOT</span>
Expand Down Expand Up @@ -537,6 +537,24 @@ <h3 id="_response"><a class="link" href="#_response">Response</a></h3>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Authorization</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Basic auth credentials</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
Expand Down Expand Up @@ -652,6 +670,24 @@ <h3 id="_request_2"><a class="link" href="#_request_2">Request</a></h3>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Authorization</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Basic auth credentials</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
Expand Down Expand Up @@ -808,7 +844,7 @@ <h3 id="_response_2"><a class="link" href="#_response_2">Response</a></h3>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-12-31 04:39:02 +0900
Last updated 2023-12-31 04:53:41 +0900
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion unibond/BOOT-INF/classes/static/docs/member.html
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ <h3 id="_response"><a class="link" href="#_response">Response</a></h3>
"code" : 1000,
"message" : "요청에 성공하였습니다.",
"result" : {
"profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ec2cb752-c710-47b9-a01b-0b5c9ea7357atest_profile_img.jpg",
"profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/7b7a3e8e-e2f4-4b34-84fe-33cddd8a2256test_profile_img.jpg",
"nickname" : "5jizzi",
"gender" : "MALE",
"diseaseName" : "1번 염색체 장완 21.3 부분의 미세결손 증후군",
Expand Down
16 changes: 15 additions & 1 deletion unibond/src/docs/asciidoc/letter-rooms.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,24 @@ include::{snippets}/get_all_letter-rooms/response-fields.adoc[]
=== Request
include::{snippets}/get_all_letters_in_letter-rooms/http-request.adoc[]
include::{snippets}/get_all_letters_in_letter-rooms/request-headers.adoc[]
include::{snippets}/get_all_letters_in_letter-rooms/path-parameters.adoc[]
include::{snippets}/get_all_letters_in_letter-rooms/query-parameters.adoc[]


=== Response

include::{snippets}/get_all_letters_in_letter-rooms/http-response.adoc[]
include::{snippets}/get_all_letters_in_letter-rooms/response-fields.adoc[]
include::{snippets}/get_all_letters_in_letter-rooms/response-fields.adoc[]

== Get All Liked Letters

=== Request
include::{snippets}/get_all_liked_letters/http-request.adoc[]
include::{snippets}/get_all_liked_letters/request-headers.adoc[]
include::{snippets}/get_all_liked_letters/query-parameters.adoc[]


=== Response

include::{snippets}/get_all_liked_letters/http-response.adoc[]
include::{snippets}/get_all_liked_letters/response-fields.adoc[]
1 change: 1 addition & 0 deletions unibond/src/docs/asciidoc/member.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include::{snippets}/modify-member-info/httpie-request.adoc[]
include::{snippets}/modify-member-info/curl-request.adoc[]

include::{snippets}/modify-member-info/request-headers.adoc[]
include::{snippets}/modify-member-info/path-parameters.adoc[]
include::{snippets}/modify-member-info/request-parts.adoc[]
include::{snippets}/modify-member-info/request-part-request-fields.adoc[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Page<Letter> findLettersByLetterRoomAndReceiverOrSender(@Param("letterRoom") Lon
Boolean hasSentLetterToSamePersonWithinHour(@Param("sender") Long senderId, @Param("receiver") Long receiverId,
@Param("currentTimeMinusOneHour") LocalDateTime currentTimeMinusOneHour);

@Query("select l from Letter l " +
"join fetch l.receiver " +
"join fetch l.sender " +
"where l.liked = true and l.letterStatus = 'ARRIVED' and l.status = 'ACTIVE'")
Page<Letter> findLikedLetterByReceiver(@Param("receiver") Long receiverId, Pageable pageable);

@Modifying
@Query("update Letter l set l.letterStatus = 'ARRIVED' " +
"where l.createdDate <= :currentTimeMinusOneHour and l.letterStatus = 'SENDING'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public BaseResponse<?> getAllLetterRooms(@RequestHeader("Authorization") Long lo
}
}

@GetMapping("/like")
public BaseResponse<?> getAllLikedLetters(@RequestHeader("Authorization") Long loginId,
@PageableDefault(size = 30) Pageable pageable) {
try {
return new BaseResponse<>(letterRoomService.getAllLikeLetters(pageable));
} catch (BaseException e) {
return new BaseResponse<>(e.getStatus());
}
}

@GetMapping("/{letterRoomId}")
public BaseResponse<?> getAllLetters(@PathVariable("letterRoomId") Long letterRoomId,
@RequestHeader("Authorization") Long loginId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.unibond.unibond.letter_room.dto;

import com.unibond.unibond.common.PageInfo;
import com.unibond.unibond.letter.domain.Letter;
import com.unibond.unibond.member.domain.Member;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Page;

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

@NoArgsConstructor
@AllArgsConstructor
@Data
public class GetAllLikedLetterResDto {
private PageInfo pageInfo;
private List<LikedLetterPreviewDto> likedLetterList;

public GetAllLikedLetterResDto(Page<Letter> letterPage) {
this.pageInfo = new PageInfo(letterPage);
this.likedLetterList = letterPage.getContent().stream().map(
LikedLetterPreviewDto::new
).collect(Collectors.toList());
}

@Data
@NoArgsConstructor
@AllArgsConstructor
private class LikedLetterPreviewDto {
private String senderImg;
private LocalDateTime sentDate;
private String letterTitle;
private String senderName;

public LikedLetterPreviewDto(Letter letter) {
Member sender = letter.getSender();
this.senderImg = sender.getProfileImage();
this.sentDate = letter.getCreatedDate();
this.letterTitle = letter.getTitle();
this.senderName = sender.getNickname();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
import com.unibond.unibond.common.service.LoginInfoService;
import com.unibond.unibond.letter.domain.Letter;
import com.unibond.unibond.letter.repository.LetterRepository;
import com.unibond.unibond.letter_room.domain.LetterRoom;
import com.unibond.unibond.letter_room.dto.GetAllLetterRoomsResDto;
import com.unibond.unibond.letter_room.dto.GetAllLikedLetterResDto;
import com.unibond.unibond.letter_room.dto.GetLetterRoomDetailResDto;
import com.unibond.unibond.letter_room.repository.LetterRoomCustomRepository;
import com.unibond.unibond.letter_room.repository.LetterRoomRepository;
import com.unibond.unibond.letter_room.repository.repo_interface.LetterRoomPreviewRepoInterface;
import com.unibond.unibond.member.domain.Member;
import jdk.swing.interop.SwingInterOpUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.unibond.unibond.common.BaseResponseStatus.*;

@Service
Expand Down Expand Up @@ -66,4 +63,14 @@ private Member findAnotherParticipant(Letter letter, Long loginId) throws BaseEx
}
throw new BaseException(NOT_YOUR_LETTER_ROOM);
}

public GetAllLikedLetterResDto getAllLikeLetters(Pageable pageable) throws BaseException {
try {
Long loginMemberId = loginInfoService.getLoginMemberId();
Page<Letter> letterPage = letterRepository.findLikedLetterByReceiver(loginMemberId, pageable);
return new GetAllLikedLetterResDto(letterPage);
} catch (Exception e) {
throw new BaseException(DATABASE_ERROR);
}
}
}
48 changes: 24 additions & 24 deletions unibond/src/main/resources/static/docs/experience-community.html
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ <h3 id="_response"><a class="link" href="#_response">Response</a></h3>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 3423
Content-Length: 3664

{
"isSuccess" : true,
Expand All @@ -499,54 +499,54 @@ <h3 id="_response"><a class="link" href="#_response">Response</a></h3>
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/KakaoTalk_20230528_222457241_05.png",
"ownerNick" : "5jizzi",
"disease" : "13번 염색체 장완 21-22 부분의 결손",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 5",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-12-26T04:09:10.8631",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/21b949a4-ad87-4b83-a6ad-820981c3965c6808924_emoji_emoticon_emotion_expression_feeling_icon.png",
"ownerNick" : "jisoo2",
"disease" : "5번 염색체 장완의 결손 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/8d1501fb-00f4-477d-ac4c-51e98ea6b3adSimulator%20Screenshot%20-%20iPhone%2015%20Pro%20-%202023-12-19%20at%2021.53.29.png",
"ownerNick" : "GOGO",
"disease" : "종양 괴사 인자 수용체와 관련된 주기성 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 4",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-12-26T04:09:05.784257",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/21b949a4-ad87-4b83-a6ad-820981c3965c6808924_emoji_emoticon_emotion_expression_feeling_icon.png",
"ownerNick" : "jisoo2",
"disease" : "5번 염색체 장완의 결손 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/b0afd5ba-a19d-4913-b9c7-ff9dd7af2e82Simulator%20Screenshot%20-%20iPhone%2015%20Pro%20-%202023-12-31%20at%2018.06.36.png",
"ownerNick" : "GOGO24",
"disease" : "종양 괴사 인자 수용체와 관련된 주기성 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 3",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-12-26T04:02:22.167476",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/21b949a4-ad87-4b83-a6ad-820981c3965c6808924_emoji_emoticon_emotion_expression_feeling_icon.png",
"ownerNick" : "jisoo2",
"disease" : "5번 염색체 장완의 결손 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/7289b49a-d89e-412b-8cd2-f3e617b4528e2560px-React-icon.svg.png",
"ownerNick" : "12345",
"disease" : "3번 염색체 장완 26 부분의 중복",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 2",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-12-26T03:43:15.496574",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/21b949a4-ad87-4b83-a6ad-820981c3965c6808924_emoji_emoticon_emotion_expression_feeling_icon.png",
"ownerNick" : "jisoo2",
"disease" : "5번 염색체 장완의 결손 증후군",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/KakaoTalk_20230528_222457241_05.png",
"ownerNick" : "asdf",
"disease" : "13번 염색체 장완 21-22 부분의 결손",
"contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 1 ",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-11-16T14:18:33.129163",
"ownerProfileImg" : "http://testimg3",
"ownerNick" : "jiwoon",
"disease" : "뇌하수체-의존 부신피질기능항진증",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/8d1501fb-00f4-477d-ac4c-51e98ea6b3adSimulator%20Screenshot%20-%20iPhone%2015%20Pro%20-%202023-12-19%20at%2021.53.29.png",
"ownerNick" : "GOGO",
"disease" : "종양 괴사 인자 수용체와 관련된 주기성 증후군",
"contentPreview" : "create post test by jiwon",
"boardType" : "EXPERIENCE",
"isEnd" : true
}, {
"createdDate" : "2023-11-16T13:55:27.91433",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/21b949a4-ad87-4b83-a6ad-820981c3965c6808924_emoji_emoticon_emotion_expression_feeling_icon.png",
"ownerNick" : "jisoo2",
"disease" : "5번 염색체 장완의 결손 증후군",
"ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/b0afd5ba-a19d-4913-b9c7-ff9dd7af2e82Simulator%20Screenshot%20-%20iPhone%2015%20Pro%20-%202023-12-31%20at%2018.06.36.png",
"ownerNick" : "GOGO24",
"disease" : "종양 괴사 인자 수용체와 관련된 주기성 증후군",
"contentPreview" : "create post test by jisoo",
"boardType" : "EXPERIENCE",
"isEnd" : true
Expand Down
Loading

0 comments on commit 69e5c5a

Please sign in to comment.