-
Notifications
You must be signed in to change notification settings - Fork 0
[DP-493] 구독 가능한 기업 목록 조회 API #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
64a73c0
feat(SubscriptionService): getSubscribableCompany 개발
ralph-teuida 38f902d
feat(SubscriptionController): getSubscriptions()
ralph-teuida a6780b1
Merge branch 'develop' into DP-493
ralph-teuida 977f5b6
merge
ralph-teuida c03ac13
fix(테스트 코드 수정): company imageUrl 포맷 오류 수정
ralph-teuida 81d417f
fix(ElasticsearchSupportTest): company delete 추가
ssosee fd3188b
fix(PR): PR 리뷰 반영
ssosee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/docs/asciidoc/api/subscription/subscribable-companies.adoc
This file contains hidden or 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,26 @@ | ||
| [[Subscribable-Companies]] | ||
| == 기업 구독 API(GET: /devdevdev/api/v1/subscriptions/companies) | ||
|
|
||
| * 회원 또는 익명회원이 구독 가능한 기업 목록을 조회한다. | ||
|
|
||
| === 정상 요청/응답 | ||
|
|
||
| ==== HTTP Request | ||
|
|
||
| include::{snippets}/subscribable-companies/http-request.adoc[] | ||
|
|
||
| ==== HTTP Request Header Fields | ||
|
|
||
| include::{snippets}/subscribable-companies/request-headers.adoc[] | ||
|
|
||
| ==== HTTP Request Query Parameters Fields | ||
|
|
||
| include::{snippets}/subscribable-companies/query-parameters.adoc[] | ||
|
|
||
| ==== HTTP Response | ||
|
|
||
| include::{snippets}/subscribable-companies/http-response.adoc[] | ||
|
|
||
| ==== HTTP Response Fields | ||
|
|
||
| include::{snippets}/subscribable-companies/response-fields.adoc[] |
This file contains hidden or 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,5 @@ | ||
| = 기술 블로그 구독 | ||
|
|
||
| include::subscribe.adoc[] | ||
| include::unsubscribe.adoc[] | ||
| include::subscribable-companies.adoc[] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
3 changes: 2 additions & 1 deletion
3
src/main/java/com/dreamypatisiel/devdevdev/domain/repository/CompanyRepository.java
This file contains hidden or 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,7 +1,8 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.entity.Company; | ||
| import com.dreamypatisiel.devdevdev.domain.repository.techArticle.custom.CompanyRepositoryCustom; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface CompanyRepository extends JpaRepository<Company, Long> { | ||
| public interface CompanyRepository extends JpaRepository<Company, Long>, CompanyRepositoryCustom { | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
...va/com/dreamypatisiel/devdevdev/domain/repository/techArticle/SubscriptionRepository.java
This file contains hidden or 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,11 +1,15 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.techArticle; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.entity.Company; | ||
| import com.dreamypatisiel.devdevdev.domain.entity.Member; | ||
| import com.dreamypatisiel.devdevdev.domain.entity.Subscription; | ||
| import com.dreamypatisiel.devdevdev.domain.repository.techArticle.custom.SubscriptionRepositoryCustom; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface SubscriptionRepository extends JpaRepository<Subscription, Long>, SubscriptionRepositoryCustom { | ||
| Optional<Subscription> findByMemberAndCompanyId(Member member, Long companyId); | ||
|
|
||
| List<Subscription> findByMemberAndCompanyIn(Member member, List<Company> companies); | ||
| } |
9 changes: 9 additions & 0 deletions
9
...reamypatisiel/devdevdev/domain/repository/techArticle/custom/CompanyRepositoryCustom.java
This file contains hidden or 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,9 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.techArticle.custom; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.entity.Company; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Slice; | ||
|
|
||
| public interface CompanyRepositoryCustom { | ||
| Slice<Company> findCompanyByCursor(Pageable pageable, Long companyId); | ||
| } |
36 changes: 36 additions & 0 deletions
36
.../dreamypatisiel/devdevdev/domain/repository/techArticle/custom/CompanyRepositoryImpl.java
This file contains hidden or 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,36 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.techArticle.custom; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.entity.Company; | ||
| import static com.dreamypatisiel.devdevdev.domain.entity.QCompany.company; | ||
| import com.querydsl.core.types.dsl.BooleanExpression; | ||
| import com.querydsl.jpa.JPQLQueryFactory; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Slice; | ||
| import org.springframework.data.domain.SliceImpl; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public class CompanyRepositoryImpl implements CompanyRepositoryCustom { | ||
|
|
||
| private final JPQLQueryFactory query; | ||
|
|
||
| @Override | ||
| public Slice<Company> findCompanyByCursor(Pageable pageable, Long companyId) { | ||
| List<Company> contents = query.selectFrom(company) | ||
| .where(getCursorCondition(companyId)) | ||
| .orderBy(company.id.desc()) | ||
| .limit(pageable.getPageSize()) | ||
| .fetch(); | ||
|
|
||
| return new SliceImpl<>(contents, pageable, contents.size() >= pageable.getPageSize()); | ||
| } | ||
|
|
||
| private BooleanExpression getCursorCondition(Long companyId) { | ||
| if (companyId == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return company.id.lt(companyId); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
...java/com/dreamypatisiel/devdevdev/domain/service/response/SubscriableCompanyResponse.java
This file contains hidden or 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,35 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.service.response; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.entity.Company; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class SubscriableCompanyResponse { | ||
| private final Long companyId; | ||
| private final String companyImageUrl; | ||
| private final Boolean isSubscribed; | ||
|
|
||
| @Builder | ||
| public SubscriableCompanyResponse(Long companyId, String companyImageUrl, Boolean isSubscribed) { | ||
| this.companyId = companyId; | ||
| this.companyImageUrl = companyImageUrl; | ||
| this.isSubscribed = isSubscribed; | ||
| } | ||
|
|
||
| public static SubscriableCompanyResponse create(Company company) { | ||
| return SubscriableCompanyResponse.builder() | ||
| .companyId(company.getId()) | ||
| .companyImageUrl(company.getOfficialImageUrl().getUrl()) | ||
| .isSubscribed(false) | ||
| .build(); | ||
| } | ||
|
|
||
| public static SubscriableCompanyResponse createWithIsSubscribed(Company company, Boolean isSubscribed) { | ||
| return SubscriableCompanyResponse.builder() | ||
| .companyId(company.getId()) | ||
| .companyImageUrl(company.getOfficialImageUrl().getUrl()) | ||
| .isSubscribed(isSubscribed) | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.