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: 포트폴리오 미선택 가능하도록 수정 #204

Merged
merged 3 commits into from
Sep 20, 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 @@ -40,9 +40,7 @@ public record ApplyReq(
String part
) {
public static Apply toEntity(ApplyReq req, Team team, Member member, @Nullable Portfolio portfolio) {
PortfolioInfo portfolioInfo = portfolio != null
? PortfolioInfo.ofPortfolio(portfolio)
: PortfolioInfo.ofPrivate();
PortfolioInfo portfolioInfo = PortfolioInfo.ofPortfolio(portfolio, req.isPrivate());

return Apply.builder()
.team(team)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public record ApplyRes(
Long portfolioId,

@Nullable
String portfolioTitle,
String portfolioName,

Boolean isPrivate,

@Size(max = 500)
String body,
Expand Down Expand Up @@ -66,7 +68,8 @@ public static ApplyRes of(Apply apply) {
.memberId(apply.getMember().getId())
.leaderName(apply.getTeam().getMember().getName())
.portfolioId(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getId() : null)
.portfolioTitle(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getTitle() : null)
.portfolioName(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getPortfolioData().portfolioName() : null)
.isPrivate(apply.getPortfolioInfo().isPrivate())
.body(apply.getBody())
.status(apply.getStatus().getDescription())
.part(apply.getPart())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@ public class PortfolioInfo {

private boolean isPrivate;

public static PortfolioInfo ofPortfolio(Portfolio portfolio) {
public static PortfolioInfo ofPortfolio(Portfolio portfolio, boolean isPrivate) {
return PortfolioInfo.builder()
.portfolio(portfolio)
.isPrivate(false)
.build();
}

public static PortfolioInfo ofPrivate() {
return PortfolioInfo.builder()
.portfolio(null)
.isPrivate(true)
.isPrivate(isPrivate)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public ApplyRes apply(Member member, Long teamId, ApplyReq applyReq) {
//Business Logic
Portfolio portfolio = null;

if (!applyReq.isPrivate()) {
if (applyReq.portfolioId() == null) {
throw new ApplicationException(ErrorCode.PORTFOLIO_NOT_FOUND_EXCEPTION);
}
if (applyReq.portfolioId() != null) {
portfolio = portfolioRepository.findById(applyReq.portfolioId())
.orElseThrow(() -> new ApplicationException(ErrorCode.PORTFOLIO_NOT_FOUND_EXCEPTION));
if(!portfolio.getMember().getId().equals(member.getId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

public record SimplePortfolioRes(
Long PortfolioId,
String PortfolioTitle,
String PortfolioName,
LocalDateTime modifiedAt
) {
public static SimplePortfolioRes of(Portfolio portfolio) {
return new SimplePortfolioRes(
portfolio.getId(),
portfolio.getTitle(),
portfolio.getPortfolioData().portfolioName(),
portfolio.getModifiedAt()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public class Portfolio extends BaseTimeEntity {
@Column(name = "portfolio_id", nullable = false, columnDefinition = "bigint")
private Long id;

@Column(name = "title", nullable = false, columnDefinition = "varchar(50)")
private String title;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;
Expand Down
Loading