From 5670f72356e361c06f14e65af1c484f5d3f80c7b Mon Sep 17 00:00:00 2001 From: ParkJiYeoung8297 Date: Wed, 11 Feb 2026 03:15:37 +0900 Subject: [PATCH] =?UTF-8?q?feat(#362):=20=EC=BA=A0=ED=8E=98=EC=9D=B8=20?= =?UTF-8?q?=ED=83=9C=EA=B7=B8=20=EC=A1=B0=ED=9A=8C=20api=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 --- .../service/TagContentSortQueryService.java | 44 +++++++++++++++++++ .../business/domain/enums/ContentTagSort.java | 17 +++++++ .../controller/TagContentSortController.java | 43 ++++++++++++++++++ .../response/CollaborationPageResponse.java | 19 ++++++++ .../dto/response/TagContentSortResponse.java | 36 +++++++++++++++ .../dto/response/TagItemResponse.java | 7 +++ .../swagger/CampaignProposalSwagger.java | 5 ++- 7 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/example/RealMatch/business/application/service/TagContentSortQueryService.java create mode 100644 src/main/java/com/example/RealMatch/business/domain/enums/ContentTagSort.java create mode 100644 src/main/java/com/example/RealMatch/business/presentation/controller/TagContentSortController.java create mode 100644 src/main/java/com/example/RealMatch/business/presentation/dto/response/CollaborationPageResponse.java create mode 100644 src/main/java/com/example/RealMatch/business/presentation/dto/response/TagContentSortResponse.java create mode 100644 src/main/java/com/example/RealMatch/business/presentation/dto/response/TagItemResponse.java diff --git a/src/main/java/com/example/RealMatch/business/application/service/TagContentSortQueryService.java b/src/main/java/com/example/RealMatch/business/application/service/TagContentSortQueryService.java new file mode 100644 index 00000000..825b81c8 --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/application/service/TagContentSortQueryService.java @@ -0,0 +1,44 @@ +package com.example.RealMatch.business.application.service; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.example.RealMatch.business.domain.enums.ContentTagSort; +import com.example.RealMatch.business.presentation.dto.response.TagContentSortResponse; +import com.example.RealMatch.tag.domain.entity.TagContent; +import com.example.RealMatch.tag.domain.repository.TagContentRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class TagContentSortQueryService { + + private final TagContentRepository tagContentRepository; + + public List getAllGroupedBySort() { + + List allTags = tagContentRepository.findAll(); + + return Arrays.stream(ContentTagSort.values()) + .map(sort -> { + List filtered = allTags.stream() + .filter(tag -> + tag.getTagType().name().equals(sort.name()) + ) + .toList(); + + return TagContentSortResponse.from(sort, filtered); + }) + .toList(); + } +} + + + + + diff --git a/src/main/java/com/example/RealMatch/business/domain/enums/ContentTagSort.java b/src/main/java/com/example/RealMatch/business/domain/enums/ContentTagSort.java new file mode 100644 index 00000000..9e5e18f2 --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/domain/enums/ContentTagSort.java @@ -0,0 +1,17 @@ +package com.example.RealMatch.business.domain.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum ContentTagSort { + FORMAT("형식"), + CATEGORY("종류"), + TONE("톤"), + INVOLVEMENT("관여도"), + USAGE_RANGE("활용 범위"); + + private final String korName; +} + diff --git a/src/main/java/com/example/RealMatch/business/presentation/controller/TagContentSortController.java b/src/main/java/com/example/RealMatch/business/presentation/controller/TagContentSortController.java new file mode 100644 index 00000000..8e6dae3d --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/presentation/controller/TagContentSortController.java @@ -0,0 +1,43 @@ +package com.example.RealMatch.business.presentation.controller; + +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.example.RealMatch.business.application.service.TagContentSortQueryService; +import com.example.RealMatch.business.presentation.dto.response.TagContentSortResponse; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; + +@Tag(name = "Business-ContentTag", description = "비즈니스 캠페인 콘텐츠 태그") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/tag-contents/sort") +public class TagContentSortController { + + private final TagContentSortQueryService tagContentSortQueryService; + + @Operation( + summary = "콘텐츠 태그 정렬 기준별 조회", + description = """ + 콘텐츠 태그를 정렬 기준(ContentTagSort)별로 그룹화하여 조회합니다. + + [응답 구조] + - sort: 태그 정렬 기준 (FORMAT, CATEGORY, TONE, INVOLVEMENT, USAGE_RANGE) + - sortKorName: 정렬 기준 한글명 (형식, 종류, 톤, 관여도, 활용 범위) + - tags: 해당 정렬 기준에 속하는 태그 목록 + - id: 태그 ID + - name: 태그 한글명 + """ + ) + @GetMapping + public List getAll() { + return tagContentSortQueryService.getAllGroupedBySort(); + } +} + + diff --git a/src/main/java/com/example/RealMatch/business/presentation/dto/response/CollaborationPageResponse.java b/src/main/java/com/example/RealMatch/business/presentation/dto/response/CollaborationPageResponse.java new file mode 100644 index 00000000..3a59fed8 --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/presentation/dto/response/CollaborationPageResponse.java @@ -0,0 +1,19 @@ +package com.example.RealMatch.business.presentation.dto.response; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class CollaborationPageResponse { + + private List contents; + private int page; + private int size; + private long totalElements; + private int totalPages; + private boolean hasNext; +} + diff --git a/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagContentSortResponse.java b/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagContentSortResponse.java new file mode 100644 index 00000000..ec31bcc7 --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagContentSortResponse.java @@ -0,0 +1,36 @@ +package com.example.RealMatch.business.presentation.dto.response; + +import java.util.List; + +import com.example.RealMatch.business.domain.enums.ContentTagSort; +import com.example.RealMatch.tag.domain.entity.TagContent; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class TagContentSortResponse { + + private ContentTagSort sort; + private String sortKorName; + private List tags; + + public static TagContentSortResponse from( + ContentTagSort sort, + List tagContents + ) { + return TagContentSortResponse.builder() + .sort(sort) + .sortKorName(sort.getKorName()) + .tags(tagContents.stream() + .map(tag -> new TagItemResponse( + tag.getId(), + tag.getKorName() + )) + .toList()) + .build(); + } +} + + diff --git a/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagItemResponse.java b/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagItemResponse.java new file mode 100644 index 00000000..8521cc66 --- /dev/null +++ b/src/main/java/com/example/RealMatch/business/presentation/dto/response/TagItemResponse.java @@ -0,0 +1,7 @@ +package com.example.RealMatch.business.presentation.dto.response; + +public record TagItemResponse( + Long id, + String name +) {} + diff --git a/src/main/java/com/example/RealMatch/business/presentation/swagger/CampaignProposalSwagger.java b/src/main/java/com/example/RealMatch/business/presentation/swagger/CampaignProposalSwagger.java index 672d0e8a..7d080299 100644 --- a/src/main/java/com/example/RealMatch/business/presentation/swagger/CampaignProposalSwagger.java +++ b/src/main/java/com/example/RealMatch/business/presentation/swagger/CampaignProposalSwagger.java @@ -23,12 +23,15 @@ public interface CampaignProposalSwagger { @Operation( summary = "캠페인 제안 생성 API by 박지영", description = """ - 크리에이터가 브랜드에 캠페인을 제안합니다. + 크리에이터가 브랜드에 캠페인을 제안합니다. + brandId, creatorId를 수정해서 보내야합니다. 신규 캠페인인 경우 campaignId null 을 보내주세요. 기존 캠페인인 경우 campaignId을 보내주세요. 기타인 경우 customValue를 포함해서 보내주세요. + + /api/v1/tag-contents/sort에서 태그 id를 확인해주세요. """ ) @RequestBody(