-
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.
- Loading branch information
Showing
12 changed files
with
129 additions
and
71 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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/nice/petudio/api/controller/concept/dto/ConceptDetailResponse.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,20 @@ | ||
package com.nice.petudio.api.controller.concept.dto; | ||
|
||
|
||
import com.nice.petudio.domain.concept.Concept; | ||
import java.util.List; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record ConceptDetailResponse(List<String> successImageUris, List<String> failImageUris) { | ||
|
||
public static ConceptDetailResponse fromEntity(Concept concept) { | ||
return ConceptDetailResponse.builder() | ||
.successImageUris(List.of(concept.getSuccessImage1Uri(), concept.getSuccessImage2Uri(), | ||
concept.getSuccessImage3Uri(), concept.getSuccessImage4Uri())) | ||
.failImageUris(List.of(concept.getFailImage1lUri(), concept.getFailImage2Uri(), | ||
concept.getFailImage3Uri(), concept.getFailImage4Uri())) | ||
.build(); | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
src/main/java/com/nice/petudio/api/controller/concept/dto/ConceptResponse.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/main/java/com/nice/petudio/api/controller/concept/dto/ConceptRetrieveResponse.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,9 @@ | ||
package com.nice.petudio.api.controller.concept.dto; | ||
|
||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record ConceptRetrieveResponse(String mainImageUri, String name, String description, Boolean isNew) { | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/com/nice/petudio/api/controller/concept/dto/ConceptsResponse.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/main/java/com/nice/petudio/api/controller/concept/dto/ConceptsRetrieveResponse.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,30 @@ | ||
package com.nice.petudio.api.controller.concept.dto; | ||
|
||
import com.nice.petudio.common.util.MessageUtils; | ||
import com.nice.petudio.domain.concept.Concept; | ||
import com.nice.petudio.domain.concept.ConceptMessageType; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.springframework.context.MessageSource; | ||
|
||
public record ConceptsRetrieveResponse(List<ConceptRetrieveResponse> conceptInfos) { | ||
|
||
public static ConceptsRetrieveResponse convertEntitiesToDto(List<Concept> concepts, MessageSource messageSource, | ||
LocalDateTime now) { | ||
List<ConceptRetrieveResponse> conceptsResponse = new ArrayList<>(); | ||
|
||
for (Concept concept : concepts) { | ||
String conceptMessagePrefix = concept.getConceptType().getMessagePrefix(); | ||
|
||
String conceptName = MessageUtils.getMessage(messageSource, | ||
conceptMessagePrefix + ConceptMessageType.NAME.getType()); | ||
String conceptDescription = MessageUtils.getMessage(messageSource, | ||
conceptMessagePrefix + ConceptMessageType.DESCRIPTION.getType()); | ||
|
||
conceptsResponse.add(new ConceptRetrieveResponse(concept.getMainImageUri(), conceptName, conceptDescription, | ||
concept.validateIsNew(now))); | ||
} | ||
return new ConceptsRetrieveResponse(conceptsResponse); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/nice/petudio/api/controller/concept/service/ConceptServiceUtils.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,4 +1,15 @@ | ||
package com.nice.petudio.api.controller.concept.service; | ||
|
||
import com.nice.petudio.common.exception.error.ErrorCode; | ||
import com.nice.petudio.common.exception.model.NotFoundException; | ||
import com.nice.petudio.domain.concept.Concept; | ||
import com.nice.petudio.domain.concept.repository.ConceptRepository; | ||
|
||
public class ConceptServiceUtils { | ||
|
||
public static Concept findByConceptId(ConceptRepository conceptRepository, Long conceptId) { | ||
return conceptRepository.findById(conceptId) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_CONCEPT_EXCEPTION, | ||
String.format("존재하지 않는 conceptId(%d) 입니다.", conceptId))); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/nice/petudio/domain/concept/repository/ConceptRepository.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,7 +1,10 @@ | ||
package com.nice.petudio.domain.concept.repository; | ||
|
||
import com.nice.petudio.domain.concept.Concept; | ||
import com.nice.petudio.domain.concept.ConceptType; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ConceptRepository extends ConceptRepositoryCustom, JpaRepository<Concept, Long> { | ||
Optional<Concept> findByConceptType(ConceptType conceptType); | ||
} |
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,3 +1,2 @@ | ||
# Concept Data Insert (컨셉 추가 시, 여기에 추가) | ||
INSERT INTO concepts VALUES(1, 'CONCEPT_3D', 'mainImage','image','image','image','image','image','image','image','image', '2024-01-24 23:48:52','2024-01-24 23:48:52'); | ||
INSERT INTO concepts VALUES(2, 'CONCEPT_TRENDY', 'mainImage','image','image','image','image','image','image','image','image', '2024-01-24 23:48:52','2024-01-24 23:48:52'); |
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