Skip to content

Commit 8272c27

Browse files
Merge pull request #368 from RealMatchTeam/feat/#362-get-tag-content
feat(#362): 캠페인 태그 조회 api 추가
2 parents 497ea20 + 96e285c commit 8272c27

File tree

7 files changed

+170
-1
lines changed

7 files changed

+170
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.example.RealMatch.business.application.service;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.transaction.annotation.Transactional;
8+
9+
import com.example.RealMatch.business.domain.enums.ContentTagSort;
10+
import com.example.RealMatch.business.presentation.dto.response.TagContentSortResponse;
11+
import com.example.RealMatch.tag.domain.entity.TagContent;
12+
import com.example.RealMatch.tag.domain.repository.TagContentRepository;
13+
14+
import lombok.RequiredArgsConstructor;
15+
16+
@Service
17+
@RequiredArgsConstructor
18+
@Transactional(readOnly = true)
19+
public class TagContentSortQueryService {
20+
21+
private final TagContentRepository tagContentRepository;
22+
23+
public List<TagContentSortResponse> getAllGroupedBySort() {
24+
25+
List<TagContent> allTags = tagContentRepository.findAll();
26+
27+
return Arrays.stream(ContentTagSort.values())
28+
.map(sort -> {
29+
List<TagContent> filtered = allTags.stream()
30+
.filter(tag ->
31+
tag.getTagType().name().equals(sort.name())
32+
)
33+
.toList();
34+
35+
return TagContentSortResponse.from(sort, filtered);
36+
})
37+
.toList();
38+
}
39+
}
40+
41+
42+
43+
44+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.RealMatch.business.domain.enums;
2+
3+
import lombok.Getter;
4+
import lombok.RequiredArgsConstructor;
5+
6+
@Getter
7+
@RequiredArgsConstructor
8+
public enum ContentTagSort {
9+
FORMAT("형식"),
10+
CATEGORY("종류"),
11+
TONE("톤"),
12+
INVOLVEMENT("관여도"),
13+
USAGE_RANGE("활용 범위");
14+
15+
private final String korName;
16+
}
17+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.example.RealMatch.business.presentation.controller;
2+
3+
import java.util.List;
4+
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
import com.example.RealMatch.business.application.service.TagContentSortQueryService;
10+
import com.example.RealMatch.business.presentation.dto.response.TagContentSortResponse;
11+
12+
import io.swagger.v3.oas.annotations.Operation;
13+
import io.swagger.v3.oas.annotations.tags.Tag;
14+
import lombok.RequiredArgsConstructor;
15+
16+
@Tag(name = "Business-ContentTag", description = "비즈니스 캠페인 콘텐츠 태그")
17+
@RestController
18+
@RequiredArgsConstructor
19+
@RequestMapping("/api/v1/tag-contents/sort")
20+
public class TagContentSortController {
21+
22+
private final TagContentSortQueryService tagContentSortQueryService;
23+
24+
@Operation(
25+
summary = "콘텐츠 태그 정렬 기준별 조회",
26+
description = """
27+
콘텐츠 태그를 정렬 기준(ContentTagSort)별로 그룹화하여 조회합니다.
28+
29+
[응답 구조]
30+
- sort: 태그 정렬 기준 (FORMAT, CATEGORY, TONE, INVOLVEMENT, USAGE_RANGE)
31+
- sortKorName: 정렬 기준 한글명 (형식, 종류, 톤, 관여도, 활용 범위)
32+
- tags: 해당 정렬 기준에 속하는 태그 목록
33+
- id: 태그 ID
34+
- name: 태그 한글명
35+
"""
36+
)
37+
@GetMapping
38+
public List<TagContentSortResponse> getAll() {
39+
return tagContentSortQueryService.getAllGroupedBySort();
40+
}
41+
}
42+
43+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.example.RealMatch.business.presentation.dto.response;
2+
3+
import java.util.List;
4+
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
8+
@Getter
9+
@AllArgsConstructor
10+
public class CollaborationPageResponse {
11+
12+
private List<CollaborationResponse> contents;
13+
private int page;
14+
private int size;
15+
private long totalElements;
16+
private int totalPages;
17+
private boolean hasNext;
18+
}
19+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.example.RealMatch.business.presentation.dto.response;
2+
3+
import java.util.List;
4+
5+
import com.example.RealMatch.business.domain.enums.ContentTagSort;
6+
import com.example.RealMatch.tag.domain.entity.TagContent;
7+
8+
import lombok.Builder;
9+
import lombok.Getter;
10+
11+
@Getter
12+
@Builder
13+
public class TagContentSortResponse {
14+
15+
private ContentTagSort sort;
16+
private String sortKorName;
17+
private List<TagItemResponse> tags;
18+
19+
public static TagContentSortResponse from(
20+
ContentTagSort sort,
21+
List<TagContent> tagContents
22+
) {
23+
return TagContentSortResponse.builder()
24+
.sort(sort)
25+
.sortKorName(sort.getKorName())
26+
.tags(tagContents.stream()
27+
.map(tag -> new TagItemResponse(
28+
tag.getId(),
29+
tag.getKorName()
30+
))
31+
.toList())
32+
.build();
33+
}
34+
}
35+
36+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.RealMatch.business.presentation.dto.response;
2+
3+
public record TagItemResponse(
4+
Long id,
5+
String name
6+
) {}
7+

src/main/java/com/example/RealMatch/business/presentation/swagger/CampaignProposalSwagger.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ public interface CampaignProposalSwagger {
2323
@Operation(
2424
summary = "캠페인 제안 생성 API by 박지영",
2525
description = """
26-
크리에이터가 브랜드에 캠페인을 제안합니다.
26+
크리에이터가 브랜드에 캠페인을 제안합니다.
27+
brandId, creatorId를 수정해서 보내야합니다.
2728
2829
신규 캠페인인 경우 campaignId null 을 보내주세요.
2930
기존 캠페인인 경우 campaignId을 보내주세요.
3031
3132
기타인 경우 customValue를 포함해서 보내주세요.
33+
34+
/api/v1/tag-contents/sort에서 태그 id를 확인해주세요.
3235
"""
3336
)
3437
@RequestBody(

0 commit comments

Comments
 (0)