Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public record AnalysisResponse(
@Schema(description = "분석 결과 식별자")
@JsonProperty("analysis_id") UUID analysisId,

@JsonProperty("record_id") UUID recordId,

@JsonProperty("photo_id") UUID photoId,

@Schema(description = "결과를 낸 분석 작업 식별자")
@JsonProperty("job_id") UUID jobId,

Expand All @@ -35,7 +39,7 @@ public record AnalysisResponse(
@JsonProperty("model_version") String modelVersion,

@Schema(description = "결과 요약 문장. 없을 수 있다")
String summary,
@JsonProperty("summary_comment") String summary,

@Schema(description = "분석이 끝난 시각")
@JsonProperty("analyzed_at") Instant analyzedAt,
Expand Down Expand Up @@ -77,7 +81,8 @@ public record Overlay(
public static AnalysisResponse from(GetLatestAnalysisUseCase.Result result) {
var analysis = result.analysis();
return new AnalysisResponse(
analysis.analysisId(), analysis.jobId(), result.status().name(),
analysis.analysisId(), analysis.recordId(), analysis.photoId(), analysis.jobId(),
result.status().name(),
metrics(result), confidence(result), analysis.modelVersion(), analysis.summary(),
analysis.analyzedAt(), overlays(result.overlays()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.time.Instant;
import java.util.List;
Expand All @@ -27,6 +28,9 @@ public record CreateTreatmentRecordRequest(
@Schema(description = "시술일시(ISO-8601). 미래일 수 없다")
@JsonProperty("performed_at") Instant performedAt,

@Schema(description = "입력 기준 IANA 시간대", example = "Asia/Seoul")
@JsonProperty("timezone") String timezone,

@Schema(description = "미용실 이름. 선택 입력, 최대 50자")
@JsonProperty("salon_name") String salonName,

Expand All @@ -43,6 +47,25 @@ public record CreateTreatmentRecordRequest(
+ "적는다", example = "애쉬브라운 전체 염색")
@JsonProperty("treatment_content") String treatmentContent,

@Size(max = 20)
@Schema(description = "커트 길이")
@JsonProperty("cut_length") String cutLength,

@Size(max = 20)
@Schema(description = "커트 형태", example = "LAYERED")
@JsonProperty("cut_shape") String cutShape,

@Size(max = 20)
@Schema(description = "펌 종류")
@JsonProperty("perm_type") String permType,

@Size(max = 30)
@Schema(description = "염색 색상명", example = "애쉬 브라운")
@JsonProperty("color_name") String colorName,

@Schema(description = "사용 제품 또는 약제 목록")
@JsonProperty("products") List<@NotNull String> products,

@Schema(description = "가격 금액. 선택 입력", example = "35000")
@JsonProperty("price_amount") Long priceAmount,

Expand Down Expand Up @@ -85,7 +108,8 @@ public PhotoRequest(UUID fileId, ImageType imageType) {
public CreateTreatmentRecordUseCase.Command toCommand(UUID userId) {
return new CreateTreatmentRecordUseCase.Command(userId, serviceTypes, salonName, designerName,
performedAt, satisfaction, priceAmount, priceCurrency, appointmentId,
memo, nextVisitCautions, durationMinutes, treatmentContent,
memo, nextVisitCautions, durationMinutes, treatmentContent, timezone,
cutLength, cutShape, permType, colorName, products,
photos == null ? List.of() : java.util.stream.IntStream.range(0, photos.size())
.mapToObj(index -> {
PhotoRequest photo = photos.get(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ public record TreatmentRecordResponse(
@Schema(description = "시술일시")
@JsonProperty("performed_at") Instant performedAt,

@Schema(description = "입력 기준 IANA 시간대")
String timezone,

@JsonProperty("cut_length") String cutLength,

@JsonProperty("cut_shape") String cutShape,

@JsonProperty("perm_type") String permType,

@JsonProperty("color_name") String colorName,

List<String> products,

@Schema(description = "만족도(1~5). 입력하지 않았으면 비어 있다")
@JsonProperty("satisfaction") Integer satisfaction,

Expand Down Expand Up @@ -139,7 +152,8 @@ public static TreatmentRecordResponse withPhotos(TreatmentRecord record, Map<UUI
private static TreatmentRecordResponse of(TreatmentRecord record, List<? extends Photo> photos) {
return new TreatmentRecordResponse(
record.recordId(), record.serviceTypes(), record.salonName(), record.designerName(),
record.performedAt(), record.satisfaction(),
record.performedAt(), record.timezone(), record.cutLength(), record.cutShape(),
record.permType(), record.colorName(), record.products(), record.satisfaction(),
record.priceAmount() == null ? null
: new Price(record.priceAmount(), record.priceCurrency()),
record.appointmentId(), record.memo(), record.nextVisitCautions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
Expand Down Expand Up @@ -53,6 +54,22 @@ public class UpdateTreatmentRecordRequest {
private boolean durationMinutesPresent;
private String treatmentContent;
private boolean treatmentContentPresent;
private String timezone;
private boolean timezonePresent;
@Size(max = 20)
private String cutLength;
private boolean cutLengthPresent;
@Size(max = 20)
private String cutShape;
private boolean cutShapePresent;
@Size(max = 20)
private String permType;
private boolean permTypePresent;
@Size(max = 30)
private String colorName;
private boolean colorNamePresent;
private List<@NotNull String> products;
private boolean productsPresent;

private final List<String> unknownFields = new ArrayList<>();

Expand Down Expand Up @@ -149,6 +166,42 @@ public void setTreatmentContent(String treatmentContent) {
treatmentContentPresent = true;
}

@JsonSetter("timezone")
public void setTimezone(String timezone) {
this.timezone = timezone;
timezonePresent = true;
}

@JsonSetter("cut_length")
public void setCutLength(String cutLength) {
this.cutLength = cutLength;
cutLengthPresent = true;
}

@JsonSetter("cut_shape")
public void setCutShape(String cutShape) {
this.cutShape = cutShape;
cutShapePresent = true;
}

@JsonSetter("perm_type")
public void setPermType(String permType) {
this.permType = permType;
permTypePresent = true;
}

@JsonSetter("color_name")
public void setColorName(String colorName) {
this.colorName = colorName;
colorNamePresent = true;
}

@JsonSetter("products")
public void setProducts(List<String> products) {
this.products = products;
productsPresent = true;
}

public UpdateTreatmentRecordUseCase.Command toCommand(UUID requesterId, UUID recordId) {
return new UpdateTreatmentRecordUseCase.Command(
requesterId, recordId,
Expand All @@ -163,7 +216,13 @@ public UpdateTreatmentRecordUseCase.Command toCommand(UUID requesterId, UUID rec
patch(memoPresent, memo),
patch(nextVisitCautionsPresent, nextVisitCautions),
patch(durationMinutesPresent, durationMinutes),
patch(treatmentContentPresent, treatmentContent));
patch(treatmentContentPresent, treatmentContent),
patch(timezonePresent, timezone),
patch(cutLengthPresent, cutLength),
patch(cutShapePresent, cutShape),
patch(permTypePresent, permType),
patch(colorNamePresent, colorName),
patch(productsPresent, products));
}

private <T> UpdateTreatmentRecordUseCase.Patch<T> patch(boolean present, T value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class AnalysisJobEntity extends BaseEntity {
private short progress;

@Column(name = "attempt_count", nullable = false, updatable = false)
private short attemptCount;
private int attemptCount;

@Column(name = "failure_code", length = 50)
private String failureCode;

@Column(name = "failure_message", length = 500)
@Column(name = "failure_message", columnDefinition = "text")
private String failureMessage;

@Column(name = "started_at")
Expand All @@ -64,7 +64,7 @@ protected AnalysisJobEntity() {
userId = job.userId();
recordId = job.recordId();
photoId = job.photoId();
attemptCount = (short) job.attemptCount();
attemptCount = job.attemptCount();
apply(job);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class AnalysisResultEntity extends BaseEntity {
@Column(name = "model_version", nullable = false, length = 50)
private String modelVersion;

@Column(name = "summary", length = 500)
@Column(name = "summary_comment", length = 500)
private String summary;

@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "evidence")
@Column(name = "evidence_json")
private String evidence;

@Column(name = "analyzed_at", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class HairstyleAssetEntity extends BaseEntity {
@Column(name = "hairstyle_id", nullable = false, updatable = false)
private UUID hairstyleId;

@Column(name = "style_name", nullable = false, length = 100)
@Column(name = "style_name", nullable = false, length = 30)
private String styleName;

@Column(nullable = false, length = 50)
@Column(nullable = false, length = 20)
private String category;

@Column(name = "thumbnail_file_id")
Expand All @@ -27,7 +27,7 @@ class HairstyleAssetEntity extends BaseEntity {
@Column(nullable = false)
private boolean active;

@Column(name = "asset_version", nullable = false, length = 30)
@Column(name = "asset_version", nullable = false, length = 20)
private String assetVersion;

protected HairstyleAssetEntity() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RecommendationItemEntity {
@Column(name = "color_id", updatable = false)
private UUID colorId;
@Column(name = "display_rank", nullable = false, updatable = false)
private int displayRank;
private short displayRank;
@Column(nullable = false, precision = 5, scale = 2, updatable = false)
private BigDecimal score;
@JdbcTypeCode(SqlTypes.JSON)
Expand All @@ -39,7 +39,7 @@ class RecommendationItemEntity {
@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "reasons_json", nullable = false, columnDefinition = "jsonb", updatable = false)
private List<Map<String, Object>> reasons = List.of();
@Column(name = "management_difficulty", nullable = false, length = 20, updatable = false)
@Column(name = "management_difficulty", nullable = false, length = 10, updatable = false)
private String managementDifficulty;
@Column(name = "estimated_daily_care_minutes", nullable = false, updatable = false)
private int estimatedDailyCareMinutes;
Expand All @@ -51,7 +51,7 @@ protected RecommendationItemEntity() { }
recommendationRunId = runId;
hairstyleId = item.hairstyleId();
colorId = item.colorId();
displayRank = item.displayRank();
displayRank = (short) item.displayRank();
score = item.score();
scoreBreakdown = breakdownMap(item.scoreBreakdown());
reasons = item.reasons().stream().map(reason -> Map.<String, Object>of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecommendationReferenceEntity {
private UUID recommendationItemId;
@Id @Column(name = "record_id", nullable = false, updatable = false)
private UUID recordId;
@Column(name = "reference_reason_code", nullable = false, length = 60, updatable = false)
@Column(name = "reference_reason", nullable = false, length = 255, updatable = false)
private String referenceReasonCode;

protected RecommendationReferenceEntity() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Map<UUID, RecommendationReference> findByItemIds(Collection<UUID> itemIds) {
Map<UUID, RecommendationReference> result = new LinkedHashMap<>();
jdbcTemplate.query("""
SELECT reference.recommendation_item_id, reference.record_id,
reference.reference_reason_code, record.performed_at, record.satisfaction
reference.reference_reason, record.performed_at, record.satisfaction
FROM recommendation_reference_records reference
JOIN treatment_records record ON record.record_id = reference.record_id
WHERE reference.recommendation_item_id IN (:ids)
Expand All @@ -32,7 +32,7 @@ WHERE reference.recommendation_item_id IN (:ids)
new RecommendationReference(rows.getObject("record_id", UUID.class),
rows.getTimestamp("performed_at").toInstant(),
rows.getObject("satisfaction", Integer.class),
rows.getString("reference_reason_code"))));
rows.getString("reference_reason"))));
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SavedStyleEntity extends BaseEntity {
@Column(name = "capture_id", updatable = false)
private UUID captureId;

@Column(length = 500)
@Column(columnDefinition = "text")
private String memo;

protected SavedStyleEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class TreatmentPhotoEntity extends BaseEntity {
private UUID fileId;

@Enumerated(EnumType.STRING)
@Column(name = "image_type", nullable = false, length = 20)
@Column(name = "image_type", nullable = false, length = 10)
private ImageType imageType;

@Column(name = "sort_order", nullable = false)
private int sortOrder;
private short sortOrder;

protected TreatmentPhotoEntity() {
}
Expand All @@ -47,7 +47,7 @@ protected TreatmentPhotoEntity() {
recordId = photo.recordId();
fileId = photo.fileId();
imageType = photo.imageType();
sortOrder = photo.sortOrder();
sortOrder = (short) photo.sortOrder();
}

/** 페이지 조립이 사진을 기록별로 모을 때 쓴다(#66). */
Expand All @@ -63,6 +63,6 @@ TreatmentPhoto toDomain() {
void update(TreatmentPhoto photo) {
fileId = photo.fileId();
imageType = photo.imageType();
sortOrder = photo.sortOrder();
sortOrder = (short) photo.sortOrder();
}
}
Loading
Loading