From 136f3c670a8ebf8b88ecabec588dab3460d9af1a Mon Sep 17 00:00:00 2001 From: jinnxyoung Date: Fri, 20 Sep 2024 23:54:04 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[#205]=20fix:=20Data=20Type=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/portfolio/dto/request/PortfolioReq.java | 2 +- .../server/domain/portfolio/dto/response/PortfolioRes.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/request/PortfolioReq.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/request/PortfolioReq.java index 3043f9b..c7bb5aa 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/request/PortfolioReq.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/request/PortfolioReq.java @@ -21,7 +21,7 @@ public record PortfolioReq ( public record Education ( String school, String grade, - Boolean isActive + String state ) { } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/PortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/PortfolioRes.java index a28ea0f..caf6cb5 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/PortfolioRes.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/PortfolioRes.java @@ -22,7 +22,7 @@ public static PortfolioRes from(Portfolio portfolio) { PortfolioData portfolioData = portfolio.getPortfolioData(); return new PortfolioRes( portfolio.getId(), - portfolioData.portfolioName(), + portfolio.getPortfolioName(), portfolioData.educationList(), portfolioData.workList(), portfolioData.activityList(), From 44d706a21e93417c3c48603c74c01c0e7346711e Mon Sep 17 00:00:00 2001 From: jinnxyoung Date: Fri, 20 Sep 2024 23:54:30 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[#205]=20fix:=20Data=20Type=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongjakso/server/domain/portfolio/vo/PortfolioData.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/vo/PortfolioData.java b/src/main/java/com/gongjakso/server/domain/portfolio/vo/PortfolioData.java index a67c842..a0bf85b 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/vo/PortfolioData.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/vo/PortfolioData.java @@ -4,7 +4,6 @@ import java.util.List; public record PortfolioData ( - String portfolioName, List educationList, List workList, List activityList, @@ -15,7 +14,7 @@ public record PortfolioData ( public record Education ( String school, String grade, - Boolean isActive + String state ) { } From ccbe05c02c6e4ae7e37f6685029fffe0d38ca88f Mon Sep 17 00:00:00 2001 From: jinnxyoung Date: Sat, 21 Sep 2024 00:16:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[#206]=20fix:=20PortfolioData=20=EB=82=B4?= =?UTF-8?q?=EB=B6=80=20portfolioName=20=ED=95=84=EB=93=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/portfolio/entity/Portfolio.java | 12 ++++++-- .../portfolio/service/PortfolioService.java | 29 ++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) 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 9de2a75..ef7c3a0 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,6 +25,9 @@ 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 portfolioName; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id") private Member member; @@ -34,12 +37,17 @@ public class Portfolio extends BaseTimeEntity { private PortfolioData portfolioData; @Builder - public Portfolio(Member member, PortfolioData portfolioData) { + public Portfolio(Member member, String portfolioName, PortfolioData portfolioData) { this.member = member; + this.portfolioName = portfolioName; this.portfolioData = portfolioData; } - public void update(PortfolioData updatedData) { + public void updateName(String updatedName) { + this.portfolioName = updatedName; + } + + public void updateData(PortfolioData updatedData) { this.portfolioData = updatedData; } } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index b170474..f94554f 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -21,20 +21,23 @@ public class PortfolioService { private final PortfolioRepository portfolioRepository; - // PortfolioReq -> PortfolioData 변환 - private PortfolioData convertToPortfolioData(PortfolioReq portfolioReq) { - String portfolioName = portfolioReq.portfolioName(); + // PortfolioName 생성 로직을 분리 + private String generatePortfolioName(String portfolioName) { if (portfolioName == null || portfolioName.isEmpty()) { long existingPortfolioCount = portfolioRepository.countByDeletedAtIsNull(); - portfolioName = "포트폴리오 " + (existingPortfolioCount + 1); + return "포트폴리오 " + (existingPortfolioCount + 1); } + return portfolioName; + } + // PortfolioReq -> PortfolioData 변환 + private PortfolioData convertToPortfolioData(PortfolioReq portfolioReq) { List educationList = portfolioReq.educationList() != null ? portfolioReq.educationList().stream() .map(education -> new PortfolioData.Education( education.school(), education.grade(), - education.isActive() + education.state() )) .toList() : List.of(); @@ -89,7 +92,7 @@ private PortfolioData convertToPortfolioData(PortfolioReq portfolioReq) { .toList() : List.of(); - return new PortfolioData(portfolioName, educationList, workList, activityList, awardList, certificateList, snsList); + return new PortfolioData(educationList, workList, activityList, awardList, certificateList, snsList); } @Transactional @@ -97,11 +100,16 @@ public PortfolioRes registerPortfolio(Member member, PortfolioReq portfolioReq) if (member == null) { throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); } + + String portfolioName = generatePortfolioName(portfolioReq.portfolioName()); PortfolioData portfolioData = convertToPortfolioData(portfolioReq); + Portfolio portfolio = Portfolio.builder() .member(member) + .portfolioName(portfolioName) .portfolioData(portfolioData) .build(); + Portfolio savedPortfolio = portfolioRepository.save(portfolio); return PortfolioRes.from(savedPortfolio); @@ -124,8 +132,15 @@ public PortfolioRes updatePortfolio(Member member, Long portfolioId, PortfolioRe if (!portfolio.getMember().getId().equals(member.getId())) { throw new ApplicationException(ErrorCode.FORBIDDEN_EXCEPTION); } + + if (portfolioReq.portfolioName() != null) { + String portfolioName = generatePortfolioName(portfolioReq.portfolioName()); + portfolio.updateName(portfolioName); + } + PortfolioData updatedPortfolioData = convertToPortfolioData(portfolioReq); - portfolio.update(updatedPortfolioData); + portfolio.updateData(updatedPortfolioData); + Portfolio updatedPortfolio = portfolioRepository.save(portfolio); return PortfolioRes.from(updatedPortfolio); From 49db1fff157ac631b8abb5ef40e7ba92f80ca623 Mon Sep 17 00:00:00 2001 From: jinnxyoung Date: Sat, 21 Sep 2024 00:28:52 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[#206]=20fix:=20portfolioName=20=EC=B9=BC?= =?UTF-8?q?=EB=9F=BC=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gongjakso/server/domain/portfolio/entity/Portfolio.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ef7c3a0..ff563f6 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,7 +25,7 @@ public class Portfolio extends BaseTimeEntity { @Column(name = "portfolio_id", nullable = false, columnDefinition = "bigint") private Long id; - @Column(name = "title", nullable = false, columnDefinition = "varchar(50)") + @Column(name = "portfolio_name", nullable = false, columnDefinition = "varchar(50)") private String portfolioName; @ManyToOne(fetch = FetchType.LAZY) From e5a9118b0c51774a0d6cae99109d7cf628138f6b Mon Sep 17 00:00:00 2001 From: jinnxyoung Date: Sat, 21 Sep 2024 00:29:31 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[#206]=20fix:=20Apply=EC=99=80=20=EC=97=B0?= =?UTF-8?q?=EA=B4=80=EB=90=9C=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongjakso/server/domain/apply/dto/response/ApplyRes.java | 2 +- .../domain/portfolio/dto/response/SimplePortfolioRes.java | 2 +- 2 files changed, 2 insertions(+), 2 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 b80789f..fadcb50 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 @@ -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) - .portfolioName(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getPortfolioData().portfolioName() : null) + .portfolioName(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getPortfolioName() : 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 ee50e30..ee60919 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 @@ -12,7 +12,7 @@ public record SimplePortfolioRes( public static SimplePortfolioRes of(Portfolio portfolio) { return new SimplePortfolioRes( portfolio.getId(), - portfolio.getPortfolioData().portfolioName(), + portfolio.getPortfolioName(), portfolio.getModifiedAt() ); }