Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.likelion.trendithon.domain.card.controller;

import jakarta.servlet.http.HttpServletRequest;

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;

import com.likelion.trendithon.domain.card.dto.request.CardRequest;
import com.likelion.trendithon.domain.card.dto.request.CreateCardRequest;
import com.likelion.trendithon.domain.card.service.CardService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;

Expand All @@ -27,31 +29,33 @@ public class CardController {

@Operation(summary = "[ 토큰 O | 카드 등록 ]", description = "새로운 카드 등록")
@PostMapping("/create")
public ResponseEntity<?> createCard(@RequestBody CardRequest card) {
return cardService.createCard(card);
public ResponseEntity<?> createCard(
@Parameter(description = "카드에 포함되는 내용") @RequestBody CreateCardRequest createCardRequest,
HttpServletRequest httpServletRequest) {
return cardService.createCard(createCardRequest, httpServletRequest);
}

@Operation(summary = "[ 토큰 O | 카드 조회 ]", description = "ID를 통해 특정 카드 조회")
@Operation(summary = "[ 토큰 X | 카드 단일 조회 ]", description = "카드 ID를 통해 특정 카드 조회")
@GetMapping("/{id}")
public ResponseEntity<?> getCardById(@PathVariable Long id) {
public ResponseEntity<?> getCardById(@Parameter(description = "카드 ID") @PathVariable Long id) {
return cardService.getCardById(id);
}

@Operation(summary = "[ 토큰 O | 카드 목록 조회 ]", description = "사용자 ID를 통해 특정 카드 조회")
@GetMapping("/all/{userId}")
public ResponseEntity<?> getAllCards(@PathVariable String userId) {
return cardService.getAllCards(userId);
@Operation(summary = "[ 토큰 X | 랜덤 카드 3장 조회 ]", description = "경험 등록 후 랜덤 카드 3장의 ID 조회")
@GetMapping("/random")
public ResponseEntity<?> getRandomCards() {
return cardService.getRandomCards();
}

@Operation(summary = "[ 토큰 X | 전체 카드 조회 | 테스트용 ]", description = "전체 카드 조회")
@GetMapping()
public ResponseEntity<?> getAllCard() {
return cardService.getAllCards();
}

@Operation(summary = "[ 토큰 O | 카드 삭제 ]", description = "ID를 통해 특정 카드 삭제")
@DeleteMapping("/{id}")
public ResponseEntity<?> deleteCard(@PathVariable Long id) {
return cardService.deleteCard(id);
}

@Operation(summary = "[ 토큰 O | 카드 수정 ]", description = "ID를 통해 특정 카드 수정")
@PutMapping("/update/{id}")
public ResponseEntity<?> updateCard(@PathVariable Long id, @RequestBody CardRequest updatedCard) {
return cardService.updateCard(id, updatedCard);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.likelion.trendithon.domain.card.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

@Getter
public class CreateCardRequest {

@Schema(description = "카드 아이콘", example = "모바일 키보드 이모지")
private String emoji;

@Schema(description = "카드 제목", example = "멋쟁이사자 되기")
private String title;

@Schema(description = "카드 내용", example = "나는 오늘 멋쟁이 사자가 되었다.")
private String content;

@Schema(description = "카드 표지", example = "#000000")
private String cover;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import com.likelion.trendithon.domain.card.entity.Card;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -16,6 +18,6 @@ public class CardListResponse {
@Schema(description = "응답 메세지", example = "성공적으로 카드가 생성되었습니다.")
private String message;

@Schema(description = "보유한 카드 리스트")
private List<CardListSummaryDto> cardList;
@Schema(description = "카드 리스트")
private List<Card> cardList;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.likelion.trendithon.domain.card.dto.response;

import com.likelion.trendithon.domain.card.entity.Card;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -8,9 +10,12 @@
@Getter
public class CardResponse {

@Schema(description = "카드 생성 결과", example = "true")
@Schema(description = "카드 조회 결과", example = "true")
private boolean success;

@Schema(description = "응답 메세지", example = "카드가 생성 성공하였습니다.")
@Schema(description = "응답 메세지", example = "카드 조회에 성공하였습니다.")
private String message;

@Schema(description = "카드")
private Card card;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.likelion.trendithon.domain.card.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class CreateCardResponse {

@Schema(description = "카드 생성 결과", example = "true")
private boolean success;

@Schema(description = "응답 메세지", example = "카드 생성에 성공하였습니다.")
private String message;

@Schema(description = "생성된 카드 ID", example = "1")
private Long cardId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.likelion.trendithon.domain.card.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class DeleteCardResponse {

@Schema(description = "카드 삭제 결과", example = "true")
private boolean success;

@Schema(description = "응답 메세지", example = "카드 삭제에 성공하였습니다.")
private String message;

@Schema(description = "삭제된 카드 ID", example = "1")
private Long cardId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.likelion.trendithon.domain.card.dto.response;

import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class RandomCardResponse {

@Schema(description = "랜덤 카드 3장 조회 결과", example = "true")
private boolean success;

@Schema(description = "응답 메세지", example = "랜덤 카드 3장 조회에 성공하였습니다.")
private String message;

@Schema(description = "랜덤 카드 3장 ID 리스트", example = "[1, 2, 3]")
private List<Long> cardIds;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;

import com.likelion.trendithon.domain.tag.entity.Tag;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -30,18 +28,21 @@ public class Card {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long cardId;

@Column(name = "created_by")
private String loginId;

@Column(name = "emoji")
private String emoji;

@Column(name = "title", nullable = false)
private String title;

@Column(name = "content", nullable = false)
private String content;

@Column(name = "imgUrl")
private String imgUrl;

@Column(name = "user_id")
private String userId;
@Column(name = "cover", nullable = false)
private String cover;

@OneToMany(mappedBy = "card", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Tag> TagItems = new ArrayList<>();
private List<UserCard> userCardList = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.likelion.trendithon.domain.card.entity;

import java.time.LocalDate;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import com.likelion.trendithon.domain.user.entity.User;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
public class UserCard {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userCardId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "login_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "card_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Card card;

@Column(name = "cover", nullable = false)
private String cover;

@Column(name = "start_date", nullable = false)
private LocalDate startDate;

@Column(name = "end_date", nullable = false)
private LocalDate endDate;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.likelion.trendithon.domain.card.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import com.likelion.trendithon.domain.card.entity.Card;

public interface CardRepository extends JpaRepository<Card, Long> {
List<Card> findByUserId(String id);
}
public interface CardRepository extends JpaRepository<Card, Long> {}
Loading
Loading