Skip to content

Commit

Permalink
Merge pull request #201 from Gongjakso/feat/portfolio
Browse files Browse the repository at this point in the history
feat: 포트폴리오 이름 입력 기능 추가
  • Loading branch information
jinnxyoung authored Sep 15, 2024
2 parents 192ba85 + c0fa3ea commit 1ad330b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.gongjakso.server.domain.portfolio.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import java.util.List;
import lombok.Builder;

@Builder
public record PortfolioReq (
@Nullable
String portfolioName,
List<Education> educationList,
List<Work> workList,
List<Activty> activityList,
Expand Down Expand Up @@ -35,18 +40,21 @@ public record Activty (
Boolean isActive
) {
}

public record Award (
String contestName,
String awardName,
LocalDate awardDate
) {
}

public record Certificate (
String name,
String rating,
LocalDate certificationDate
) {
}

public record Sns (
String snsLink
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public record PortfolioRes (
Long id,
String portfolioName,
List<PortfolioData.Education> educationList,
List<PortfolioData.Work> workList,
List<PortfolioData.Activity> activityList,
Expand All @@ -21,6 +22,7 @@ public static PortfolioRes from(Portfolio portfolio) {
PortfolioData portfolioData = portfolio.getPortfolioData();
return new PortfolioRes(
portfolio.getId(),
portfolioData.portfolioName(),
portfolioData.educationList(),
portfolioData.workList(),
portfolioData.activityList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

public interface PortfolioRepository extends JpaRepository<Portfolio, Long> {
Optional<Portfolio> findByIdAndDeletedAtIsNull(Long portfolioId);

long countByDeletedAtIsNull();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class PortfolioService {

// PortfolioReq -> PortfolioData 변환
private PortfolioData convertToPortfolioData(PortfolioReq portfolioReq) {
String portfolioName = portfolioReq.portfolioName();
if (portfolioName == null || portfolioName.isEmpty()) {
long existingPortfolioCount = portfolioRepository.countByDeletedAtIsNull();
portfolioName = "포트폴리오 " + (existingPortfolioCount + 1);
}

List<PortfolioData.Education> educationList = portfolioReq.educationList() != null
? portfolioReq.educationList().stream()
.map(education -> new PortfolioData.Education(
Expand Down Expand Up @@ -82,7 +88,7 @@ private PortfolioData convertToPortfolioData(PortfolioReq portfolioReq) {
.toList()
: List.of();

return new PortfolioData(educationList, workList, activityList, awardList, certificateList, snsList);
return new PortfolioData(portfolioName, educationList, workList, activityList, awardList, certificateList, snsList);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

public record PortfolioData (
String portfolioName,
List<Education> educationList,
List<Work> workList,
List<Activity> activityList,
Expand All @@ -17,6 +18,7 @@ public record Education (
Boolean isActive
) {
}

public record Work (
String company,
String partition,
Expand All @@ -26,23 +28,27 @@ public record Work (
String detail
) {
}

public record Activity (
String name,
Boolean isActive
) {
}

public record Award (
String contestName,
String awardName,
LocalDate awardDate
) {
}

public record Certificate (
String name,
String rating,
LocalDate certificationDate
) {
}

public record Sns (
String snsLink
) {
Expand Down

0 comments on commit 1ad330b

Please sign in to comment.