-
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.
- Loading branch information
Showing
16 changed files
with
352 additions
and
73 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
11 changes: 11 additions & 0 deletions
11
src/main/java/the_monitor/application/dto/request/EmailUpdateRequest.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 the_monitor.application.dto.request; | ||
|
||
import lombok.Getter; | ||
import java.util.List; | ||
|
||
@Getter | ||
public class EmailUpdateRequest { | ||
|
||
private List<String> recipients; | ||
private List<String> ccs; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/the_monitor/application/dto/request/KeywordUpdateRequest.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,16 @@ | ||
package the_monitor.application.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import the_monitor.domain.enums.CategoryType; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class KeywordUpdateRequest { | ||
@Schema(description = "카테고리와 키워드 매핑", example = "{ \"SELF\": [\"keyword1\", \"keyword2\"], \"COMPETITOR\": [\"keyword3\"], \"INDUSTRY\": [\"keyword4\"] }") | ||
private Map<CategoryType, List<String>> keywordsByCategory; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/the_monitor/application/dto/response/EmailResponse.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,20 @@ | ||
package the_monitor.application.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class EmailResponse { | ||
private List<String> recipients; | ||
private List<String> ccs; | ||
|
||
@Builder | ||
public EmailResponse(List<String> recipients, List<String> ccs) { | ||
this.recipients = recipients; | ||
this.ccs = ccs; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/the_monitor/application/service/CategoryService.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,16 @@ | ||
package the_monitor.application.service; | ||
|
||
import the_monitor.domain.enums.CategoryType; | ||
import the_monitor.domain.model.Category; | ||
import the_monitor.domain.model.Client; | ||
import the_monitor.domain.model.Keyword; | ||
|
||
import java.util.List; | ||
|
||
public interface CategoryService { | ||
// 카테고리 생성 및 키워드 저장 | ||
void saveCategoryWithKeywords(CategoryType categoryType, List<String> keywords, Client client); | ||
|
||
// 키워드 생성 | ||
List<Keyword> createKeywords(List<String> keywords, Category category); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/the_monitor/application/service/KeywordService.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,15 +1,19 @@ | ||
package the_monitor.application.service; | ||
|
||
import the_monitor.application.dto.request.KeywordUpdateRequest; | ||
import the_monitor.application.dto.response.KeywordResponse; | ||
import the_monitor.domain.enums.CategoryType; | ||
import the_monitor.domain.model.Keyword; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface KeywordService { | ||
|
||
KeywordResponse getKeywords(Long clientId); | ||
|
||
List<Keyword> getKeywordByAccountIdAndClientIdAndCategoryType(Long accountId, Long clientId, CategoryType categoryType); | ||
|
||
KeywordResponse updateKeywords(Long clientId, KeywordUpdateRequest keywordUpdateRequest); | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/the_monitor/application/serviceImpl/CategoryServiceImpl.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,53 @@ | ||
package the_monitor.application.serviceImpl; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import the_monitor.application.service.CategoryService; | ||
import the_monitor.domain.enums.CategoryType; | ||
import the_monitor.domain.model.Category; | ||
import the_monitor.domain.model.Client; | ||
import the_monitor.domain.model.Keyword; | ||
import the_monitor.domain.repository.CategoryRepository; | ||
import the_monitor.domain.repository.KeywordRepository; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class CategoryServiceImpl implements CategoryService { | ||
|
||
private final CategoryRepository categoryRepository; | ||
private final KeywordRepository keywordRepository; | ||
|
||
@Override | ||
public void saveCategoryWithKeywords(CategoryType categoryType, List<String> keywords, Client client) { | ||
// 카테고리 생성 | ||
Category category = Category.builder() | ||
.categoryType(categoryType) | ||
.client(client) | ||
.build(); | ||
categoryRepository.save(category); | ||
|
||
// 키워드 생성 | ||
List<Keyword> keywordEntities = createKeywords(keywords, category); | ||
keywordRepository.saveAll(keywordEntities); | ||
|
||
category.addKeywords(keywordEntities); | ||
} | ||
|
||
|
||
@Override | ||
public List<Keyword> createKeywords(List<String> keywords, Category category) { | ||
// 키워드 리스트를 Keyword 엔티티로 변환 | ||
return keywords.stream() | ||
.map(keyword -> Keyword.builder() | ||
.keyword(keyword) | ||
.category(category) | ||
.resultCount(0) // 초기 resultCount 설정 | ||
.build()) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
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.