diff --git a/unibond/BOOT-INF/classes/static/docs/community.html b/unibond/BOOT-INF/classes/static/docs/community.html index 4b4278c..3d51dc6 100644 --- a/unibond/BOOT-INF/classes/static/docs/community.html +++ b/unibond/BOOT-INF/classes/static/docs/community.html @@ -561,7 +561,22 @@

Response

"commentUserName" : "찍사", "commentId" : 28, "createdDate" : "2023-12-04T16:20:31.039816", - "content" : "사진이 너무 멋있는데요??\uD83D\uDE0E" + "content" : "사진이 너무 멋있는데요??\uD83D\uDE0E", + "childCommentPageInfo" : { + "numberOfElements" : 1, + "lastPage" : true, + "totalPages" : 1, + "totalElements" : 1, + "size" : 30 + }, + "childCommentList" : [ { + "commentUserId" : 32, + "profileImgUrl" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/0ee1ae29-e205-4107-9a4d-69ffa68e98ecmountaineers-5649828_640.jpg", + "commentUserName" : "건강렛츠고", + "commentId" : 30, + "createdDate" : "2024-01-03T01:24:59.326471", + "content" : "파하핫 하핫 기분이 좋네요 제가 좀 치죠?\uD83D\uDCF8" + } ] }, { "commentUserId" : 29, "profileImgUrl" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", diff --git a/unibond/BOOT-INF/classes/static/docs/experience-community.html b/unibond/BOOT-INF/classes/static/docs/experience-community.html index 81a4ac6..a41bd23 100644 --- a/unibond/BOOT-INF/classes/static/docs/experience-community.html +++ b/unibond/BOOT-INF/classes/static/docs/experience-community.html @@ -504,7 +504,7 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 4969
+Content-Length: 2479
 
 {
   "isSuccess" : true,
@@ -512,13 +512,24 @@ 

Response

"message" : "요청에 성공하였습니다.", "result" : { "pageInfo" : { - "numberOfElements" : 7, + "numberOfElements" : 3, "lastPage" : true, "totalPages" : 1, - "totalElements" : 7, + "totalElements" : 3, "size" : 30 }, "postPreviewList" : [ { + "createdDate" : "2024-01-03T01:30:08.746334", + "ownerId" : 27, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ef3a45d1-4eb3-48a5-af19-92b0b42aee2bnight-1927265_640.jpg", + "ownerNick" : "찍사", + "disease" : "분열뇌증", + "postId" : 68, + "postImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/post/2bd26dac-d165-41be-a0d1-c45b4d35a621KakaoTalk_20240103_010020693.jpg", + "contentPreview" : "크리스마스에 다들 뭐하셨나요? \uD83C\uDF85 저는 정말 거대한 트리를 목격했답니다. 연말은", + "boardType" : "EXPERIENCE", + "isEnd" : false + }, { "createdDate" : "2024-01-03T01:13:39.116094", "ownerId" : 32, "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/0ee1ae29-e205-4107-9a4d-69ffa68e98ecmountaineers-5649828_640.jpg", @@ -529,61 +540,6 @@

Response

"contentPreview" : "아무리 환자라도 공부할 건 해아죠ㅋㅋ\uD83D\uDE31 다들 시험 별로 안남으셨을 텐데 공부 잘", "boardType" : "EXPERIENCE", "isEnd" : false - }, { - "createdDate" : "2024-01-01T04:02:22.167476", - "ownerId" : 30, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/3b6fc68f-808c-4e22-97e8-9447d6916bc5cat-2068462_640.jpg", - "ownerNick" : "눈송이네 베이킹", - "disease" : "8번 삼염색체 섞임증", - "postId" : 12, - "postImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/post/31f7130c-b08e-48e3-ba0a-ebd791ecf960test-img.jpg", - "contentPreview" : "앱스 아자아자 파이팅! 유니본드도 파이팅! 아자아자아자뵤 앱스 아자아자 파이팅! ", - "boardType" : "EXPERIENCE", - "isEnd" : false - }, { - "createdDate" : "2023-12-27T03:16:53.252948", - "ownerId" : 29, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", - "ownerNick" : "시험왕", - "disease" : "블륨 증후군", - "postId" : 26, - "postImg" : "", - "contentPreview" : "우리나라어가 세계 공통어가 된다면... 나는 당장 한국어 과외를 시작할 것이다. ", - "boardType" : "EXPERIENCE", - "isEnd" : false - }, { - "createdDate" : "2023-12-26T04:09:10.8631", - "ownerId" : 31, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/b8602030-7b09-4f2c-bfb4-b9140c73f72afitness-594143_640.jpg", - "ownerNick" : "헬스파트너", - "disease" : "5번 염색체 장완의 결손 증후군", - "postId" : 14, - "postImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/post/31f7130c-b08e-48e3-ba0a-ebd791ecf960test-img.jpg", - "contentPreview" : "경험 기록 게시판 게시물 업로드 테스트 이모티콘도 잘 보이나 헤헷\uD83C\uDF89\uD83C\uDF89\uD83C\uDF89\uD83C\uDF89 ", - "boardType" : "EXPERIENCE", - "isEnd" : false - }, { - "createdDate" : "2023-12-26T04:09:05.784257", - "ownerId" : 32, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/0ee1ae29-e205-4107-9a4d-69ffa68e98ecmountaineers-5649828_640.jpg", - "ownerNick" : "건강렛츠고", - "disease" : "종양 괴사 인자 수용체와 관련된 주기성 증후군", - "postId" : 13, - "postImg" : "", - "contentPreview" : "경험 기록 게시판 게시물 진짜 개많네", - "boardType" : "EXPERIENCE", - "isEnd" : true - }, { - "createdDate" : "2023-12-26T03:43:15.496574", - "ownerId" : 28, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", - "ownerNick" : "서울의가을", - "disease" : "피어슨 증후군[Pierson syndrome]", - "postId" : 11, - "postImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/post/code-944499_640.jpg", - "contentPreview" : "드디어 1년 간 제가 개발한 서비스가 출시했어요! 제가 많이 늦고, 서투르지만 친", - "boardType" : "EXPERIENCE", - "isEnd" : false }, { "createdDate" : "2023-12-03T00:39:17.136017", "ownerId" : 32, diff --git a/unibond/BOOT-INF/classes/static/docs/member.html b/unibond/BOOT-INF/classes/static/docs/member.html index 0968fda..0161824 100644 --- a/unibond/BOOT-INF/classes/static/docs/member.html +++ b/unibond/BOOT-INF/classes/static/docs/member.html @@ -557,7 +557,7 @@

Response

"diseaseName" : "블륨 증후군", "diagnosisTiming" : "2002-06-27", "bio" : "안녕하세요 친하게 지내요^^", - "interestList" : [ "개발", "코딩", "운동" ] + "interestList" : [ "만화/애니메이션", "등산", "운동" ] } }
@@ -723,12 +723,12 @@

Response

"diseaseName" : "블륨 증후군", "diagnosisTiming" : "2002-06-27", "bio" : "안녕하세요 친하게 지내요^^", - "interestList" : [ "개발", "코딩", "운동" ], + "interestList" : [ "만화/애니메이션", "등산", "운동" ], "pageInfo" : { - "numberOfElements" : 2, + "numberOfElements" : 1, "lastPage" : true, "totalPages" : 1, - "totalElements" : 2, + "totalElements" : 1, "size" : 30 }, "postPreviewList" : [ { @@ -742,17 +742,6 @@

Response

"contentPreview" : "급하게 친구들끼리 여행을 가게 될 일이 생겼어요. 사실 이동하는 게 많이 어려워서", "boardType" : "QNA", "isEnd" : false - }, { - "createdDate" : "2023-12-27T03:16:53.252948", - "ownerId" : 29, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", - "ownerNick" : "시험왕", - "disease" : "블륨 증후군", - "postId" : 26, - "postImg" : "", - "contentPreview" : "우리나라어가 세계 공통어가 된다면... 나는 당장 한국어 과외를 시작할 것이다. ", - "boardType" : "EXPERIENCE", - "isEnd" : false } ] } } @@ -1087,20 +1076,20 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 545
+Content-Length: 561
 
 {
   "isSuccess" : true,
   "code" : 1000,
   "message" : "요청에 성공하였습니다.",
   "result" : {
-    "profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/fe0cdfc6-ba75-42ab-a3b0-67dc5ab2be0atest_profile_img.jpg",
+    "profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/23f6cba6-49f5-4e12-a316-034965eabe1ftest_profile_img.jpg",
     "nickname" : "시험왕",
     "gender" : "MALE",
     "diseaseName" : "1번 염색체 장완 21.3 부분의 미세결손 증후군",
     "diagnosisTiming" : "2002-06-27",
     "bio" : "수정 테스트를 해봅시다",
-    "interestList" : [ "개발", "코딩", "운동" ]
+    "interestList" : [ "만화/애니메이션", "등산", "운동" ]
   }
 }
diff --git a/unibond/BOOT-INF/classes/static/docs/question-community.html b/unibond/BOOT-INF/classes/static/docs/question-community.html index f569349..0e5ad3e 100644 --- a/unibond/BOOT-INF/classes/static/docs/question-community.html +++ b/unibond/BOOT-INF/classes/static/docs/question-community.html @@ -498,7 +498,7 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 2507
+Content-Length: 2002
 
 {
   "isSuccess" : true,
@@ -506,24 +506,13 @@ 

Response

"message" : "요청에 성공하였습니다.", "result" : { "pageInfo" : { - "numberOfElements" : 4, + "numberOfElements" : 3, "lastPage" : true, "totalPages" : 1, - "totalElements" : 4, + "totalElements" : 3, "size" : 30 }, "postPreviewList" : [ { - "createdDate" : "2024-01-03T00:57:12.641472", - "ownerId" : 28, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", - "ownerNick" : "서울의가을", - "disease" : "피어슨 증후군[Pierson syndrome]", - "postId" : 62, - "postImg" : null, - "contentPreview" : "학교에 다니면서 친구들한테 어떻게 이 병에 대해 솔직하게 털어놨는지 다들 계기가 ", - "boardType" : "QNA", - "isEnd" : false - }, { "createdDate" : "2023-12-30T00:40:29.237761", "ownerId" : 29, "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", @@ -535,16 +524,16 @@

Response

"boardType" : "QNA", "isEnd" : false }, { - "createdDate" : "2023-12-25T18:42:48.293668", - "ownerId" : 30, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/3b6fc68f-808c-4e22-97e8-9447d6916bc5cat-2068462_640.jpg", - "ownerNick" : "눈송이네 베이킹", - "disease" : "8번 삼염색체 섞임증", - "postId" : 10, - "postImg" : "", - "contentPreview" : "질문 게시판 오바 여긴 질문 게시판", + "createdDate" : "2023-11-12T00:57:12.641472", + "ownerId" : 28, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", + "ownerNick" : "서울의가을", + "disease" : "피어슨 증후군[Pierson syndrome]", + "postId" : 62, + "postImg" : null, + "contentPreview" : "학교에 다니면서 친구들한테 어떻게 이 병에 대해 솔직하게 털어놨는지 다들 계기가 ", "boardType" : "QNA", - "isEnd" : true + "isEnd" : false }, { "createdDate" : "2023-10-03T00:41:51.650698", "ownerId" : 30, diff --git a/unibond/build.gradle b/unibond/build.gradle index 2d05b93..1a76fb7 100644 --- a/unibond/build.gradle +++ b/unibond/build.gradle @@ -28,7 +28,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'javax.validation:validation-api:2.0.1.Final' - // https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-aws implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' compileOnly 'org.projectlombok:lombok' diff --git a/unibond/src/docs/asciidoc/member.adoc b/unibond/src/docs/asciidoc/member.adoc index 6259245..bc06676 100644 --- a/unibond/src/docs/asciidoc/member.adoc +++ b/unibond/src/docs/asciidoc/member.adoc @@ -11,6 +11,20 @@ ifndef::snippets[] :snippets: ./build/generated-snippets endif::[] +== Sign Up - V1 + +회원가입 V1 (프로필 사진 제외) + +=== Request + +include::{snippets}/sign-up-member_v1/http-request.adoc[] +include::{snippets}/sign-up-member_v1/request-fields.adoc[] + +=== Response + +include::{snippets}/sign-up-member_v1/response-body.adoc[] +include::{snippets}/sign-up-member_v1/response-fields.adoc[] + == Get My Profile Info 자신의 프로필 조회하기 @@ -43,7 +57,25 @@ include::{snippets}/get_other_profile/query-parameters.adoc[] include::{snippets}/get_other_profile/response-body.adoc[] include::{snippets}/get_other_profile/response-fields.adoc[] -== Modify Member Info +== Modify Member Info - V1 + +멤버 정보 수정하기 V1 (프로필 사진 변경 제외) + +=== Request + +include::{snippets}/modify-member-info_v1/http-request.adoc[] + +include::{snippets}/modify-member-info_v1/request-headers.adoc[] +include::{snippets}/modify-member-info_v1/path-parameters.adoc[] +- 단, 변경할 property만 body를 통해 전송해야 합니다. +include::{snippets}/modify-member-info_v1/request-fields.adoc[] + +=== Response + +include::{snippets}/modify-member-info_v1/http-response.adoc[] +include::{snippets}/modify-member-info_v1/response-fields.adoc[] + +== Modify Member Info - V2 멤버 정보 수정하기 diff --git a/unibond/src/main/java/com/unibond/unibond/common/BaseResponseStatus.java b/unibond/src/main/java/com/unibond/unibond/common/BaseResponseStatus.java index b59accd..f5c8aff 100644 --- a/unibond/src/main/java/com/unibond/unibond/common/BaseResponseStatus.java +++ b/unibond/src/main/java/com/unibond/unibond/common/BaseResponseStatus.java @@ -46,8 +46,9 @@ public enum BaseResponseStatus { // member (2500 ~ 2599) INVALID_MEMBER_ID(false, 2500, "유효하지 않은 멤버 id 입니다."), - DUPLICATE_MEMBER_NICK(false, 2501, "중복되는 닉네임입니다."), - NOT_YOUR_PROFILE(false, 2502, "자신의 프로필이 아니므로 수정할 수 없습니다."), + TOO_LONG_NICKNAME(false, 2501, "설정한 닉네임이 너무 깁니다"), + DUPLICATE_MEMBER_NICK(false, 2502, "중복되는 닉네임입니다."), + NOT_YOUR_PROFILE(false, 2503, "자신의 프로필이 아니므로 수정할 수 없습니다."), // post (2600 ~ 2699) INVALID_POST_ID(false, 2600, "유효하지 않은 게시글 id 입니다"), diff --git a/unibond/src/main/java/com/unibond/unibond/member/controller/MemberController.java b/unibond/src/main/java/com/unibond/unibond/member/controller/MemberController.java index 7b3e187..5081a9d 100644 --- a/unibond/src/main/java/com/unibond/unibond/member/controller/MemberController.java +++ b/unibond/src/main/java/com/unibond/unibond/member/controller/MemberController.java @@ -17,11 +17,19 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/v1/members") public class MemberController { private final MemberService memberService; - @PostMapping(value = "", consumes = {APPLICATION_JSON_VALUE, MULTIPART_FORM_DATA_VALUE}) + @PostMapping("/api/v1/members") + public BaseResponse signup(@RequestBody MemberRegisterReqDto request) { + try { + return new BaseResponse<>(memberService.signupWithNoProfileImg(request)); + } catch (BaseException e) { + return new BaseResponse<>(e.getStatus()); + } + } + + @PostMapping(value = "/api/v2/members", consumes = {APPLICATION_JSON_VALUE, MULTIPART_FORM_DATA_VALUE}) public BaseResponse signup(@RequestPart MemberRegisterReqDto request, @RequestPart MultipartFile profileImg) { try { @@ -31,7 +39,7 @@ public BaseResponse signup(@RequestPart MemberRegisterReqDto request, } } - @GetMapping("/duplicate") + @GetMapping("/api/v1/members/duplicate") public BaseResponse checkNickDuplicate(@RequestParam("nickname") String nickname) { try { return new BaseResponse<>(memberService.checkNickNameDuplicate(nickname)); @@ -40,7 +48,7 @@ public BaseResponse checkNickDuplicate(@RequestParam("nickname") String nickn } } - @GetMapping("/{memberId}") + @GetMapping("/api/v1/members/{memberId}") public BaseResponse getMemberDetail(@PathVariable("memberId") Long memberId, @RequestHeader("Authorization") Long loginId, @PageableDefault(size = 30) Pageable pageable) { @@ -51,7 +59,21 @@ public BaseResponse getMemberDetail(@PathVariable("memberId") Long memberId, } } - @PatchMapping(value = "/{memberId}", consumes = {APPLICATION_JSON_VALUE, MULTIPART_FORM_DATA_VALUE}) + @PatchMapping("/api/v1/members/{memberId}") + public BaseResponse modifyMemberInfo(@PathVariable("memberId") Long memberId, + @RequestBody(required = false) MemberModifyReqDto request, + @RequestHeader("Authorization") Long loginId) { + try { + if (!memberId.equals(loginId)) { + throw new BaseException(NOT_YOUR_PROFILE); + } + return new BaseResponse<>(memberService.modifyMemberInfoWithoutProfileImg(request)); + } catch (BaseException e) { + return new BaseResponse<>(e.getStatus()); + } + } + + @PatchMapping(value = "/api/v2/members/{memberId}", consumes = {APPLICATION_JSON_VALUE, MULTIPART_FORM_DATA_VALUE}) public BaseResponse modifyMemberInfo(@PathVariable("memberId") Long memberId, @RequestPart(required = false) MemberModifyReqDto request, @RequestPart(required = false) MultipartFile profileImg, diff --git a/unibond/src/main/java/com/unibond/unibond/member/domain/Member.java b/unibond/src/main/java/com/unibond/unibond/member/domain/Member.java index 95b9b73..933dfab 100644 --- a/unibond/src/main/java/com/unibond/unibond/member/domain/Member.java +++ b/unibond/src/main/java/com/unibond/unibond/member/domain/Member.java @@ -68,6 +68,10 @@ public Member(String profileImage, String nickname, Gender gender, Disease disea this.interestSet = interestSet; } + public void modifyMember(MemberModifyReqDto reqDto, Disease disease) { + modifyMember(reqDto, disease, null); + } + public void modifyMember(MemberModifyReqDto reqDto, Disease disease, String profileImgUrl) { this.profileImage = propertyNullCheck(profileImgUrl, this.profileImage); this.nickname = propertyNullCheck(reqDto.getNickname(), this.nickname); diff --git a/unibond/src/main/java/com/unibond/unibond/member/dto/MemberRegisterReqDto.java b/unibond/src/main/java/com/unibond/unibond/member/dto/MemberRegisterReqDto.java index 89c3f31..aa3ffd4 100644 --- a/unibond/src/main/java/com/unibond/unibond/member/dto/MemberRegisterReqDto.java +++ b/unibond/src/main/java/com/unibond/unibond/member/dto/MemberRegisterReqDto.java @@ -4,12 +4,15 @@ import com.unibond.unibond.member.domain.Gender; import com.unibond.unibond.member.domain.Member; import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; import java.time.LocalDate; import java.util.HashSet; import java.util.List; @Data +@NoArgsConstructor public class MemberRegisterReqDto { private Long diseaseId; private LocalDate diseaseTiming; @@ -18,6 +21,18 @@ public class MemberRegisterReqDto { private String bio; private List interestList; + public Member toEntity(Disease disease) { + HashSet interestSet = new HashSet<>(interestList); + return Member.builder() + .disease(disease) + .diagnosisTiming(this.diseaseTiming) + .gender(gender) + .nickname(this.nickname) + .bio(this.bio) + .interestSet(interestSet) + .build(); + } + public Member toEntity(Disease disease, String imgUrl) { HashSet interestSet = new HashSet<>(interestList); return Member.builder() diff --git a/unibond/src/main/java/com/unibond/unibond/member/service/MemberService.java b/unibond/src/main/java/com/unibond/unibond/member/service/MemberService.java index 837df87..ec1750c 100644 --- a/unibond/src/main/java/com/unibond/unibond/member/service/MemberService.java +++ b/unibond/src/main/java/com/unibond/unibond/member/service/MemberService.java @@ -31,6 +31,31 @@ public class MemberService { private final DiseaseRepository diseaseRepository; private final PostRepository postRepository; + @Transactional + public Long signupWithNoProfileImg(MemberRegisterReqDto registerReqDto) throws BaseException { + try { + if (registerReqDto.getNickname().length() > 10) { + throw new BaseException(TOO_LONG_NICKNAME); + } + + if (memberRepository.existsMemberByNickname(registerReqDto.getNickname())) { + throw new BaseException(DUPLICATE_MEMBER_NICK); + } + + Disease disease = diseaseRepository.findById(registerReqDto.getDiseaseId()).orElseThrow( + () -> new BaseException(INVALID_DISEASE_ID) + ); + Member newMember = registerReqDto.toEntity(disease); + Member savedMember = memberRepository.save(newMember); + return savedMember.getId(); + } catch (BaseException e) { + throw e; + } catch (Exception e) { + System.err.println(e); + throw new BaseException(DATABASE_ERROR); + } + } + @Transactional public Long signupMember(MemberRegisterReqDto registerReqDto, MultipartFile profileImg) throws BaseException { try { @@ -67,6 +92,27 @@ public BaseResponseStatus checkNickNameDuplicate(String nickname) throws BaseExc } } + @Transactional + public MemberDetailResDto modifyMemberInfoWithoutProfileImg(MemberModifyReqDto reqDto) throws BaseException { + try { + Member member = loginInfoService.getLoginMember(); + + Disease disease = null; + if (reqDto.getDiseaseId() != null) { + disease = diseaseRepository.findById(reqDto.getDiseaseId()) + .orElseThrow(() -> new BaseException(INVALID_DISEASE_ID)); + } + + member.modifyMember(reqDto, disease); + return getMyProfileInfo(loginInfoService.getLoginMemberId()); + } catch (BaseException e) { + throw e; + } catch (Exception e) { + System.err.println(e); + throw new BaseException(DATABASE_ERROR); + } + } + @Transactional public MemberDetailResDto modifyMemberInfo(MemberModifyReqDto reqDto, MultipartFile profileImg) throws BaseException { try { diff --git a/unibond/src/main/resources/static/docs/letter-rooms.html b/unibond/src/main/resources/static/docs/letter-rooms.html index 64abd21..10fa8e5 100644 --- a/unibond/src/main/resources/static/docs/letter-rooms.html +++ b/unibond/src/main/resources/static/docs/letter-rooms.html @@ -511,7 +511,7 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json
-Content-Length: 616
+Content-Length: 649
 
 {
   "isSuccess" : true,
@@ -519,7 +519,7 @@ 

Response

"message" : "요청에 성공하였습니다.", "result" : { "letterRoomList" : [ { - "senderProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", + "senderProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/025cc515-c832-4c29-9fe0-9e77f0afea7d6808929_emoji_emoticon_emotion_expression_face_icon.png", "senderNick" : "서울의가을", "senderId" : 28, "recentLetterSentDate" : "2024-01-01T02:37:54.084", @@ -731,7 +731,7 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json
-Content-Length: 1040
+Content-Length: 1073
 
 {
   "isSuccess" : true,
@@ -739,7 +739,7 @@ 

Response

"message" : "요청에 성공하였습니다.", "result" : { "receiverId" : 28, - "receiverProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", + "receiverProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/025cc515-c832-4c29-9fe0-9e77f0afea7d6808929_emoji_emoticon_emotion_expression_face_icon.png", "receiverName" : "서울의가을", "receiverDiseaseName" : "피어슨 증후군[Pierson syndrome]", "receiverDiagnosisTiming" : "2023-11-10", diff --git a/unibond/src/main/resources/static/docs/member.html b/unibond/src/main/resources/static/docs/member.html index 0161824..c84da9f 100644 --- a/unibond/src/main/resources/static/docs/member.html +++ b/unibond/src/main/resources/static/docs/member.html @@ -448,36 +448,172 @@

Member API

+

Sign Up - V1

+
+
+

회원가입 V1 (프로필 사진 제외)

+
+
+

Request

+
+
+
POST /api/v1/members HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Accept: application/json
+Content-Length: 235
+Host: localhost:8080
+
+{
+  "diseaseId" : 1,
+  "diseaseTiming" : "2024-01-06",
+  "gender" : "FEMALE",
+  "nickname" : "안녕하세요닉네임",
+  "bio" : "안녕하세요 한 줄 소개 작성합니다.",
+  "interestList" : [ "운동", "환우회" ]
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

diseaseId

Number

질병 ID : 검색 API를 통해 검색해서 가져옵니다.

diseaseTiming

String

질병 진단 시기 ex) 2002-06-27

gender

String

성별 : NULL, MALE, FEMALE

nickname

String

닉네임: 중복 체크에 유의하기, 10자 이상 작성 불가능

bio

String

한 줄 소개

interestList

Array

관심사 리스트: 문자열 리스트로 전달해주면 됨.

+
+
+

Response

+
+
+
{
+  "isSuccess" : true,
+  "code" : 1000,
+  "message" : "요청에 성공하였습니다.",
+  "result" : 39
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

isSuccess

Boolean

성공 여부

code

Number

결과 코드

message

String

결과 메세지

result

Number

생성된 멤버의 로그인 아이디

+
+
+
+

Get My Profile Info

자신의 프로필 조회하기

-

Request

+

Request

GET /api/v1/members/29?page=0 HTTP/1.1
@@ -543,7 +679,7 @@ 

Request

-

Response

+

Response

{
@@ -557,7 +693,7 @@ 

Response

"diseaseName" : "블륨 증후군", "diagnosisTiming" : "2002-06-27", "bio" : "안녕하세요 친하게 지내요^^", - "interestList" : [ "만화/애니메이션", "등산", "운동" ] + "interestList" : [ "영화/드라마", "친목", "운동" ] } }
@@ -643,7 +779,7 @@

-

Request

+

Request

GET /api/v1/members/29?page=0 HTTP/1.1
@@ -709,7 +845,7 @@ 

Request

-

Response

+

Response

{
@@ -723,15 +859,103 @@ 

Response

"diseaseName" : "블륨 증후군", "diagnosisTiming" : "2002-06-27", "bio" : "안녕하세요 친하게 지내요^^", - "interestList" : [ "만화/애니메이션", "등산", "운동" ], + "interestList" : [ "영화/드라마", "친목", "운동" ], "pageInfo" : { - "numberOfElements" : 1, + "numberOfElements" : 9, "lastPage" : true, "totalPages" : 1, - "totalElements" : 1, + "totalElements" : 9, "size" : 30 }, "postPreviewList" : [ { + "createdDate" : "2024-01-06T06:07:59.413161", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 79, + "postImg" : null, + "contentPreview" : "아아\n글 왜 쓰면 풀투리프레쉬 없어ㅍ졋ㅆ지...", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-04T12:24:22.161686", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 78, + "postImg" : null, + "contentPreview" : "글 작성도 아주 잘 됩니다! 하지만 속도는 조금 느려요.. 어쩔수가없네ㅠ 성능개선", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-04T12:11:05.969729", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 77, + "postImg" : null, + "contentPreview" : "글도 쓸 수 있다! 난 너무 행복해 해 자동완성 왜 되냐;; 킹받네...나 밥도 ", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-04T01:09:39.566862", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 76, + "postImg" : null, + "contentPreview" : "안녕하시렵니까? 잘 써지나유", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-03T23:29:05.627646", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 75, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다,,,,,이이이이이이이이이이이이이이이이ㅣㅇ이이이", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-03T23:26:28.345496", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 74, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다,,,,,이이이이이이이이이이이이이이이이ㅣㅇ이이이", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-03T23:26:09.69247", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 73, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-03T22:16:28.436585", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 72, + "postImg" : null, + "contentPreview" : "이것은 질문 게시판의 게시물인데, 작성이 잘 될까요? 궁금합니다. 저는 빨리좀 하", + "boardType" : "QNA", + "isEnd" : false + }, { "createdDate" : "2023-12-30T00:40:29.237761", "ownerId" : 29, "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", @@ -907,16 +1131,233 @@

Response

-

Modify Member Info

+

Modify Member Info - V1

-

멤버 정보 수정하기

+

멤버 정보 수정하기 V1 (프로필 사진 변경 제외)

-

Request

+

Request

PATCH /api/v1/members/29 HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Authorization: 29
+Authorization: 29
+Accept: application/json
+Content-Length: 194
+Host: localhost:8080
+
+{
+  "nickname" : null,
+  "gender" : "NULL",
+  "diseaseId" : 3,
+  "diagnosisTiming" : null,
+  "bio" : "안녕하세요 수정된 한 줄 소개 작성합니다.",
+  "interestList" : null
+}
+
+
+ ++++ + + + + + + + + + + + + +
NameDescription

Authorization

Basic auth credentials

+ + ++++ + + + + + + + + + + + + +
Table 3. /api/v1/members/{memberId}
ParameterDescription

memberId

수정할 memberId: 로그인한 아이디와 동일해야 수정이 가능합니다.

+
+
    +
  • +

    단, 변경할 property만 body를 통해 전송해야 합니다.

    +
  • +
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

diseaseId

Number

질병 ID : 검색 API를 통해 검색해서 가져옵니다.

diagnosisTiming

String

질병 진단 시기 ex) 2002-06-27

gender

String

성별 : NULL, MALE, FEMALE

nickname

String

닉네임: 중복 체크에 유의하기, 10자 이상 작성 불가능

bio

String

한 줄 소개

interestList

Array

관심사 리스트: 문자열 리스트로 전달해주면 됨.

+
+
+

Response

+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json;charset=UTF-8
+Content-Length: 574
+
+{
+  "isSuccess" : true,
+  "code" : 1000,
+  "message" : "요청에 성공하였습니다.",
+  "result" : {
+    "profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg",
+    "nickname" : "시험왕",
+    "gender" : "NULL",
+    "diseaseName" : "10번 염색체 장완 말단부의 단일염색체증",
+    "diagnosisTiming" : "2002-06-27",
+    "bio" : "안녕하세요 수정된 한 줄 소개 작성합니다.",
+    "interestList" : [ "영화/드라마", "친목", "운동" ]
+  }
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

isSuccess

Boolean

성공 여부

code

Number

결과 코드

message

String

결과 메세지

result

Object

결과 데이터

result.profileImage

String

프로필 사진

result.nickname

String

닉네임

result.gender

String

성별

result.diseaseName

String

질병명

result.diagnosisTiming

String

진단 시기

result.bio

String

한 줄 소개

result.interestList

Array

관심사

+
+
+
+
+

Modify Member Info - V2

+
+
+

멤버 정보 수정하기

+
+
+

Request

+
+
+
PATCH /api/v2/members/29 HTTP/1.1
 Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
 Authorization: 29
 Host: localhost:8080
@@ -924,7 +1365,7 @@

Request

-
$ http --multipart PATCH 'http://localhost:8080/api/v1/members/29' \
+
$ http --multipart PATCH 'http://localhost:8080/api/v2/members/29' \
     'Authorization:29' \
     'profileImg'@'test_profile_img.jpg' \
     'request'@'request'
@@ -932,7 +1373,7 @@

Request

-
$ curl 'http://localhost:8080/api/v1/members/29' -i -X PATCH \
+
$ curl 'http://localhost:8080/api/v2/members/29' -i -X PATCH \
     -H 'Content-Type: multipart/form-data;charset=UTF-8' \
     -H 'Authorization: 29' \
     -F 'profileImg=@test_profile_img.jpg;type=multipart/form-data' \
@@ -958,7 +1399,7 @@ 

Request

- +@@ -1071,25 +1512,25 @@

Request

-

Response

+

Response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 561
+Content-Length: 555
 
 {
   "isSuccess" : true,
   "code" : 1000,
   "message" : "요청에 성공하였습니다.",
   "result" : {
-    "profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/23f6cba6-49f5-4e12-a316-034965eabe1ftest_profile_img.jpg",
+    "profileImage" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/5bb0336a-8496-49d2-85a0-86ba1755d9b2test_profile_img.jpg",
     "nickname" : "시험왕",
     "gender" : "MALE",
     "diseaseName" : "1번 염색체 장완 21.3 부분의 미세결손 증후군",
     "diagnosisTiming" : "2002-06-27",
     "bio" : "수정 테스트를 해봅시다",
-    "interestList" : [ "만화/애니메이션", "등산", "운동" ]
+    "interestList" : [ "영화/드라마", "친목", "운동" ]
   }
 }
@@ -1172,7 +1613,7 @@

Response

diff --git a/unibond/src/main/resources/static/docs/question-community.html b/unibond/src/main/resources/static/docs/question-community.html index 0e5ad3e..75649a5 100644 --- a/unibond/src/main/resources/static/docs/question-community.html +++ b/unibond/src/main/resources/static/docs/question-community.html @@ -498,7 +498,7 @@

Response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 2002
+Content-Length: 6235
 
 {
   "isSuccess" : true,
@@ -506,13 +506,101 @@ 

Response

"message" : "요청에 성공하였습니다.", "result" : { "pageInfo" : { - "numberOfElements" : 3, + "numberOfElements" : 11, "lastPage" : true, "totalPages" : 1, - "totalElements" : 3, + "totalElements" : 11, "size" : 30 }, "postPreviewList" : [ { + "createdDate" : "2024-01-06T06:07:59.413161", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 79, + "postImg" : null, + "contentPreview" : "아아\n글 왜 쓰면 풀투리프레쉬 없어ㅍ졋ㅆ지...", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-04T12:24:22.161686", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 78, + "postImg" : null, + "contentPreview" : "글 작성도 아주 잘 됩니다! 하지만 속도는 조금 느려요.. 어쩔수가없네ㅠ 성능개선", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-04T12:11:05.969729", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 77, + "postImg" : null, + "contentPreview" : "글도 쓸 수 있다! 난 너무 행복해 해 자동완성 왜 되냐;; 킹받네...나 밥도 ", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-04T01:09:39.566862", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 76, + "postImg" : null, + "contentPreview" : "안녕하시렵니까? 잘 써지나유", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-03T23:29:05.627646", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 75, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다,,,,,이이이이이이이이이이이이이이이이ㅣㅇ이이이", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-03T23:26:28.345496", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 74, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다,,,,,이이이이이이이이이이이이이이이이ㅣㅇ이이이", + "boardType" : "QNA", + "isEnd" : false + }, { + "createdDate" : "2024-01-03T23:26:09.69247", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 73, + "postImg" : null, + "contentPreview" : "새로고침 테스트를 위한 글쓰기입니다", + "boardType" : "QNA", + "isEnd" : true + }, { + "createdDate" : "2024-01-03T22:16:28.436585", + "ownerId" : 29, + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", + "ownerNick" : "시험왕", + "disease" : "블륨 증후군", + "postId" : 72, + "postImg" : null, + "contentPreview" : "이것은 질문 게시판의 게시물인데, 작성이 잘 될까요? 궁금합니다. 저는 빨리좀 하", + "boardType" : "QNA", + "isEnd" : false + }, { "createdDate" : "2023-12-30T00:40:29.237761", "ownerId" : 29, "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/f4113115-ee23-4a14-8a47-861b5aa7fdecdog-4586317_640.jpg", @@ -526,7 +614,7 @@

Response

}, { "createdDate" : "2023-11-12T00:57:12.641472", "ownerId" : 28, - "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/ab1a78e5-339b-4263-bb79-89d7792c0bb8people-3281583_640.jpg", + "ownerProfileImg" : "https://unibond-img-bucket.s3.ap-northeast-2.amazonaws.com/user/025cc515-c832-4c29-9fe0-9e77f0afea7d6808929_emoji_emoticon_emotion_expression_face_icon.png", "ownerNick" : "서울의가을", "disease" : "피어슨 증후군[Pierson syndrome]", "postId" : 62, diff --git a/unibond/src/test/java/com/unibond/unibond/member/controller/MemberControllerTest.java b/unibond/src/test/java/com/unibond/unibond/member/controller/MemberControllerTest.java index 654ea7f..7a2a6c2 100644 --- a/unibond/src/test/java/com/unibond/unibond/member/controller/MemberControllerTest.java +++ b/unibond/src/test/java/com/unibond/unibond/member/controller/MemberControllerTest.java @@ -1,7 +1,11 @@ package com.unibond.unibond.member.controller; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.unibond.unibond.member.domain.Gender; import com.unibond.unibond.member.dto.MemberModifyReqDto; +import com.unibond.unibond.member.dto.MemberRegisterReqDto; import jakarta.transaction.Transactional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -11,6 +15,7 @@ import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockMultipartFile; import org.springframework.restdocs.RestDocumentationContextProvider; @@ -25,11 +30,19 @@ import org.springframework.web.filter.CharacterEncodingFilter; import java.io.FileInputStream; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static com.unibond.unibond.common.ApiDocumentUtils.getDocumentRequest; import static com.unibond.unibond.common.ApiDocumentUtils.getDocumentResponse; +import static com.unibond.unibond.member.domain.Gender.*; import static com.unibond.unibond.member.domain.Gender.MALE; +import static com.unibond.unibond.member.domain.Gender.NULL; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.springframework.http.MediaType.*; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; @@ -38,7 +51,7 @@ import static org.springframework.restdocs.payload.JsonFieldType.*; import static org.springframework.restdocs.payload.PayloadDocumentation.*; import static org.springframework.restdocs.request.RequestDocumentation.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest @@ -63,6 +76,53 @@ public void setUp(WebApplicationContext webApplicationContext, RestDocumentation .build(); } + @Test + @Transactional + @DisplayName("회원 가입 테스트 - v1 (프로필 사진 업로드 제외)") + void signUpTest() throws Exception { + MemberRegisterReqDto reqDto = new MemberRegisterReqDto(); + reqDto.setDiseaseId(1L); + reqDto.setDiseaseTiming(LocalDate.now()); + reqDto.setGender(FEMALE); + reqDto.setNickname("안녕하세요닉네임"); + reqDto.setBio("안녕하세요 한 줄 소개 작성합니다."); + ArrayList interestList = new ArrayList<>(); + interestList.add("운동"); + interestList.add("환우회"); + reqDto.setInterestList(interestList); + + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + String content = objectMapper.writeValueAsString(reqDto); + + this.mockMvc.perform( + post("/api/v1/members") + .contentType(APPLICATION_JSON) + .characterEncoding("UTF-8") + .accept(APPLICATION_JSON) + .content(content) + ) + .andExpect(status().isOk()) + .andDo(document("sign-up-member_v1", + getDocumentRequest(), + getDocumentResponse(), + requestFields( + fieldWithPath("diseaseId").type(NUMBER).description("질병 ID : 검색 API를 통해 검색해서 가져옵니다."), + fieldWithPath("diseaseTiming").type(STRING).description("질병 진단 시기 ex) `2002-06-27`"), + fieldWithPath("gender").type(STRING).description("성별 : `NULL`, `MALE`, `FEMALE`"), + fieldWithPath("nickname").type(STRING).description("닉네임: 중복 체크에 유의하기, 10자 이상 작성 불가능"), + fieldWithPath("bio").type(STRING).description("한 줄 소개"), + fieldWithPath("interestList").type(ARRAY).description("관심사 리스트: 문자열 리스트로 전달해주면 됨.") + ), + responseFields( + fieldWithPath("isSuccess").type(BOOLEAN).description("성공 여부"), + fieldWithPath("code").type(NUMBER).description("결과 코드"), + fieldWithPath("message").type(STRING).description("결과 메세지"), + fieldWithPath("result").type(NUMBER).description("생성된 멤버의 로그인 아이디") + ) + )); + } + @Test @DisplayName("자신의 프로필 조회 API Test") void getMyProfile() throws Exception { @@ -163,6 +223,65 @@ void getOtherProfile() throws Exception { )); } + @Test + @Transactional + @DisplayName("프로필 수정 API Test - v1 (프로필 사진 제외)") + void modifyMemberInfoV1() throws Exception { + Long modifyMemberId = 29L; + + MemberModifyReqDto reqDto = new MemberModifyReqDto(); + reqDto.setDiseaseId(3L); + reqDto.setGender(NULL); + reqDto.setBio("안녕하세요 수정된 한 줄 소개 작성합니다."); + + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + String content = objectMapper.writeValueAsString(reqDto); + + this.mockMvc.perform( + RestDocumentationRequestBuilders + .patch("/api/v1/members/{memberId}", modifyMemberId) + .header("Authorization", modifyMemberId) + .contentType(APPLICATION_JSON) + .characterEncoding("UTF-8") + .accept(APPLICATION_JSON) + .content(content) + .header("Authorization", modifyMemberId) + ) + .andExpect(status().isOk()) + .andDo(document("modify-member-info_v1", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("Basic auth credentials") + ), + pathParameters( + parameterWithName("memberId").description("수정할 memberId: 로그인한 아이디와 동일해야 수정이 가능합니다.").optional() + ), + requestFields( + fieldWithPath("diseaseId").type(NUMBER).description("질병 ID : 검색 API를 통해 검색해서 가져옵니다.").optional(), + fieldWithPath("diagnosisTiming").type(STRING).description("질병 진단 시기 ex) `2002-06-27`").optional(), + fieldWithPath("gender").type(STRING).description("성별 : `NULL`, `MALE`, `FEMALE`").optional(), + fieldWithPath("nickname").type(STRING).description("닉네임: 중복 체크에 유의하기, 10자 이상 작성 불가능").optional(), + fieldWithPath("bio").type(STRING).description("한 줄 소개").optional(), + fieldWithPath("interestList").type(ARRAY).description("관심사 리스트: 문자열 리스트로 전달해주면 됨.").optional() + ), + responseFields( + fieldWithPath("isSuccess").type(BOOLEAN).description("성공 여부"), + fieldWithPath("code").type(NUMBER).description("결과 코드"), + fieldWithPath("message").type(STRING).description("결과 메세지"), + fieldWithPath("result").type(OBJECT).description("결과 데이터"), + fieldWithPath("result.profileImage").type(STRING).description("프로필 사진"), + fieldWithPath("result.nickname").type(STRING).description("닉네임"), + fieldWithPath("result.gender").type(STRING).description("성별"), + fieldWithPath("result.diseaseName").type(STRING).description("질병명"), + fieldWithPath("result.diagnosisTiming").type(STRING).description("진단 시기"), + fieldWithPath("result.bio").type(STRING).description("한 줄 소개"), + fieldWithPath("result.interestList").type(ARRAY).description("관심사") + ) + )); + } + @Test @Transactional @DisplayName("프로필 수정 API Test") @@ -187,7 +306,7 @@ public void modifyMemberInfo() throws Exception { = new MockMultipartFile("request", "request", "application/json", content.getBytes(UTF_8)); - MockMultipartHttpServletRequestBuilder builder = RestDocumentationRequestBuilders.multipart("/api/v1/members/{memberId}", modifyMemberId); + MockMultipartHttpServletRequestBuilder builder = RestDocumentationRequestBuilders.multipart("/api/v2/members/{memberId}", modifyMemberId); builder.with(new RequestPostProcessor() { @Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
Table 3. /api/v1/members/{memberId}Table 4. /api/v2/members/{memberId}