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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/♻️-refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "♻️ Refactor"
about: λ¦¬νŒ©ν† λ§ 이슈 ν…œν”Œλ¦Ώ
title: "♻️Refactor: "
labels: ''
labels: ":recycle: Refactor"
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/✨-feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "✨ Feature"
about: κΈ°λŠ₯ μΆ”κ°€ 이슈 ν…œν”Œλ¦Ώ
title: "✨Feat: "
labels: enhancement
labels: "✨ Feature"
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/πŸ›-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "\U0001F41B Fix"
about: 버그 및 μ—λŸ¬ 이슈 ν…œν”Œλ¦Ώ
title: "\U0001F41BFix: "
labels: bug
labels: "\U0001F41E BugFix"
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/πŸ“-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "\U0001F4DD Documentation"
about: λ¬Έμ„œ μˆ˜μ • 이슈 ν…œν”Œλ¦Ώ
title: "\U0001F4DDDocs: "
labels: documentation
labels: "\U0001F4C3 Docs"
assignees: ''

---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.likelion.trendithon.domain.card.controller;

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.service.CardService;

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

@RestController
@AllArgsConstructor
@RequestMapping("/api/cards")
@Tag(name = "Card", description = "Card 관리 API")
public class CardController {

private CardService cardService;

@Operation(summary = "[ 토큰 O | μΉ΄λ“œ 등둝 ]", description = "μƒˆλ‘œμš΄ μΉ΄λ“œ 등둝")
@PostMapping("/create")
public ResponseEntity<?> createCard(@RequestBody CardRequest card) {
return cardService.createCard(card);
}

@Operation(summary = "[ 토큰 O | μΉ΄λ“œ 쑰회 ]", description = "IDλ₯Ό 톡해 νŠΉμ • μΉ΄λ“œ 쑰회")
@GetMapping("/{id}")
public ResponseEntity<?> getCardById(@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 = "[ 토큰 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.likelion.trendithon.domain.card.dto.request;

import java.util.List;

import com.likelion.trendithon.domain.tag.dto.TagDto;

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

@Getter
public class CardRequest {

@Schema(description = "μΉ΄λ“œ 제λͺ©", example = "λ©‹μŸμ΄μ‚¬μž 되기")
private String title;

@Schema(description = "μΉ΄λ“œ λ‚΄μš©", example = "λ‚˜λŠ” 였늘 λ©‹μŸμ΄ μ‚¬μžκ°€ λ˜λ‹€.")
private String content;

@Schema(description = "이λͺ¨μ§€ Url")
private String imgUrl;

@Schema(description = "νƒœκ·Έ λͺ©λ‘", example = "[{\"tagTitle\": \"팁\", \"tagContent\": \"μ—΄μ‹¬νžˆ ν•˜κΈ°\"}]")
private List<TagDto> tagItems;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.likelion.trendithon.domain.card.dto.response;

import java.util.List;

import com.likelion.trendithon.domain.tag.dto.TagDto;

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

@Getter
@Builder
public class CardDto {

@Schema(description = "μΉ΄λ“œ 제λͺ©", example = "λ©‹μŸμ΄μ‚¬μž 되기")
private String title;

@Schema(description = "μΉ΄λ“œ λ‚΄μš©", example = "λ‚˜λŠ” 였늘 λ©‹μŸμ΄ μ‚¬μžκ°€ λ˜λ‹€.")
private String content;

@Schema(description = "이λͺ¨μ§€ Url")
private String imgUrl;

@Schema(description = "μ‚¬μš©μž Id", example = "likelion")
private String userId;

@Schema(description = "νƒœκ·Έ λͺ©λ‘", example = "[{\"tagTitle\": \"팁\", \"tagContent\": \"μ—΄μ‹¬νžˆ ν•˜κΈ°\"}]")
private List<TagDto> tagItems;
}
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 CardListResponse {

@Schema(description = "μΉ΄λ“œ 생성 κ²°κ³Ό", example = "true")
private boolean success;

@Schema(description = "응닡 λ©”μ„Έμ§€", example = "μ„±κ³΅μ μœΌλ‘œ μΉ΄λ“œκ°€ μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€.")
private String message;

@Schema(description = "λ³΄μœ ν•œ μΉ΄λ“œ 리슀트")
private List<CardListSummaryDto> cardList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.likelion.trendithon.domain.card.dto.response;

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

@Getter
@Setter
@AllArgsConstructor
@Builder
@NoArgsConstructor
public class CardListSummaryDto {

@Schema(description = "μΉ΄λ“œ Id", example = "1234")
private Long cardId;

@Schema(description = "μΉ΄λ“œ 제λͺ©", example = "λ©‹μŸμ΄μ‚¬μž 되기")
private String title;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 CardResponse {

@Schema(description = "μΉ΄λ“œ 생성 κ²°κ³Ό", example = "true")
private boolean success;

@Schema(description = "응닡 λ©”μ„Έμ§€", example = "μΉ΄λ“œκ°€ 생성 μ„±κ³΅ν•˜μ˜€μŠ΅λ‹ˆλ‹€.")
private String message;
}
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 CardSearchResponse {

@Schema(description = "μΉ΄λ“œ 쑰회 κ²°κ³Ό", example = "true")
private boolean success;

@Schema(description = "응닡 λ©”μ„Έμ§€", example = "μΉ΄λ“œκ°€ 쑰회 μ„±κ³΅ν•˜μ˜€μŠ΅λ‹ˆλ‹€.")
private String message;

@Schema(description = "μΉ΄λ“œ")
private CardDto card;
}
47 changes: 47 additions & 0 deletions src/main/java/com/likelion/trendithon/domain/card/entity/Card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.likelion.trendithon.domain.card.entity;

import java.util.*;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
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;
import lombok.NoArgsConstructor;
import lombok.Setter;

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

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

@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;

@OneToMany(mappedBy = "card", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Tag> TagItems = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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);
}
Loading
Loading