-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
154 additions
and
14 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
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
TodaysFail-Domain/src/main/java/com/todaysfail/domains/tag/repository/TagRepository.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,9 +1,14 @@ | ||
package com.todaysfail.domains.tag.repository; | ||
|
||
import com.todaysfail.domains.tag.domain.Tag; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface TagRepository extends JpaRepository<Tag, Long> { | ||
Optional<Tag> findByTagName(String tagName); | ||
|
||
List<Tag> findTop5ByTagNameContainsIgnoreCase(String searchKeyword); | ||
|
||
List<Tag> findTop5ByOrderByUsedCountDesc(); | ||
} |
17 changes: 17 additions & 0 deletions
17
TodaysFail-Domain/src/main/java/com/todaysfail/domains/tag/service/TagDomainService.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,17 @@ | ||
package com.todaysfail.domains.tag.service; | ||
|
||
import com.todaysfail.aop.lock.RedissonLock; | ||
import com.todaysfail.domains.tag.domain.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TagDomainService { | ||
|
||
@RedissonLock(lockName = "태그사용수증가", identifier = "tag") | ||
public Tag increaseUsedCount(Tag tag) { | ||
tag.increaseUsedCount(); | ||
return tag; | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/TagController.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,40 @@ | ||
package com.todaysfail.api.web.tag; | ||
|
||
import com.todaysfail.api.web.tag.dto.response.TagResponse; | ||
import com.todaysfail.api.web.tag.usecase.TagPopularUseCase; | ||
import com.todaysfail.api.web.tag.usecase.TagSearchUseCase; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "7. [태그]") | ||
@RestController | ||
@RequestMapping("/api/v1/tags") | ||
@SecurityRequirement(name = "access-token") | ||
@RequiredArgsConstructor | ||
public class TagController { | ||
private final TagSearchUseCase tagSearchUseCase; | ||
private final TagPopularUseCase tagPopularUseCase; | ||
|
||
@Operation(summary = "태그를 검색합니다. (5개)") | ||
@GetMapping("/search") | ||
public List<TagResponse> search(@RequestParam String searchKeyword) { | ||
return tagSearchUseCase.execute(searchKeyword); | ||
} | ||
|
||
@Operation(summary = "많이 사용된 태그를 조회합니다. (5개)") | ||
@GetMapping("/popular") | ||
public List<TagResponse> popular() { | ||
return tagPopularUseCase.execute(); | ||
} | ||
|
||
// @Operation(summary = "추천 태그를 조회합니다.") | ||
// @GetMapping("/recommend") | ||
// TODO: 추천 태그 조회 API 구현 | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/TagPopularUseCase.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,21 @@ | ||
package com.todaysfail.api.web.tag.usecase; | ||
|
||
import com.todaysfail.api.web.tag.dto.response.TagResponse; | ||
import com.todaysfail.api.web.tag.mapper.TagMapper; | ||
import com.todaysfail.common.annotation.UseCase; | ||
import com.todaysfail.domains.tag.domain.Tag; | ||
import com.todaysfail.domains.tag.port.TagQueryPort; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class TagPopularUseCase { | ||
private final TagMapper tagMapper; | ||
private final TagQueryPort tagQueryPort; | ||
|
||
public List<TagResponse> execute() { | ||
List<Tag> popularTagList = tagQueryPort.queryPopular(); | ||
return tagMapper.toTagResponseList(popularTagList); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/TagSearchUseCase.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,21 @@ | ||
package com.todaysfail.api.web.tag.usecase; | ||
|
||
import com.todaysfail.api.web.tag.dto.response.TagResponse; | ||
import com.todaysfail.api.web.tag.mapper.TagMapper; | ||
import com.todaysfail.common.annotation.UseCase; | ||
import com.todaysfail.domains.tag.domain.Tag; | ||
import com.todaysfail.domains.tag.port.TagQueryPort; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class TagSearchUseCase { | ||
private final TagMapper tagMapper; | ||
private final TagQueryPort tagQueryPort; | ||
|
||
public List<TagResponse> execute(String searchKeyword) { | ||
List<Tag> tagList = tagQueryPort.querySearch(searchKeyword); | ||
return tagMapper.toTagResponseList(tagList); | ||
} | ||
} |