-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#79] 모델 지원서 작성 API
- Loading branch information
Showing
16 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.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,22 @@ | ||
package com.moddy.server.controller.model.dto.request; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
import java.util.List; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record ModelApplicationRequest( | ||
String hairLength, | ||
List<String> preferHairStyles, | ||
String hairDetail, | ||
List<ModelHairServiceRequest> hairServiceRecords, | ||
MultipartFile modelImgUrl, | ||
String instagramId, | ||
MultipartFile applicationCaptureImgUrl | ||
) { | ||
|
||
@Schema(description = "Hair service records in JSON array format", example = "[{\"hairService\": \"PERM\", \"hairServiceTerm\": \"UNDER_ONE\"}, {\"hairService\": \"BLACK\", \"hairServiceTerm\": \"ABOVE_TWELVE\"}]") | ||
public List<ModelHairServiceRequest> getHairServiceRecords() { | ||
return hairServiceRecords; | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
src/main/java/com/moddy/server/controller/model/dto/request/ModelHairServiceRequest.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,7 @@ | ||
package com.moddy.server.controller.model.dto.request; | ||
|
||
public record ModelHairServiceRequest( | ||
String hairService, | ||
String hairServiceTerm | ||
) { | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/moddy/server/controller/model/dto/requestEditor/ListPropertyEditor.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,46 @@ | ||
package com.moddy.server.controller.model.dto.requestEditor; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.util.StringUtils; | ||
import java.beans.PropertyEditorSupport; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
|
||
public class ListPropertyEditor extends PropertyEditorSupport { | ||
|
||
private final Class<?> elementType; | ||
private final ObjectMapper objectMapper; | ||
|
||
public ListPropertyEditor(Class<?> elementType) { | ||
this.elementType = elementType; | ||
this.objectMapper = new ObjectMapper(); | ||
} | ||
|
||
@Override | ||
public void setAsText(String text) throws IllegalArgumentException { | ||
if (StringUtils.hasText(text)) { | ||
try { | ||
List<?> list = objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, elementType)); | ||
setValue(list); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Failed to convert value to List: " + text, e); | ||
} | ||
} else { | ||
setValue(null); | ||
} | ||
} | ||
|
||
@Override | ||
public String getAsText() { | ||
Object value = getValue(); | ||
if (value == null) { | ||
return ""; | ||
} | ||
try { | ||
return objectMapper.writeValueAsString(value); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Failed to convert value to JSON: " + value, e); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/moddy/server/domain/hair_model_application/HairLength.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 |
---|---|---|
@@ -1,12 +1,26 @@ | ||
package com.moddy.server.domain.hair_model_application; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import com.moddy.server.domain.user.Gender; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum HairLength { | ||
SHORT("숏"), ABOVE_SHOULDER("단발"), UNDER_SHOULDER("어깨 아래"), UNDER_WAIST("허리 아래"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static HairLength findByHairLength(String hairLength) { | ||
return Stream.of(HairLength.values()) | ||
.filter(c -> c.name().equals(hairLength)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_LENGTH_EXCEPTION)); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecord.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 |
---|---|---|
@@ -1,12 +1,26 @@ | ||
package com.moddy.server.domain.hair_service_record; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import com.moddy.server.domain.hair_model_application.HairLength; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ServiceRecord { | ||
PERM("펌"), DECOLOR("탈색"), BLACK("블랙 염색"), COLOR("컬러 염색"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static ServiceRecord findByServiceRecord(String serviceRecord) { | ||
return Stream.of(ServiceRecord.values()) | ||
.filter(c -> c.name().equals(serviceRecord)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_SERVICE_RECORD_EXCEPTION)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecordTerm.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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
package com.moddy.server.domain.hair_service_record; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ServiceRecordTerm { | ||
UNDER_ONE("1 개월 미만"), ONE_THREE("1 - 3 개월"), FOUR_SIX("4 - 6 개월"), SEVEN_TWELVE("7 - 12 개월"), ABOVE_TWELVE("12 개월 초과"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static ServiceRecordTerm findByServiceRecord(String serviceRecordTerm) { | ||
return Stream.of(ServiceRecordTerm.values()) | ||
.filter(c -> c.name().equals(serviceRecordTerm)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_SERVICE_RECORD_TERM_EXCEPTION)); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...om/moddy/server/domain/hair_service_record/repository/HairServiceRecordJpaRepository.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,7 @@ | ||
package com.moddy.server.domain.hair_service_record.repository; | ||
|
||
import com.moddy.server.domain.hair_service_record.HairServiceRecord; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface HairServiceRecordJpaRepository extends JpaRepository<HairServiceRecord, Long> { | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/moddy/server/domain/prefer_hair_style/HairStyle.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 |
---|---|---|
@@ -1,12 +1,28 @@ | ||
package com.moddy.server.domain.prefer_hair_style; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import com.moddy.server.domain.hair_model_application.HairLength; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum HairStyle { | ||
NORMAL_CUT("일반 커트"), ALL_COLOR("전체 염색"), ALL_DECOLOR("전체 탈색"), SETTING_PERM("셋팅펌"), NORMAL_PERM("일반펌"), STRAIGHTENING("매직"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static HairStyle findByHairStyle(String hairStyle) { | ||
return Stream.of(HairStyle.values()) | ||
.filter(c -> c.name().equals(hairStyle)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_STYLE_EXCEPTION)); | ||
} | ||
|
||
} | ||
|
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
Oops, something went wrong.