From 81f744dd32cff10cf973673ad3a9446ceaba0f54 Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Sun, 17 Sep 2023 22:46:00 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profileem/controller/CardController.java | 46 ++++++++++++++++++- submodule-data | 1 - 2 files changed, 44 insertions(+), 3 deletions(-) delete mode 160000 submodule-data diff --git a/src/main/java/com/example/profileem/controller/CardController.java b/src/main/java/com/example/profileem/controller/CardController.java index 1c5c588..47aafd5 100644 --- a/src/main/java/com/example/profileem/controller/CardController.java +++ b/src/main/java/com/example/profileem/controller/CardController.java @@ -21,7 +21,7 @@ public CardController(CardRepository cardRepository) { this.cardRepository = cardRepository; } - @PostMapping("/") // 내 프로필 카드 등록 -- 수정해야 될 내용 : 등록할 때 카카오 로그인 userid를 Card의 userid로 넘겨줘야함 + @PostMapping("/") // 내 프로필 카드 등록 public ResponseEntity createCard(@RequestBody Card card) { // 나머지 카드 정보 설정하고 저장 @@ -35,7 +35,7 @@ public ResponseEntity> getCardsByUserId(@PathVariable Long userId) { return new ResponseEntity<>(cards, HttpStatus.OK); } - @GetMapping("/card/{userId}/{cardId}") // 내 프로필 카드 특정 조회 + @GetMapping("/{userId}/{cardId}") // 내 프로필 카드 특정 조회 public ResponseEntity getCardByUserIdAndCardId( @PathVariable Long userId, @PathVariable Long cardId) { @@ -57,4 +57,46 @@ public ResponseEntity deleteCardByUserIdAndCardId( return new ResponseEntity<>("Card not found.", HttpStatus.NOT_FOUND); } } + + + @PutMapping("/{userId}/{cardId}") // 내 프로필 카드 수정 + public ResponseEntity updateCardByUserIdAndCardId( + @PathVariable Long userId, @PathVariable Long cardId, + @RequestBody Card updatedCard) { + Optional optionalCard = cardRepository.findByUserUserIdAndCid(userId, cardId); + if (optionalCard.isPresent()) { + Card card = optionalCard.get(); + + if (updatedCard.getNickname() != null) card.setNickname(updatedCard.getNickname()); + + if (updatedCard.getUniversity() != null) card.setUniversity(updatedCard.getUniversity()); + + if (updatedCard.getMajor() != null) card.setMajor(updatedCard.getMajor()); + + if (updatedCard.getResidence() != null) card.setResidence(updatedCard.getResidence()); + + if (updatedCard.getQr() != null) card.setQr(updatedCard.getQr()); + + if (updatedCard.getProfile() != null) card.setProfile(updatedCard.getProfile()); + + if (updatedCard.getTemplate() != null) card.setTemplate(updatedCard.getTemplate()); + + if (updatedCard.getMbti() != null) card.setMbti(updatedCard.getMbti()); + + if (updatedCard.getMusic() != null) card.setMusic(updatedCard.getMusic()); + + if (updatedCard.getDrink() != null) card.setDrink(updatedCard.getDrink()); + + if (updatedCard.getBad_food() != null) card.setBad_food(updatedCard.getBad_food()); + + if (updatedCard.getBirth() != null) card.setBirth(updatedCard.getBirth()); + + cardRepository.save(card); // 수정한 카드 정보 저장 + + return new ResponseEntity<>("Card has been updated.", HttpStatus.OK); + } else { + return new ResponseEntity<>("Card not found.", HttpStatus.NOT_FOUND); + } + + } } diff --git a/submodule-data b/submodule-data deleted file mode 160000 index 9df1f8d..0000000 --- a/submodule-data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9df1f8d4ff94e0572ed2362be2ccb68a35c5bff9 From 119c1d9bc68ccea20814d5f56b1aeb32f844a0a9 Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Sun, 24 Sep 2023 20:13:51 +0900 Subject: [PATCH 2/6] =?UTF-8?q?add=20:=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes build.gradle | 3 +++ .../profileem/config/SwaggerConfig.java | 23 ++++++++++++++++++ .../profileem/controller/CardController.java | 22 +++++++++++------ .../profileem/controller/KakaoController.java | 5 ++++ .../profileem/controller/PartyController.java | 11 +++++++-- .../profileem/controller/UserController.java | 8 ++++++ 7 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 .DS_Store create mode 100644 src/main/java/com/example/profileem/config/SwaggerConfig.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d672bdcb7e5f8beef03b08f50eac6f5aaa9d43db GIT binary patch literal 6148 zcmeHKy-EW?5T1>v21N)KVqtM$F9=%Lof2O_#n${u5=cnU1g+#6D-|EW2T-hh0ujV# z@C_7OD@(uGT`xO1Piz#09oYRYJ2N}qeV6Ryh)AvVYl}n$BFbYh1{0V*G4}IFSaVxzVvq+&e;&$A(h5I>QaOHR1wu_>Np+Ya#-$NA3PZjL;JKl118x~f)9lQK6_NA z8ntLw@_FIAHIs;`0q6U1jqXZvSVm_nLrwJ~*RF+((H>B6)albM%Z=a2m z?`raSgs4w3*B`^TBDo96;O%7C?{b(tO`eU|!)1{bBX}t8OHh5Es$kNjF7;?%GRfVh zBU~p9ef|sUQtg)*!0H?J)12* zY0%GJ0k42pAW?wNhY*7?vKSlGM+c@HKC(YxWW%*Svw@-g99fJF!UIz#6=+hGeZ^2F z9qXZui!8N+#sB~S literal 0 HcmV?d00001 diff --git a/build.gradle b/build.gradle index bc8243e..f051f67 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,9 @@ repositories { } dependencies { + //swagger 의존성 추가 + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.google.code.gson:gson:2.8.7' diff --git a/src/main/java/com/example/profileem/config/SwaggerConfig.java b/src/main/java/com/example/profileem/config/SwaggerConfig.java new file mode 100644 index 0000000..dc0f91b --- /dev/null +++ b/src/main/java/com/example/profileem/config/SwaggerConfig.java @@ -0,0 +1,23 @@ +package com.example.profileem.config;// Java +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + @Bean + public OpenAPI openAPI() { + return new OpenAPI() + .components(new Components()) + .info(apiInfo()); + } + + private Info apiInfo() { + return new Info() + .title("Springdoc 테스트") + .description("Springdoc을 사용한 Swagger UI 테스트") + .version("1.0.0"); + } +} diff --git a/src/main/java/com/example/profileem/controller/CardController.java b/src/main/java/com/example/profileem/controller/CardController.java index 47aafd5..c68dc08 100644 --- a/src/main/java/com/example/profileem/controller/CardController.java +++ b/src/main/java/com/example/profileem/controller/CardController.java @@ -2,6 +2,8 @@ import com.example.profileem.domain.Card; import com.example.profileem.repository.CardRepository; +import io.swagger.v3.oas.annotations.*; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -10,6 +12,8 @@ import java.util.List; import java.util.Optional; + +@Tag(name = "Card") @RestController @RequestMapping("/card") public class CardController { @@ -21,21 +25,22 @@ public CardController(CardRepository cardRepository) { this.cardRepository = cardRepository; } - @PostMapping("/") // 내 프로필 카드 등록 + @Operation(summary = "내 프로필 카드 등록", description = "내 프로필 카드 등록") + @PostMapping("/") public ResponseEntity createCard(@RequestBody Card card) { - - // 나머지 카드 정보 설정하고 저장 Card savedCard = cardRepository.save(card); return new ResponseEntity<>(savedCard, HttpStatus.CREATED); } - @GetMapping("/{userId}") // 내 프로필 카드 전체 조회 + @Operation(summary = "내 프로필 카드 전체 조회", description = "내 프로필 카드 전체 조회") + @GetMapping("/{userId}") public ResponseEntity> getCardsByUserId(@PathVariable Long userId) { List cards = cardRepository.findByUserUserId(userId); return new ResponseEntity<>(cards, HttpStatus.OK); } - @GetMapping("/{userId}/{cardId}") // 내 프로필 카드 특정 조회 + @Operation(summary = "내 프로필 카드 특정 조회", description = "내 프로필 카드 특정 조회") + @GetMapping("/{userId}/{cardId}") public ResponseEntity getCardByUserIdAndCardId( @PathVariable Long userId, @PathVariable Long cardId) { @@ -45,7 +50,8 @@ public ResponseEntity getCardByUserIdAndCardId( .orElseGet(() -> new ResponseEntity<>(HttpStatus.NOT_FOUND)); } - @DeleteMapping("/{userId}/{cardId}") // 내 프로필 카드 특정 삭제 + @Operation(summary = "내 프로필 카드 특정 삭제", description = "내 프로필 카드 특정 삭제") + @DeleteMapping("/{userId}/{cardId}") public ResponseEntity deleteCardByUserIdAndCardId( @PathVariable Long userId, @PathVariable Long cardId) { @@ -58,8 +64,8 @@ public ResponseEntity deleteCardByUserIdAndCardId( } } - - @PutMapping("/{userId}/{cardId}") // 내 프로필 카드 수정 + @Operation(summary = "내 프로필 카드 수정", description = "내 프로필 카드 수정") + @PutMapping("/{userId}/{cardId}") public ResponseEntity updateCardByUserIdAndCardId( @PathVariable Long userId, @PathVariable Long cardId, @RequestBody Card updatedCard) { diff --git a/src/main/java/com/example/profileem/controller/KakaoController.java b/src/main/java/com/example/profileem/controller/KakaoController.java index 3de60f4..89de1f0 100644 --- a/src/main/java/com/example/profileem/controller/KakaoController.java +++ b/src/main/java/com/example/profileem/controller/KakaoController.java @@ -2,6 +2,8 @@ import com.example.profileem.service.KakaoService; import lombok.RequiredArgsConstructor; +import io.swagger.v3.oas.annotations.*; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,10 +12,13 @@ @RestController @RequiredArgsConstructor @RequestMapping("/oauth2") +@Tag(name = "Kakao") + public class KakaoController { public final KakaoService kakaoService; + @Operation(summary = "카카오 로그인", description = "카카오 로그인") @GetMapping("/kakao") public Long kakaoLogin(@RequestHeader(value = "AccessToken") String accessToken) { Long userId = kakaoService.createKakaoUser(accessToken); diff --git a/src/main/java/com/example/profileem/controller/PartyController.java b/src/main/java/com/example/profileem/controller/PartyController.java index 645f89c..c4e16ec 100644 --- a/src/main/java/com/example/profileem/controller/PartyController.java +++ b/src/main/java/com/example/profileem/controller/PartyController.java @@ -6,11 +6,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; - +import io.swagger.v3.oas.annotations.*; +import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; +@Tag(name="Party") @RestController @RequestMapping("/party") +//@Api(tags = {"Party"}) public class PartyController { private final PartyService partyService; @@ -21,7 +24,7 @@ public PartyController(PartyService partyService) { } // 내가 방장인 파티 생성 - // 파티 생성 + @Operation(summary = "(내가 방장인 파티) 파티 생성", description = "(내가 방장인 파티) 파티 생성") @PostMapping("/") public ResponseEntity createParty( @RequestParam("party_name") String partyName, @@ -35,6 +38,7 @@ public ResponseEntity createParty( } // 사용자를 파티에 초대 + @Operation(summary = "파티에 사용자 초대", description = "파티에 사용자 초대") @PostMapping("/{partyId}/invitation") public ResponseEntity inviteUserToParty( @PathVariable("partyId") Long partyId, @@ -53,6 +57,7 @@ public ResponseEntity inviteUserToParty( // 파티에 카드 등록 + @Operation(summary = "파티에 카드 등록", description = "파티에 카드 등록") @PostMapping("/{partyId}/card") public ResponseEntity addCardToParty( @PathVariable("partyId") Long partyId, @@ -66,6 +71,7 @@ public ResponseEntity addCardToParty( } // 파티에 등록했던 카드 교체 + @Operation(summary = "파티에 등록했던 카드 교체", description = "파티에 등록했던 카드 교체") @PutMapping("/{partyId}/card") public ResponseEntity replacePartyCard( @PathVariable("partyId") Long partyId, @@ -83,4 +89,5 @@ public ResponseEntity replacePartyCard( + } diff --git a/src/main/java/com/example/profileem/controller/UserController.java b/src/main/java/com/example/profileem/controller/UserController.java index 879b597..d00bd29 100644 --- a/src/main/java/com/example/profileem/controller/UserController.java +++ b/src/main/java/com/example/profileem/controller/UserController.java @@ -8,8 +8,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import io.swagger.v3.oas.annotations.*; +import io.swagger.v3.oas.annotations.tags.Tag; + import java.util.List; +@Tag(name = "User") @RestController @RequestMapping("/user") public class UserController { @@ -22,6 +26,7 @@ public UserController(UserService userService) { } // 사용자가 받은 개인 프로필 카드 ID 추가 + @Operation(summary = "사용자가 받은 개인 프로필 카드 ID 추가", description = "사용자가 받은 개인 프로필 카드 ID 추가") @PostMapping("/{user_id}/card") public ResponseEntity addReceivedCardId( @PathVariable("user_id") Long userId, @@ -35,6 +40,7 @@ public ResponseEntity addReceivedCardId( } // 사용자가 받은 개인 프로필 카드 ID 목록 조희 + @Operation(summary = "사용자가 받은 개인 프로필 카드 ID 목록 조희", description = "사용자가 받은 개인 프로필 카드 ID 목록 조희") @GetMapping("/{user_id}/cards") public ResponseEntity> getReceivedCardIds(@PathVariable("user_id") Long userId) { try { @@ -46,6 +52,7 @@ public ResponseEntity> getReceivedCardIds(@PathVariable("user_id") Lo } // 사용자가 받은 개인 프로필 카드 삭제 + @Operation(summary = "사용자가 받은 개인 프로필 카드 삭제", description = "사용자가 받은 개인 프로필 카드 삭제") @DeleteMapping("/{user_id}/{card_id}") public ResponseEntity deleteReceivedCard( @PathVariable("user_id") Long userId, @@ -59,6 +66,7 @@ public ResponseEntity deleteReceivedCard( } // 사용자가 속한 파티 목록 조회 + @Operation(summary = "사용자가 속한 파티 목록 조회", description = "사용자가 속한 파티 목록 조회") @GetMapping("/{userId}/parties") public ResponseEntity> getUserPartyIds(@PathVariable("userId") Long userId) { try { From 337a446701c5ac8d36af37111c4975d8445e60bc Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Sun, 24 Sep 2023 20:15:13 +0900 Subject: [PATCH 3/6] =?UTF-8?q?add=20:=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index aeda1fe..f83a403 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ build/ bin/ !**/src/main/**/bin/ !**/src/test/**/bin/ +.DS_Store ### IntelliJ IDEA ### application.yml From b4d1812124a712ff16f947ce09192ac03f7e5aea Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Mon, 25 Sep 2023 01:15:56 +0900 Subject: [PATCH 4/6] =?UTF-8?q?.Ds=5FStore=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d672bdcb7e5f8beef03b08f50eac6f5aaa9d43db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKy-EW?5T1>v21N)KVqtM$F9=%Lof2O_#n${u5=cnU1g+#6D-|EW2T-hh0ujV# z@C_7OD@(uGT`xO1Piz#09oYRYJ2N}qeV6Ryh)AvVYl}n$BFbYh1{0V*G4}IFSaVxzVvq+&e;&$A(h5I>QaOHR1wu_>Np+Ya#-$NA3PZjL;JKl118x~f)9lQK6_NA z8ntLw@_FIAHIs;`0q6U1jqXZvSVm_nLrwJ~*RF+((H>B6)albM%Z=a2m z?`raSgs4w3*B`^TBDo96;O%7C?{b(tO`eU|!)1{bBX}t8OHh5Es$kNjF7;?%GRfVh zBU~p9ef|sUQtg)*!0H?J)12* zY0%GJ0k42pAW?wNhY*7?vKSlGM+c@HKC(YxWW%*Svw@-g99fJF!UIz#6=+hGeZ^2F z9qXZui!8N+#sB~S diff --git a/.gitignore b/.gitignore index f83a403..680f006 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ build/ bin/ !**/src/main/**/bin/ !**/src/test/**/bin/ -.DS_Store ### IntelliJ IDEA ### application.yml @@ -38,3 +37,4 @@ out/ ### VS Code ### .vscode/ +.DS_Store From 78ddf93845ff90d488bf5d148ce5201db8006669 Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Mon, 9 Oct 2023 14:24:47 +0900 Subject: [PATCH 5/6] =?UTF-8?q?chore=20:=20swagger=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/profileem/controller/NoticeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/profileem/controller/NoticeController.java b/src/main/java/com/example/profileem/controller/NoticeController.java index ad2a495..457fa02 100644 --- a/src/main/java/com/example/profileem/controller/NoticeController.java +++ b/src/main/java/com/example/profileem/controller/NoticeController.java @@ -55,7 +55,7 @@ public ResponseEntity updateNotice(@PathVariable Long notice_id, @Reques } // 공지사항 삭제 (관리자만 하도록 수정해야함) - @Operation(summary = "공지사항 수정", description = "공지사항 수정") + @Operation(summary = "공지사항 삭제", description = "공지사항 삭제") @DeleteMapping("/{notice_id}") public ResponseEntity deleteNotice(@PathVariable Long notice_id) { noticeService.deleteNotice(notice_id); From 4b0d9c95f4ebcc5daf3c805687bd99b489632960 Mon Sep 17 00:00:00 2001 From: JJiyunkim Date: Mon, 9 Oct 2023 17:25:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=EB=A1=9C=EC=BB=AC=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index dcaf99a..eebef36 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "submodule-data"] path = submodule-data - url = git@github.com:ProfileeM/submodule-data.git + url = git@github.com:ProfileeM/submodule-data.git \ No newline at end of file