diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/HotBoardsRetrievalController.java b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/HotBoardsRetrievalController.java index 5236643cd..148b5ef9a 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/in/web/HotBoardsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/in/web/HotBoardsRetrievalController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; @@ -12,8 +13,6 @@ import page.clab.api.domain.community.board.application.port.in.RetrieveHotBoardsUseCase; import page.clab.api.global.common.dto.ApiResponse; -import java.util.List; - @RestController @RequestMapping("/api/v1/boards") @RequiredArgsConstructor diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java index 9b8602ed3..502865f7d 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/BoardPersistenceAdapter.java @@ -1,5 +1,8 @@ package page.clab.api.domain.community.board.adapter.out.persistence; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -10,10 +13,6 @@ import page.clab.api.domain.community.board.domain.BoardCategory; import page.clab.api.global.exception.NotFoundException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; - @Component @RequiredArgsConstructor public class BoardPersistenceAdapter implements diff --git a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/RedisHotBoardPersistenceAdapter.java b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/RedisHotBoardPersistenceAdapter.java index 3ff92cf92..2e1c45622 100644 --- a/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/RedisHotBoardPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/community/board/adapter/out/persistence/RedisHotBoardPersistenceAdapter.java @@ -1,5 +1,8 @@ package page.clab.api.domain.community.board.adapter.out.persistence; +import java.util.List; +import java.util.Objects; +import java.util.Set; import lombok.RequiredArgsConstructor; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; @@ -7,10 +10,6 @@ import page.clab.api.domain.community.board.application.port.out.RemoveHotBoardPort; import page.clab.api.domain.community.board.application.port.out.RetrieveHotBoardPort; -import java.util.List; -import java.util.Objects; -import java.util.Set; - @Component @RequiredArgsConstructor public class RedisHotBoardPersistenceAdapter implements diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java index 0ed4eae3e..33a546928 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java @@ -7,7 +7,6 @@ import page.clab.api.domain.community.board.application.dto.response.BoardDetailsResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardEmojiCountResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardHashtagResponseDto; -import page.clab.api.domain.community.board.application.dto.response.BoardEmojiToggleResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardListResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardMyResponseDto; import page.clab.api.domain.community.board.application.dto.response.BoardOverviewResponseDto; diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java index 7853abcfd..cb1ee03a2 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java @@ -19,10 +19,10 @@ public BoardHashtag fromDto(Long boardId, Long hashtagId) { .build(); } - public BoardHashtagRequestDto toDto(Long boardId, List hashtagIdList) { + public BoardHashtagRequestDto toDto(Long boardId, List hashtagNames) { return BoardHashtagRequestDto.builder() .boardId(boardId) - .hashtagIds(hashtagIdList) + .hashtagNames(hashtagNames) .build(); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardHashtagRequestDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardHashtagRequestDto.java index ec062b064..b86f830c4 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardHashtagRequestDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardHashtagRequestDto.java @@ -11,5 +11,5 @@ public class BoardHashtagRequestDto { private Long boardId; - private List hashtagIds; + private List hashtagNames; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java index b8b933fd6..dc8fc2a60 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardRequestDto.java @@ -33,6 +33,6 @@ public class BoardRequestDto { @Schema(description = "익명 사용 여부", example = "false", required = true) private boolean wantAnonymous; - @Schema(description = "해시태그 id 리스트", example = "[1, 2]") - private List hashtagIdList; + @Schema(description = "해시태그 이름 리스트", example = "[\"Java\", \"C++\"]") + private List hashtagNames; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardUpdateRequestDto.java b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardUpdateRequestDto.java index 57a962276..139b8860e 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardUpdateRequestDto.java +++ b/src/main/java/page/clab/api/domain/community/board/application/dto/request/BoardUpdateRequestDto.java @@ -27,6 +27,6 @@ public class BoardUpdateRequestDto { @Schema(description = "익명 사용 여부", example = "false") private boolean wantAnonymous; - @Schema(description = "해시태그 id 리스트", example = "[1, 2]") - private List hashtagIdList; + @Schema(description = "해시태그 이름 리스트", example = "[\"Java\", \"Devops\"]") + private List hashtagNames; } diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveHotBoardsUseCase.java b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveHotBoardsUseCase.java index 11da513c5..cf6d3f91a 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveHotBoardsUseCase.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/in/RetrieveHotBoardsUseCase.java @@ -1,8 +1,7 @@ package page.clab.api.domain.community.board.application.port.in; -import page.clab.api.domain.community.board.application.dto.response.BoardListResponseDto; - import java.util.List; +import page.clab.api.domain.community.board.application.dto.response.BoardListResponseDto; public interface RetrieveHotBoardsUseCase { List retrieveHotBoards(String strategyName); diff --git a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardPort.java b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardPort.java index 5e42bcc25..e9d5741d3 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardPort.java +++ b/src/main/java/page/clab/api/domain/community/board/application/port/out/RetrieveBoardPort.java @@ -1,13 +1,12 @@ package page.clab.api.domain.community.board.application.port.out; +import java.time.LocalDateTime; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import page.clab.api.domain.community.board.domain.Board; import page.clab.api.domain.community.board.domain.BoardCategory; -import java.time.LocalDateTime; -import java.util.List; - public interface RetrieveBoardPort { Board getById(Long boardId); diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java index d6384fd96..201099f0b 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardHashtagRegisterService.java @@ -25,9 +25,9 @@ public class BoardHashtagRegisterService implements RegisterBoardHashtagUseCase @Override public Long registerBoardHashtag(BoardHashtagRequestDto requestDto) { Long boardId = requestDto.getBoardId(); - for (Long hashtagId : requestDto.getHashtagIds()) { - Hashtag hashtag = externalRetrieveHashtagUseCase.getById(hashtagId); - BoardHashtag boardHashtag = mapper.fromDto(boardId, hashtagId); + for (String hashtagName : requestDto.getHashtagNames()) { + Hashtag hashtag = externalRetrieveHashtagUseCase.getByName(hashtagName); + BoardHashtag boardHashtag = mapper.fromDto(boardId, hashtag.getId()); registerBoardHashtagPort.save(boardHashtag); hashtag.incrementBoardUsage(); externalRegisterHashtagUseCase.save(hashtag); diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java index 6300b58a2..d6ff74bfa 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRegisterService.java @@ -53,7 +53,7 @@ public String registerBoard(BoardRequestDto requestDto) throws PermissionDeniedE List uploadedFiles = uploadedFileService.getUploadedFilesByUrls(requestDto.getFileUrlList()); Board board = boardDtoMapper.fromDto(requestDto, currentMemberInfo.getMemberId(), uploadedFiles); board.validateAccessPermissionForCreation(currentMemberInfo); - board.validateBoardHashtagRegistration(requestDto.getHashtagIdList()); + board.validateBoardHashtagRegistration(requestDto.getHashtagNames()); if (board.shouldNotifyForNewBoard(currentMemberInfo)) { externalSendNotificationUseCase.sendNotificationToMember(currentMemberInfo.getMemberId(), @@ -65,9 +65,9 @@ public String registerBoard(BoardRequestDto requestDto) throws PermissionDeniedE Board savedBoard = registerBoardPort.save(board); - if (requestDto.getHashtagIdList() != null) { + if (requestDto.getHashtagNames() != null && !requestDto.getHashtagNames().isEmpty()) { registerBoardHashtagUseCase.registerBoardHashtag( - boardHashtagDtoMapper.toDto(savedBoard.getId(), requestDto.getHashtagIdList())); + boardHashtagDtoMapper.toDto(savedBoard.getId(), requestDto.getHashtagNames())); } return savedBoard.getCategory().getKey(); } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java index e640fcce4..4cea345eb 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardUpdateService.java @@ -47,7 +47,11 @@ public String updateBoard(Long boardId, BoardUpdateRequestDto requestDto) throws board.update(requestDto); - List hastagIdList = requestDto.getHashtagIdList(); + List hashtagNames = requestDto.getHashtagNames(); + + List hastagIdList = hashtagNames.stream() + .map(externalRetrieveHashtagUseCase::getIdByName) + .toList(); handleBoardHashtagUpdate(boardId, board, hastagIdList); eventPublisher.publishEvent(new BoardUpdatedEvent(this, board.getId())); @@ -70,6 +74,9 @@ private void deleteAllHashtagsForBoard(Long boardId) { currentBoardHashtags.forEach(boardHashtag -> { if (!boardHashtag.getIsDeleted()) { boardHashtag.toggleIsDeletedStatus(); + Hashtag hashtag = externalRetrieveHashtagUseCase.getById(boardHashtag.getHashtagId()); + hashtag.decreaseBoardUsage(); + externalRegisterHashtagUseCase.save(hashtag); registerBoardHashtagPort.save(boardHashtag); } }); @@ -151,7 +158,8 @@ private void addOrUpdateHashtag(Long boardId, Long hashtagId, List }, () -> { registerBoardHashtagUseCase.registerBoardHashtag( - boardHashtagDtoMapper.toDto(boardId, List.of(hashtagId)) + boardHashtagDtoMapper.toDto(boardId, + List.of(externalRetrieveHashtagUseCase.getNameById(hashtagId))) ); } ); diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/DefaultHotBoardSelectionStrategy.java b/src/main/java/page/clab/api/domain/community/board/application/service/DefaultHotBoardSelectionStrategy.java index b31a4f1c3..00d33bc04 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/DefaultHotBoardSelectionStrategy.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/DefaultHotBoardSelectionStrategy.java @@ -1,5 +1,11 @@ package page.clab.api.domain.community.board.application.service; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,13 +14,6 @@ import page.clab.api.domain.community.board.domain.Board; import page.clab.api.external.community.comment.application.port.ExternalRetrieveCommentUseCase; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - @Service(HotBoardSelectionStrategies.DEFAULT) @RequiredArgsConstructor public class DefaultHotBoardSelectionStrategy implements HotBoardSelectionStrategy { diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRegisterService.java b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRegisterService.java index 462ef38dc..b810954ac 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRegisterService.java @@ -1,5 +1,7 @@ package page.clab.api.domain.community.board.application.service; +import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -8,9 +10,6 @@ import page.clab.api.domain.community.board.application.port.out.RemoveHotBoardPort; import page.clab.api.domain.community.board.domain.Board; -import java.util.List; -import java.util.Map; - @Service @RequiredArgsConstructor public class HotBoardRegisterService { diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRetrievalService.java index 0aa370a62..ade6b8845 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRetrievalService.java @@ -2,6 +2,8 @@ import com.drew.lang.annotations.NotNull; import jakarta.transaction.Transactional; +import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import page.clab.api.domain.community.board.application.dto.mapper.BoardDtoMapper; @@ -15,9 +17,6 @@ import page.clab.api.external.community.comment.application.port.ExternalRetrieveCommentUseCase; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; -import java.util.List; -import java.util.Map; - @Service @RequiredArgsConstructor public class HotBoardRetrievalService implements RetrieveHotBoardsUseCase { diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardSelectionStrategy.java b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardSelectionStrategy.java index 6a2d4a5c9..f15f70d43 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardSelectionStrategy.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/HotBoardSelectionStrategy.java @@ -1,8 +1,7 @@ package page.clab.api.domain.community.board.application.service; -import page.clab.api.domain.community.board.domain.Board; - import java.util.List; +import page.clab.api.domain.community.board.domain.Board; public interface HotBoardSelectionStrategy { List getHotBoards(); diff --git a/src/main/java/page/clab/api/domain/community/board/domain/Board.java b/src/main/java/page/clab/api/domain/community/board/domain/Board.java index 069d355c2..fbde99831 100644 --- a/src/main/java/page/clab/api/domain/community/board/domain/Board.java +++ b/src/main/java/page/clab/api/domain/community/board/domain/Board.java @@ -75,8 +75,8 @@ public void validateAccessPermissionForCreation(MemberDetailedInfoDto currentMem } } - public void validateBoardHashtagRegistration(List hashtagIds) { - if (!isDevelopmentQna() && (hashtagIds != null && !hashtagIds.isEmpty())) { + public void validateBoardHashtagRegistration(List hashtagNames) { + if (!isDevelopmentQna() && (hashtagNames != null && !hashtagNames.isEmpty())) { throw new InvalidBoardCategoryHashtagException("개발질문 게시판에만 해시태그를 등록할 수 있습니다."); } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java b/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java index c878d0cfa..35a74b0d6 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java @@ -27,7 +27,7 @@ public class HashtagRegisterController { @PreAuthorize("hasRole('ADMIN')") @PostMapping("") public ApiResponse> registerHashtag( - @Valid @RequestBody HashtagRequestDto requestDto + @Valid @RequestBody List requestDto ) { List hashTags = registerHashtagUseCase.registerHashtag(requestDto); return ApiResponse.success(hashTags); diff --git a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java index 62721ab11..00c570b0f 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/adapter/out/persistence/HashtagJpaEntity.java @@ -2,6 +2,8 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -14,6 +16,7 @@ import lombok.Setter; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLRestriction; +import page.clab.api.domain.community.hashtag.domain.HashtagCategory; import page.clab.api.global.common.domain.BaseEntity; @Entity @@ -34,6 +37,10 @@ public class HashtagJpaEntity extends BaseEntity { @Column(name = "name", unique = true, nullable = false) private String name; + @Column(name = "hashtag_category", nullable = false) + @Enumerated(EnumType.STRING) + private HashtagCategory hashtagCategory; + @Column(name = "board_usage", nullable = false) private Long boardUsage; diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java index e9797bba7..6188c9655 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java @@ -4,14 +4,16 @@ import org.springframework.stereotype.Component; import page.clab.api.domain.community.hashtag.application.dto.response.HashtagResponseDto; import page.clab.api.domain.community.hashtag.domain.Hashtag; +import page.clab.api.domain.community.hashtag.domain.HashtagCategory; @Component @RequiredArgsConstructor public class HashtagDtoMapper { - public Hashtag of(String name) { + public Hashtag of(String name, HashtagCategory hashtagCategory) { return Hashtag.builder() .name(name) + .hashtagCategory(hashtagCategory) .boardUsage(0L) .isDeleted(false) .build(); @@ -21,6 +23,7 @@ public HashtagResponseDto toDto(Hashtag hashtag) { return HashtagResponseDto.builder() .id(hashtag.getId()) .name(hashtag.getName()) + .hashtagCategory(hashtag.getHashtagCategory().getKey()) .boardUsageCount(hashtag.getBoardUsage()) .build(); } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java index e5f2ea1ee..997bfea52 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java @@ -1,13 +1,17 @@ package page.clab.api.domain.community.hashtag.application.dto.request; -import java.util.ArrayList; -import java.util.List; +import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; +import page.clab.api.domain.community.hashtag.domain.HashtagCategory; @Getter @Setter public class HashtagRequestDto { - List hashtagNames = new ArrayList<>(); + @NotNull + private String name; + + @NotNull + private HashtagCategory hashtagCategory; } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/response/HashtagResponseDto.java b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/response/HashtagResponseDto.java index 509ffdf2a..c7c9cb10b 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/dto/response/HashtagResponseDto.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/dto/response/HashtagResponseDto.java @@ -9,5 +9,6 @@ public class HashtagResponseDto { private Long id; private String name; + private String hashtagCategory; private Long boardUsageCount; } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java b/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java index 508a49b73..98a36b444 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java @@ -6,5 +6,5 @@ public interface RegisterHashtagUseCase { - List registerHashtag(HashtagRequestDto requestDto); + List registerHashtag(List requestDto); } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRegisterService.java b/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRegisterService.java index d4ea81ebe..4d7c2945d 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRegisterService.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRegisterService.java @@ -11,6 +11,7 @@ import page.clab.api.domain.community.hashtag.application.port.in.RetrieveHashtagUseCase; import page.clab.api.domain.community.hashtag.application.port.out.RegisterHashtagPort; import page.clab.api.domain.community.hashtag.domain.Hashtag; +import page.clab.api.domain.community.hashtag.domain.HashtagCategory; @Service @RequiredArgsConstructor @@ -21,16 +22,18 @@ public class HashtagRegisterService implements RegisterHashtagUseCase { private final HashtagDtoMapper mapper; @Override - public List registerHashtag(HashtagRequestDto requestDto) { - List savedHashtagId = new ArrayList<>(); - for (String name : requestDto.getHashtagNames()) { + public List registerHashtag(List requestDtos) { + List savedHashtag = new ArrayList<>(); + for (HashtagRequestDto requestDto : requestDtos) { + String name = requestDto.getName(); + HashtagCategory hashtagCategory = requestDto.getHashtagCategory(); if (retrieveHashtagUseCase.existsByName(name)) { - savedHashtagId.add(mapper.toDto(retrieveHashtagUseCase.getByName(name))); + savedHashtag.add(mapper.toDto(retrieveHashtagUseCase.getByName(name))); } else { - Hashtag hashtag = mapper.of(name); - savedHashtagId.add(mapper.toDto(registerHashtagPort.save(hashtag))); + Hashtag hashtag = mapper.of(name, hashtagCategory); + savedHashtag.add(mapper.toDto(registerHashtagPort.save(hashtag))); } } - return savedHashtagId; + return savedHashtag; } } diff --git a/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java b/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java index a320679ad..ead91b88b 100644 --- a/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java +++ b/src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java @@ -16,6 +16,7 @@ public class Hashtag { Long id; String name; + HashtagCategory hashtagCategory; Boolean isDeleted; Long boardUsage; diff --git a/src/main/java/page/clab/api/domain/community/hashtag/domain/HashtagCategory.java b/src/main/java/page/clab/api/domain/community/hashtag/domain/HashtagCategory.java new file mode 100644 index 000000000..3e87db44c --- /dev/null +++ b/src/main/java/page/clab/api/domain/community/hashtag/domain/HashtagCategory.java @@ -0,0 +1,17 @@ +package page.clab.api.domain.community.hashtag.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum HashtagCategory { + + LANGUAGE("LANGUAGE", "언어"), + FIELD("FIELD", "분야"), + SKILL("SKILL", "기술"), + ETC("ETC", "기타"); + + private final String key; + private final String description; +} diff --git a/src/main/java/page/clab/api/external/hashtag/application/port/ExternalRetrieveHashtagUseCase.java b/src/main/java/page/clab/api/external/hashtag/application/port/ExternalRetrieveHashtagUseCase.java index 8a3e0a2da..59df13bea 100644 --- a/src/main/java/page/clab/api/external/hashtag/application/port/ExternalRetrieveHashtagUseCase.java +++ b/src/main/java/page/clab/api/external/hashtag/application/port/ExternalRetrieveHashtagUseCase.java @@ -7,4 +7,8 @@ public interface ExternalRetrieveHashtagUseCase { Hashtag getById(Long id); Hashtag getByName(String name); + + Long getIdByName(String name); + + String getNameById(Long id); } diff --git a/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java b/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java index 0a856cb16..a67b18ce0 100644 --- a/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java +++ b/src/main/java/page/clab/api/external/hashtag/application/service/ExternalHashtagRetrievalService.java @@ -23,4 +23,14 @@ public Hashtag getById(Long id) { public Hashtag getByName(String name) { return retrieveHashtagUseCase.getByName(name); } + + @Override + public Long getIdByName(String name) { + return getByName(name).getId(); + } + + @Override + public String getNameById(Long id) { + return getById(id).getName(); + } }