Skip to content

Commit

Permalink
Merge pull request #153 from KUSITMS-29th-TEAM-B/refactor/flight-150
Browse files Browse the repository at this point in the history
refactor: 태그, 역량 키워드, 경험 매퍼 클래스 객체 생성 방식 리팩토링
  • Loading branch information
whereami2048 authored May 23, 2024
2 parents 903579e + d691fd3 commit 6d4df45
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class TagController(

@DeleteMapping(TagApi.TAG_PATH_VARIABLE_URL)
fun deleteTag( @PathVariable("tagId") tagId: UUID) {

tagDeleteService.deleteTag(tagId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,5 @@ data class Experience(
updatedAt = LocalDateTime.now(),
)
}

fun toDomain(
id: UUID,
userId: UUID,
title: String,
parentTagId: UUID,
childTagId: UUID,
contents: List<ExperienceContent>,
experienceStrongPoints: List<ExperienceStrongPoint>,
startedAt: LocalDateTime,
endedAt: LocalDateTime,
createdAt: LocalDateTime,
updatedAt: LocalDateTime,
): Experience {
return Experience(
id = id,
userId = userId,
title = title,
parentTagId = parentTagId,
childTagId = childTagId,
contents = contents,
strongPoints = experienceStrongPoints,
startedAt = startedAt,
endedAt = endedAt,
createdAt = createdAt,
updatedAt = updatedAt,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ data class ExperienceStrongPoint(
fun create(strongPointId: UUID): ExperienceStrongPoint {
return ExperienceStrongPoint(strongPointId = strongPointId)
}

fun toDomain(id: UUID, strongPointId: UUID): ExperienceStrongPoint {
return ExperienceStrongPoint(id, strongPointId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,5 @@ data class StrongPoint(
fun create(name: String, userId: UUID): StrongPoint {
return StrongPoint(name = name, userId = userId)
}

fun toDomain(id: UUID, name: String, userId: UUID): StrongPoint {
return StrongPoint(id, name, userId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@ data class Tag(
userId = userId
)
}

fun toDomain(id : UUID, name: String, parentTagId: UUID?, userId: UUID): Tag {
return Tag(id, name, parentTagId, userId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public Experience toExperienceDomainEntity(ExperienceJpaEntity experienceJpaEnti

List<ExperienceStrongPoint> experienceStrongPoints = experienceJpaEntity.getStrongPointInfos().stream()
.map(this::toExperienceStrongPointDomainEntity).toList();
return Experience.Companion.toDomain(
return new Experience(
experienceJpaEntity.getExperienceId(),
experienceJpaEntity.getUserId(),
experienceJpaEntity.getTitle(),
experienceJpaEntity.getUserId(),
experienceJpaEntity.getParentTagId(),
experienceJpaEntity.getChildTagId(),
contents,
experienceStrongPoints,
contents,
experienceJpaEntity.getStartedAt(),
experienceJpaEntity.getEndedAt(),
experienceJpaEntity.getCreatedAt(),
Expand All @@ -63,7 +63,7 @@ public ExperienceContentJpaEntity toExperienceContentJpaEntity(ExperienceContent
}

public ExperienceContent toExperienceContentDomainEntity(ExperienceContentJpaEntity experienceContentJpaEntity) {
return ExperienceContent.Companion.toDomain(
return new ExperienceContent(
experienceContentJpaEntity.getExperienceContentId(),
experienceContentJpaEntity.getQuestion(),
experienceContentJpaEntity.getAnswer()
Expand All @@ -75,7 +75,7 @@ public ExperienceStrongPointJpaEntity toExperienceStrongPointJpaEntity(Experienc
}

public ExperienceStrongPoint toExperienceStrongPointDomainEntity(ExperienceStrongPointJpaEntity experienceStrongPointJpaEntity) {
return ExperienceStrongPoint.Companion.toDomain(
return new ExperienceStrongPoint(
experienceStrongPointJpaEntity.getExperienceStrongPointId(),
experienceStrongPointJpaEntity.getStrongPointId()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import jakarta.persistence.Table;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Table(name = "strong_point")
public class StrongPointJpaEntity {
@Id
Expand All @@ -29,7 +27,9 @@ public class StrongPointJpaEntity {
@Convert(converter = UUIDBinaryConverter.class)
private UUID userId;

public static StrongPointJpaEntity of(UUID id, String name, UUID userId) {
return new StrongPointJpaEntity(id, name, userId);
public StrongPointJpaEntity (UUID id, String name, UUID userId) {
this.strongPointId = id;
this.name = name;
this.userId = userId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
@Component
public class StrongPointMapper {
public StrongPointJpaEntity toJpaEntity(StrongPoint strongPoint) {
return StrongPointJpaEntity.of(
return new StrongPointJpaEntity(
strongPoint.getId(),
strongPoint.getName(),
strongPoint.getUserId()
);
}

public StrongPoint toDomainEntity(StrongPointJpaEntity strongPointJpaEntity) {
return StrongPoint.Companion.toDomain(
return new StrongPoint(
strongPointJpaEntity.getStrongPointId(),
strongPointJpaEntity.getName(),
strongPointJpaEntity.getUserId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public TagJpaEntity toJpaEntity(Tag tag) {
}

public Tag toDomainEntity(TagJpaEntity tagJpaEntity) {
return Tag.Companion.toDomain(tagJpaEntity.getTagId(),
return new Tag(tagJpaEntity.getTagId(),
tagJpaEntity.getName(),
tagJpaEntity.getParentTagId(),
tagJpaEntity.getUserId()
Expand Down

0 comments on commit 6d4df45

Please sign in to comment.