-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
42 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/example/letscareer/career/domain/dto/converter/CareerConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.letscareer.career.domain.dto.converter; | ||
|
||
import com.example.letscareer.career.domain.dto.CareerDTO; | ||
import com.example.letscareer.career.domain.model.Career; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class CareerConverter { | ||
|
||
// Career 리스트 -> CareerDTO 리스트 변환 로직 | ||
public static List<CareerDTO> convertToCareerDTOList(List<Career> careers) { | ||
return careers.stream() | ||
.map(CareerConverter::convertToCareerDTO) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
// Career 페이지 -> CareerDTO 리스트 변환 로직 | ||
public static List<CareerDTO> convertToCareerDTOList(Page<Career> careers) { | ||
return careers.getContent().stream() | ||
.map(CareerConverter::convertToCareerDTO) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
// Career -> CareerDTO 변환 로직 메서드 | ||
private static CareerDTO convertToCareerDTO(Career career) { | ||
return new CareerDTO( | ||
career.getCareerId(), | ||
career.getCategory().getValue(), | ||
career.getTitle(), | ||
toSummary(career.getSituation()) | ||
); | ||
} | ||
|
||
private static String toSummary(String content) { | ||
return content.length() > 25 ? content.substring(0, 25) + "..." : content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters