-
Notifications
You must be signed in to change notification settings - Fork 0
[FEATURE] 디자이너 외주 찾기 목록 조회 기능 추가 #59
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
8 commits
Select commit
Hold shift + click to select a range
68043fc
Feat(commission): 디자이너 모집 중 외주 목록 조회 API 구현
Jong0128 3746224
Refactor(Commission): `totalElements` Long -> long 타입 변환
Jong0128 b1a2942
Style(Designer): 공백 제거
Jong0128 c6eee22
Refactor(Designer): getById 트랜잭션 readonly true 추가
Jong0128 0942d9d
Fix(Designer): DesignerErrorCode 에러코드 수정
Jong0128 cc206a1
Merge remote-tracking branch 'origin/dev' into feat/#55-designers-com…
Jong0128 d6e4556
Refactor(Commission): CommissionMapper 제거 및 가격 계산 책임을 CommissionPrice…
Jong0128 f06adfa
Fix(Designer): ErrorCode HttpStatus 수정
Jong0128 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...in/java/ditda/backend/domain/commission/core/controller/DesignerCommissionController.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,48 @@ | ||
| package ditda.backend.domain.commission.core.controller; | ||
|
|
||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Sort; | ||
| import org.springframework.data.web.PageableDefault; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import ditda.backend.domain.commission.core.dto.response.CommissionListResponse; | ||
| import ditda.backend.domain.commission.core.facade.DesignerCommissionFacade; | ||
| import ditda.backend.global.apipayload.response.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/designers/commissions") | ||
| @RequiredArgsConstructor | ||
| @Tag(name = "Designer", description = "디자이너 모집 중 외주 목록 API") | ||
| public class DesignerCommissionController { | ||
|
|
||
| private final DesignerCommissionFacade designerCommissionFacade; | ||
|
|
||
| @Operation(summary = "모집 중 외주 목록 조회", description = "**[외주 찾기]** 디자이너가 모집 중인 외주 목록을 조회합니다.") | ||
| @GetMapping | ||
| public ApiResponse<CommissionListResponse> getRecruitingCommissions( | ||
| @AuthenticationPrincipal Long designerId, | ||
| @PageableDefault Pageable pageable | ||
| ) { | ||
|
|
||
| // 지원 마감일 기준 오름차순 정렬 | ||
| Pageable fixedPageable = PageRequest.of( | ||
| pageable.getPageNumber(), | ||
| pageable.getPageSize(), | ||
| Sort.by(Sort.Order.asc("applicationDeadline"), Sort.Order.asc("id")) | ||
| ); | ||
|
|
||
| CommissionListResponse response = designerCommissionFacade.getRecruitingCommissionList( | ||
| designerId, | ||
| fixedPageable | ||
| ); | ||
|
|
||
| return ApiResponse.onSuccess("디자이너 모집 중 외주 목록 조회 성공", response); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/ditda/backend/domain/commission/core/dto/PriceInfo.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,7 @@ | ||
| package ditda.backend.domain.commission.core.dto; | ||
|
|
||
| public record PriceInfo( | ||
| int baseAmount, | ||
| int maxAmount | ||
| ) { | ||
| } |
80 changes: 80 additions & 0 deletions
80
src/main/java/ditda/backend/domain/commission/core/dto/response/CommissionListResponse.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,80 @@ | ||
| package ditda.backend.domain.commission.core.dto.response; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.springframework.data.domain.Page; | ||
|
|
||
| import ditda.backend.domain.commission.core.dto.PriceInfo; | ||
| import ditda.backend.domain.commission.core.entity.Commission; | ||
| import ditda.backend.domain.commission.core.entity.enums.CategoryType; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(description = "디자이너 외주 목록 조회 응답") | ||
| public record CommissionListResponse( | ||
|
|
||
| @Schema(description = "외주 목록") | ||
| List<CommissionResponse> commissions, | ||
|
|
||
| @Schema(description = "현재 페이지 번호", example = "0") | ||
| int page, | ||
|
|
||
| @Schema(description = "페이지 크기", example = "10") | ||
| int size, | ||
|
|
||
| @Schema(description = "전체 데이터 수", example = "23") | ||
| long totalElements, | ||
|
|
||
| @Schema(description = "전체 페이지 수", example = "3") | ||
| int totalPages | ||
| ) { | ||
|
|
||
| public static CommissionListResponse from(Page<Commission> page, Map<Long, PriceInfo> priceInfos) { | ||
| List<CommissionResponse> items = page.getContent().stream() | ||
| .map(c -> CommissionResponse.from(c, priceInfos.get(c.getId()))) | ||
| .toList(); | ||
|
|
||
| return new CommissionListResponse( | ||
| items, | ||
| page.getNumber(), | ||
| page.getSize(), | ||
| page.getTotalElements(), | ||
| page.getTotalPages() | ||
| ); | ||
| } | ||
|
|
||
| @Schema(description = "외주 정보") | ||
| public record CommissionResponse( | ||
|
|
||
| @Schema(description = "외주 ID", example = "1") | ||
| Long commissionId, | ||
|
|
||
| @Schema(description = "지원 마감일", example = "2026-05-05") | ||
| LocalDate applicationDeadline, | ||
|
|
||
| @Schema(description = "외주 카테고리", example = "FLYER_TEXTBOOK_COVER_INNER") | ||
| CategoryType category, | ||
|
|
||
| @Schema(description = "제목", example = "해커스톡 왕초보 - 홍길동") | ||
| String title, | ||
|
|
||
| @Schema(description = "기본금 (원)", example = "40000") | ||
| int baseAmount, | ||
|
|
||
| @Schema(description = "최대금액 (원)", example = "210000") | ||
| int maxAmount | ||
| ) { | ||
|
|
||
| private static CommissionResponse from(Commission commission, PriceInfo priceInfo) { | ||
| return new CommissionResponse( | ||
| commission.getId(), | ||
| commission.getApplicationDeadline(), | ||
| commission.getCategoryType(), | ||
| commission.getTitle(), | ||
| priceInfo.baseAmount(), | ||
| priceInfo.maxAmount() | ||
| ); | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/ditda/backend/domain/commission/core/entity/enums/CommissionAmountPolicy.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,34 @@ | ||
| package ditda.backend.domain.commission.core.entity.enums; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import ditda.backend.domain.designer.entity.enums.DesignerLevel; | ||
| import ditda.backend.domain.designer.exception.DesignerErrorCode; | ||
| import ditda.backend.global.apipayload.exception.GeneralException; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum CommissionAmountPolicy { | ||
|
|
||
| LEVEL_1(DesignerLevel.LEVEL_1, 40_000), | ||
| LEVEL_2(DesignerLevel.LEVEL_2, 50_000), | ||
| LEVEL_3(DesignerLevel.LEVEL_3, 60_000); | ||
|
|
||
| private static final int MAX_AMOUNT_BONUS = 150_000; | ||
|
|
||
| private final DesignerLevel level; | ||
| private final int baseAmount; | ||
|
|
||
| public int getMaxAmount() { | ||
| return baseAmount + MAX_AMOUNT_BONUS; | ||
| } | ||
|
|
||
| public static CommissionAmountPolicy from(DesignerLevel level) { | ||
| return Arrays.stream(values()) | ||
| .filter(policy -> policy.level == level) | ||
| .findFirst() | ||
| .orElseThrow(() -> new GeneralException(DesignerErrorCode.DESIGNER_LEVEL_POLICY_MISSING)); | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
src/main/java/ditda/backend/domain/commission/core/facade/DesignerCommissionFacade.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,44 @@ | ||
| package ditda.backend.domain.commission.core.facade; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import ditda.backend.domain.commission.core.dto.PriceInfo; | ||
| import ditda.backend.domain.commission.core.dto.response.CommissionListResponse; | ||
| import ditda.backend.domain.commission.core.entity.Commission; | ||
| import ditda.backend.domain.commission.core.policy.CommissionPricePolicy; | ||
| import ditda.backend.domain.commission.core.service.DesignerCommissionService; | ||
| import ditda.backend.domain.designer.entity.Designer; | ||
| import ditda.backend.domain.designer.entity.enums.DesignerLevel; | ||
| import ditda.backend.domain.designer.service.DesignerService; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class DesignerCommissionFacade { | ||
|
|
||
| private final DesignerCommissionService designerCommissionService; | ||
| private final DesignerService designerService; | ||
| private final CommissionPricePolicy commissionPricePolicy; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public CommissionListResponse getRecruitingCommissionList(Long designerId, Pageable pageable) { | ||
|
|
||
| Designer designer = designerService.getById(designerId); | ||
| DesignerLevel level = designer.getLevel(); | ||
| Page<Commission> commissions = designerCommissionService.getRecruitingCommissions(pageable); | ||
|
|
||
| Map<Long, PriceInfo> priceInfos = commissions.getContent().stream() | ||
| .collect(Collectors.toMap( | ||
| Commission::getId, | ||
| c -> commissionPricePolicy.getPriceInfo(c.getCategoryType(), level) | ||
| )); | ||
|
|
||
| return CommissionListResponse.from(commissions, priceInfos); | ||
| } | ||
| } |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/ditda/backend/domain/commission/core/service/DesignerCommissionService.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,27 @@ | ||
| package ditda.backend.domain.commission.core.service; | ||
|
|
||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import ditda.backend.domain.commission.core.entity.Commission; | ||
| import ditda.backend.domain.commission.core.entity.enums.CommissionStatus; | ||
| import ditda.backend.domain.commission.core.repository.CommissionRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class DesignerCommissionService { | ||
|
|
||
| private final CommissionRepository commissionRepository; | ||
|
|
||
| // 모집 중 외주 목록 조회 | ||
| @Transactional(readOnly = true) | ||
| public Page<Commission> getRecruitingCommissions(Pageable pageable) { | ||
| return commissionRepository.findByStatus( | ||
| CommissionStatus.RECRUITING, | ||
| pageable | ||
| ); | ||
| } | ||
| } |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/ditda/backend/domain/designer/service/DesignerService.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,23 @@ | ||
| package ditda.backend.domain.designer.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import ditda.backend.domain.designer.entity.Designer; | ||
| import ditda.backend.domain.designer.exception.DesignerErrorCode; | ||
| import ditda.backend.domain.designer.repository.DesignerRepository; | ||
| import ditda.backend.global.apipayload.exception.GeneralException; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class DesignerService { | ||
|
|
||
| private final DesignerRepository designerRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public Designer getById(Long designerId) { | ||
| return designerRepository.findById(designerId) | ||
| .orElseThrow(() -> new GeneralException(DesignerErrorCode.DESIGNER_NOT_FOUND)); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#60 에
CommissionPricePolicy를 이미 구현해 놓았는데,카테고리에 따라서 가격이 달라지고도 하고 환불/정산 등의 계산 로직이 추가로 들어와야 하는데 이를 enum으로만 관리하기에는 확장성 면에서 무리가 있을 것 같습니다.
혹시
CommissionPricePolicy로 통일해서 구현해주실 수 있을까요...?그렇게 되면 아마
CommissionMapper없이 단순 from/of 정적 메소드로 변환이 가능할 것 같습니다..!Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금
CommissionPricePolicy가 @component로 등록되어 있어서 등록 없이 from 정적 메소드로 변환은 힘들꺼같습니다..!그래서
CommissionPricePolicy를CommissionMapper에 주입해서 금액 계산을 위임하는 방향으로 통일하려고 합니다. 이렇게 되면 기존CommissionAmountPolicyenum은 제거되고, 가격 로직은CommissionPricePolicy로 통일할 수 있을꺼같은데 괜찮을까요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommissionMapper는 편의에 따라서 유지하셔도 무방할 것 같습니다.다만, 비즈니스 로직이 포함되어 있는
CommissionPricePolicy를 mapper에서 호출하게 된다면, mapper는 단순 변환 역할 이상의 구조를 가지게 됩니다.차라리 Service/Facade에서 계산해서 넘기는 구조가 어떨까요..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fervovita 해당 부분
CommissionMapper제거 후CommissionPricePolicy을 통해 계산하는걸로 수정했습니다!확인해주시고 다른 문제나 변경사항이 필요하면 편하게 말씀해주세요!
만약 문제가 따로 없다면 해당 부분 merge 후 #65 해당 PR도 수정하겠습니다 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommissionAmountPolicy가 여전히 남아 있는데 이 부분만 삭제 부탁드립니다!아마 그러면
DesignerErrorCode에 새로 추가한 에러도 불필요 해질 것 같아요!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어 해당부분 못보고 머지했네요 ㅠㅠ;;;
해당 부분 #65 여기서 수정해서 올리겠습니다..!