Skip to content
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

fix: 지원 시 포트폴리오 관리 수정 #268

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public record ApplyReq(
@Schema(description = "포트폴리오 공개 설정", example = "false", defaultValue = "false")
Boolean isPrivate,

@Nullable
@Schema(description = "포트폴리오 타입", example = "NOTION | FILE")
String dataType,

@Size(max = 1000)
@Schema(description = "지원 이유", example = "저는 데이터 사이언스 과목을 수강하며 데이터에 관한 기본적인 내용들을 배우며 이런 데이터를 잘 활용하고, 이용하는 것이 중요한 역량이 될 것 같다고 판단했습니다. 그래서 관련된 역량을 쌓고자 공모전에 출품하고 싶다는 생각을 가지게 되었고, 공공데이터 공모전이 적합하다고 생각했습니다!")
String body,
Expand All @@ -40,7 +44,7 @@ public record ApplyReq(
String part
) {
public static Apply toEntity(ApplyReq req, Team team, Member member, @Nullable Portfolio portfolio) {
PortfolioInfo portfolioInfo = PortfolioInfo.ofPortfolio(portfolio, req.isPrivate());
PortfolioInfo portfolioInfo = PortfolioInfo.ofPortfolio(portfolio, req.isPrivate(), req.dataType());

return Apply.builder()
.team(team)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public record ApplyRes(
@Nullable
String portfolioName,

@Nullable
String dataType,

Boolean isPrivate,

@Size(max = 1000)
Expand Down Expand Up @@ -119,6 +122,7 @@ public static ApplyRes of(Apply apply) {
.leaderName(apply.getTeam().getMember().getName())
.portfolioId(apply.getPortfolioInfo().isPrivate() ? null : apply.getPortfolioInfo().getPortfolio().getId())
.portfolioName(apply.getPortfolioInfo().isPrivate() ? null : apply.getPortfolioInfo().getPortfolio().getPortfolioName())
.dataType(apply.getPortfolioInfo().isPrivate() ? null : apply.getPortfolioInfo().getDataType())
.isPrivate(apply.getPortfolioInfo().isPrivate())
.body(apply.getBody())
.status(apply.getStatus().getDescription())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public record SimpleApplyRes(
String applicantName,
Long portfolioId,
String portfolioName,
String dataType,
String status,
String applyPart,
Boolean isViewed
Expand All @@ -34,6 +35,7 @@ public static SimpleApplyRes of(Apply apply){
.applicantName(apply.getMember().getName())
.portfolioId(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getId() : null)
.portfolioName(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getPortfolioName() : null)
.dataType(apply.getPortfolioInfo().getDataType())
.status(apply.getStatus().name())
.applyPart(apply.getPart())
.isViewed(apply.isViewed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ public class PortfolioInfo {

private boolean isPrivate;

public static PortfolioInfo ofPortfolio(Portfolio portfolio, boolean isPrivate) {
private String dataType;

public static PortfolioInfo ofPortfolio(Portfolio portfolio, boolean isPrivate, String dataType) {
return PortfolioInfo.builder()
.portfolio(portfolio)
.isPrivate(isPrivate)
.dataType(dataType)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gongjakso.server.domain.portfolio.vo.PortfolioData;
import lombok.Builder;
import java.util.List;
import java.util.Objects;

@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -17,11 +18,23 @@ public record PortfolioRes (
List<PortfolioData.Award> awardList,
List<PortfolioData.Certificate> certificateList,
List<PortfolioData.Sns> snsList,
String dataType,
String fileUri,
String notionUri
) {
public static PortfolioRes from(Portfolio portfolio) {
PortfolioData portfolioData = portfolio.getPortfolioData();
String dataType;
if (portfolio.getFileUri() != null && portfolio.getNotionUri() != null) {
dataType = "HYBRID";
} else if (portfolio.getFileUri() != null) {
dataType = "FILE";
} else if (portfolio.getNotionUri() != null) {
dataType = "NOTION";
} else {
dataType = null;
}

return new PortfolioRes(
portfolio.getId(),
portfolio.getPortfolioName(),
Expand All @@ -31,8 +44,9 @@ public static PortfolioRes from(Portfolio portfolio) {
portfolioData != null ? portfolioData.awardList() : null,
portfolioData != null ? portfolioData.certificateList(): null,
portfolioData != null ? portfolioData.snsList(): null,
portfolio.getFileUri(),
portfolio.getNotionUri()
dataType,
Objects.equals(dataType, "NOTION") ? null : portfolio.getFileUri(),
Objects.equals(dataType, "FILE") ? null : portfolio.getNotionUri()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ public record SimplePortfolioRes(
String PortfolioName,
LocalDateTime modifiedAt,
Boolean isRegistered,
Boolean isExistedPortfolio
Boolean isExistedPortfolio,
String dataType
) {
public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered, Boolean isExistedPortfolio) {

String dataType;
if (portfolio.getFileUri() != null && portfolio.getNotionUri() != null) {
dataType = "HYBRID";
} else if (portfolio.getFileUri() != null) {
dataType = "FILE";
} else if (portfolio.getNotionUri() != null) {
dataType = "NOTION";
} else {
dataType = null;
}

return new SimplePortfolioRes(
isRegistered ? portfolio.getId() : null,
isRegistered ? portfolio.getPortfolioName() : null,
isRegistered ? portfolio.getModifiedAt() : null,
isRegistered,
isExistedPortfolio
isExistedPortfolio,
isExistedPortfolio ? dataType : null
);
}
}
Loading