-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feature][#25] 카드 메모 api, 카드 api 수정
- Loading branch information
Showing
40 changed files
with
1,237 additions
and
1,361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/com/server/bbo_gak/domain/card/controller/CardMemoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.server.bbo_gak.domain.card.controller; | ||
|
||
import com.server.bbo_gak.domain.card.dto.request.CardMemoContentUpdateRequest; | ||
import com.server.bbo_gak.domain.card.dto.request.CardMemoCreateRequest; | ||
import com.server.bbo_gak.domain.card.dto.response.CardMemoCreateResponse; | ||
import com.server.bbo_gak.domain.card.dto.response.CardMemoGetResponse; | ||
import com.server.bbo_gak.domain.card.service.CardMemoService; | ||
import com.server.bbo_gak.domain.user.entity.User; | ||
import com.server.bbo_gak.global.annotation.AuthUser; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/cards") | ||
@RequiredArgsConstructor | ||
public class CardMemoController { | ||
|
||
private final CardMemoService cardMemoService; | ||
|
||
@GetMapping("/{card-id}/card-memo") | ||
public ResponseEntity<List<CardMemoGetResponse>> getCardMemoList( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId) { | ||
|
||
return ResponseEntity.ok(cardMemoService.getCardMemoList(user, cardId)); | ||
} | ||
|
||
@PostMapping("/{card-id}/card-memo") | ||
public ResponseEntity<CardMemoCreateResponse> createCardMemo( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId, | ||
@RequestBody CardMemoCreateRequest request) { | ||
|
||
return ResponseEntity.ok(cardMemoService.createCardMemo(user, request, cardId)); | ||
} | ||
|
||
@PutMapping("/{card-id}/card-momo/{card-memo-id}/content") | ||
public ResponseEntity<Void> updateCardMemoContent( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId, | ||
@PathVariable("card-memo-id") Long cardMemoId, | ||
@RequestBody CardMemoContentUpdateRequest request) { | ||
|
||
cardMemoService.updateCardMemo(user, request, cardId, cardMemoId); | ||
return ResponseEntity.ok().body(null); | ||
} | ||
|
||
@DeleteMapping("/{card-id}/card-memo/{card-memo-id}") | ||
public ResponseEntity<Void> deleteCardMemo( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId, | ||
@PathVariable("card-memo-id") Long cardMemoId) { | ||
|
||
cardMemoService.deleteCardMemo(user, cardId, cardMemoId); | ||
return ResponseEntity.ok().body(null); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/server/bbo_gak/domain/card/controller/TagController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.server.bbo_gak.domain.card.controller; | ||
|
||
import com.server.bbo_gak.domain.card.dto.response.TagGetResponse; | ||
import com.server.bbo_gak.domain.card.service.TagService; | ||
import com.server.bbo_gak.domain.user.entity.User; | ||
import com.server.bbo_gak.global.annotation.AuthUser; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
@RequiredArgsConstructor | ||
public class TagController { | ||
|
||
private final TagService tagService; | ||
|
||
@GetMapping("/tags") | ||
public ResponseEntity<List<TagGetResponse>> getAllTagList() { | ||
return ResponseEntity.ok(tagService.getAllTagList()); | ||
} | ||
|
||
@GetMapping("/cards/{card-id}/tags") | ||
public ResponseEntity<List<TagGetResponse>> getcCardTagList( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId) { | ||
|
||
return ResponseEntity.ok(tagService.getTagListInCard(user, cardId)); | ||
} | ||
|
||
@PostMapping("/cards/{card-id}/tag/{tag-id}") | ||
public ResponseEntity<Void> addCardTag( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId, @PathVariable("tag-id") Long tagId) { | ||
|
||
tagService.addTagToCard(user, cardId, tagId); | ||
return ResponseEntity.ok(null); | ||
} | ||
|
||
@DeleteMapping("/cards/{card-id}/tag/{tag-id}") | ||
public ResponseEntity<Void> deleteCardTag( | ||
@AuthUser User user, | ||
@PathVariable("card-id") Long cardId, @PathVariable("tag-id") Long tagId | ||
) { | ||
|
||
tagService.deleteTagFromCard(user, cardId, tagId); | ||
return ResponseEntity.ok(null); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/server/bbo_gak/domain/card/dao/CardDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.server.bbo_gak.domain.card.entity.Card; | ||
import com.server.bbo_gak.domain.card.entity.CardTypeValue; | ||
import com.server.bbo_gak.domain.card.entity.QCard; | ||
import com.server.bbo_gak.domain.card.entity.QCardType; | ||
import com.server.bbo_gak.domain.user.entity.User; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Repository | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class CardDao { | ||
|
||
private final JPAQueryFactory query; | ||
|
||
public List<Card> findAllByUserIdAndCardTypeValueList(User user, CardTypeValue[] cardTypeValueList) { | ||
|
||
QCard qCard = QCard.card; | ||
QCardType qCardType = QCardType.cardType; | ||
|
||
return query.selectFrom(qCard) | ||
.leftJoin(qCard.cardTypeList, qCardType).fetchJoin() | ||
.where(qCard.user.id.eq(user.getId()).and(qCardType.cardTypeValue.in(cardTypeValueList))).distinct() | ||
.fetch(); | ||
} | ||
|
||
public List<Card> findAllByUserIdAndCardTypeValue(User user, CardTypeValue cardTypeValue) { | ||
|
||
QCard qCard = QCard.card; | ||
QCardType qCardType = QCardType.cardType; | ||
|
||
return query.selectFrom(qCard) | ||
.leftJoin(qCard.cardTypeList, qCardType).fetchJoin() | ||
.where(qCard.user.id.eq(user.getId()).and(qCardType.cardTypeValue.eq(cardTypeValue))).distinct() | ||
.fetch(); | ||
} | ||
|
||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/server/bbo_gak/domain/card/dao/CardMemoRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.server.bbo_gak.domain.card.entity.Card; | ||
import com.server.bbo_gak.domain.card.entity.CardMemo; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CardMemoRepository extends JpaRepository<CardMemo, Long> { | ||
|
||
Optional<CardMemo> findByIdAndCard(Long id, Card card); | ||
} |
8 changes: 3 additions & 5 deletions
8
src/main/java/com/server/bbo_gak/domain/card/dao/CardRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.server.bbo_gak.domain.card.entity.Card; | ||
import com.server.bbo_gak.domain.card.entity.CardType; | ||
import com.server.bbo_gak.domain.user.entity.User; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CardRepository extends JpaRepository<Card, Long> { | ||
|
||
Optional<Card> findByIdAndUserId(Long id, Long userId); | ||
Optional<Card> findByIdAndUser(Long id, User user); | ||
|
||
List<Card> findAllByUserId(Long userId); | ||
|
||
List<Card> findAllByUserIdAndCardType(Long userId, CardType cardType); | ||
List<Card> findAllByUser(User user); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/server/bbo_gak/domain/card/dao/CardTypeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.server.bbo_gak.domain.card.entity.CardType; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CardTypeRepository extends JpaRepository<CardType, Long> { | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/server/bbo_gak/domain/card/dao/TagRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.server.bbo_gak.domain.card.entity.Tag; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface TagRepository extends JpaRepository<Tag, Long> { | ||
|
||
List<Tag> findAllByIdIsNotIn(List<Long> idList); | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/server/bbo_gak/domain/card/dto/request/CardCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.server.bbo_gak.domain.card.dto.request; | ||
|
||
import jakarta.validation.constraints.Size; | ||
import java.util.List; | ||
|
||
public record CardCreateRequest( | ||
|
||
@Size(min = 1, max = 3) | ||
List<String> cardTypeValueList, | ||
|
||
@Size(max = 3) | ||
List<Long> tagIdList | ||
) { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/server/bbo_gak/domain/card/dto/request/CardMemoContentUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.server.bbo_gak.domain.card.dto.request; | ||
|
||
public record CardMemoContentUpdateRequest( | ||
String content | ||
) { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/server/bbo_gak/domain/card/dto/request/CardMemoCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.server.bbo_gak.domain.card.dto.request; | ||
|
||
public record CardMemoCreateRequest( | ||
String content | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.