Part 1. Spring Framework
Ch 03. 예제를 만들며 이해하는 스프링 웹 어플리케이션 핵심 기술
11. Developer Get(조회)기능 개발
- CRUD의 다른 기능 : get, delete 등을 수행
package com.fastcampus.programmin.dmaker.dto;
import com.fastcampus.programmin.dmaker.entity.Developer;
import com.fastcampus.programmin.dmaker.type.DeveloperLevel;
import com.fastcampus.programmin.dmaker.type.DeveloperSkillType;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.time.LocalDateTime;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DeveloperDetailDto {
private DeveloperLevel developerLevel;
private DeveloperSkillType developerSkillType;
private Integer experienceYears;
private String memberId;
private String name;
private Integer age;
public static DeveloperDetailDto fromEntity(Developer developer){
return DeveloperDetailDto.builder()
.developerLevel(developer.getDeveloperLevel())
.developerSkillType(developer.getDeveloperSkillType())
.experienceYears(developer.getExperienceYears())
.memberId(developer.getMemberId())
.name(developer.getName())
.age(developer.getAge())
.build();
}
}
<DeveloperDetailDto.java>
package com.fastcampus.programmin.dmaker.dto;
import com.fastcampus.programmin.dmaker.entity.Developer;
import com.fastcampus.programmin.dmaker.type.DeveloperLevel;
import com.fastcampus.programmin.dmaker.type.DeveloperSkillType;
import lombok.*;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DeveloperDto {
private DeveloperLevel developerLevel;
private DeveloperSkillType developerSkillType;
private String memberId;
public static DeveloperDto fromEntity(Developer developer){
return DeveloperDto.builder()
.developerLevel(developer.getDeveloperLevel())
.developerSkillType(developer.getDeveloperSkillType())
.memberId(developer.getMemberId())
.build();
}
}
<DeveloperDto.java>
GET http://localhost:8080/developer/Mickey
Accept: application/json
<dev.detail.http>
GET http://localhost:8080/developers
Accept: application/json
<dev.list>
---------------------------------------------------------------------------------------------------------------------------------
https://bit.ly/37BpXic
'[패스트캠퍼스] Spring' 카테고리의 다른 글
패스트캠퍼스 챌린지 28일차 (0) | 2022.02.20 |
---|---|
패스트캠퍼스 챌린지 27일차 (0) | 2022.02.19 |
패스트캠퍼스 챌린지 25일차 (0) | 2022.02.17 |
패스트캠퍼스 챌린지 24일차 (0) | 2022.02.16 |
패스트캠퍼스 챌린지 23일차 (0) | 2022.02.15 |
댓글