From 4cfaea3feb0e955d273e7f4d4e6e95c91b01f119 Mon Sep 17 00:00:00 2001 From: yumzen Date: Fri, 20 Sep 2024 14:23:38 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=ED=8F=AC=ED=8A=B8=ED=8F=B4=EB=A6=AC?= =?UTF-8?q?=EC=98=A4=20=EB=AF=B8=EC=84=A0=ED=83=9D=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/apply/dto/request/ApplyReq.java | 4 +--- .../server/domain/apply/dto/response/ApplyRes.java | 3 +++ .../server/domain/apply/entity/PortfolioInfo.java | 11 ++--------- .../server/domain/apply/service/ApplyService.java | 5 +---- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/request/ApplyReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/request/ApplyReq.java index 0cdce27..130f225 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/request/ApplyReq.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/request/ApplyReq.java @@ -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) diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java index ad84b31..0a87a3f 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java @@ -30,6 +30,8 @@ public record ApplyRes( @Nullable String portfolioTitle, + Boolean isPrivate, + @Size(max = 500) String body, @@ -67,6 +69,7 @@ public static ApplyRes of(Apply apply) { .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) + .isPrivate(apply.getPortfolioInfo().isPrivate()) .body(apply.getBody()) .status(apply.getStatus().getDescription()) .part(apply.getPart()) diff --git a/src/main/java/com/gongjakso/server/domain/apply/entity/PortfolioInfo.java b/src/main/java/com/gongjakso/server/domain/apply/entity/PortfolioInfo.java index c6cb7a0..c396f75 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/entity/PortfolioInfo.java +++ b/src/main/java/com/gongjakso/server/domain/apply/entity/PortfolioInfo.java @@ -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(); } } diff --git a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java index 41ae3ef..b5a8796 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java +++ b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java @@ -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())) { From 3081021fc2b9aaa710eca22965d0190d6aa8f503 Mon Sep 17 00:00:00 2001 From: yumzen Date: Fri, 20 Sep 2024 23:29:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=ED=8F=AC=ED=8A=B8=ED=8F=B4=EB=A6=AC?= =?UTF-8?q?=EC=98=A4=20=EC=9D=B4=EB=A6=84=20=ED=95=84=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongjakso/server/domain/apply/dto/response/ApplyRes.java | 4 ++-- .../domain/portfolio/dto/response/SimplePortfolioRes.java | 4 ++-- .../gongjakso/server/domain/portfolio/entity/Portfolio.java | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java index 0a87a3f..b80789f 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java @@ -28,7 +28,7 @@ public record ApplyRes( Long portfolioId, @Nullable - String portfolioTitle, + String portfolioName, Boolean isPrivate, @@ -68,7 +68,7 @@ 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()) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java index d6daf3b..ee50e30 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java @@ -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() ); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java index 0e3e233..9de2a75 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java @@ -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;