Skip to content

Commit

Permalink
feat: AI프로필 정보에 petType 추가 #32
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Jan 29, 2024
1 parent 69883a3 commit 8cf1b18
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.nice.petudio.api.controller.concept.dto;


import com.nice.petudio.domain.concept.PetType;
import lombok.AccessLevel;
import lombok.Builder;

@Builder(access = AccessLevel.PRIVATE)
public record ConceptRetrieveResponse(Long conceptId, String mainImageUri, String name, String description, Boolean isNew) {
public record ConceptRetrieveResponse(Long conceptId, String mainImageUri, String name, String descriptionMessage,
PetType petType, Boolean isNew) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public static ConceptsRetrieveResponse convertEntitiesToDto(List<Concept> concep
List<ConceptRetrieveResponse> conceptsResponse = new ArrayList<>();

for (Concept concept : concepts) {
String conceptMessagePrefix = concept.getConceptType().getMessagePrefix();
String conceptMessagePrefix = concept.getInfo().getMessagePrefix();

String conceptName = MessageUtils.getMessage(messageSource,
String name = MessageUtils.getMessage(messageSource,
conceptMessagePrefix + ConceptMessageType.NAME.getType());
String conceptDescription = MessageUtils.getMessage(messageSource,
String descriptionMessage = MessageUtils.getMessage(messageSource,
conceptMessagePrefix + ConceptMessageType.DESCRIPTION.getType());

conceptsResponse.add(new ConceptRetrieveResponse(concept.getId(), concept.getMainImageUri(), conceptName, conceptDescription,
concept.validateIsNew(now)));
conceptsResponse.add(new ConceptRetrieveResponse(concept.getId(), concept.getMainImageUri(), name,
descriptionMessage, concept.getInfo().getPetType(), concept.validateIsNew(now)));
}
return new ConceptsRetrieveResponse(conceptsResponse);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nice/petudio/domain/concept/Concept.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class Concept extends BaseEntity {
private Long id;

@Enumerated(EnumType.STRING)
@Column(name = "concept_type", length = 30, nullable = false)
private ConceptType conceptType;
@Column(name = "concept_info", length = 30, nullable = false)
private ConceptInfo info;

@Column(name = "concept_main_image_uri", length = 200, nullable = false)
private String mainImageUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum ConceptType {
CONCEPT_3D("concept.3d."),
CONCEPT_TRENDY("concept.trendy.");
public enum ConceptInfo {
DOG_3D("concept.dog.3d.", PetType.DOG),
DOG_TRENDY("concept.dog.trendy.", PetType.DOG);

private final String messagePrefix;
private final PetType petType;
}
12 changes: 12 additions & 0 deletions src/main/java/com/nice/petudio/domain/concept/PetType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nice.petudio.domain.concept;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum PetType {
DOG,
CAT
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
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);
}
8 changes: 6 additions & 2 deletions src/main/resources/sql/data.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
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');
INSERT INTO concepts
VALUES (1, 'DOG_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, 'DOG_TRENDY', 'mainImage', 'image', 'image', 'image', 'image', 'image', 'image', 'image', 'image',
'2024-01-24 23:48:52', '2024-01-24 23:48:52');
2 changes: 1 addition & 1 deletion src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CREATE TABLE `points`
CREATE TABLE `concepts`
(
`concept_id` bigint AUTO_INCREMENT PRIMARY KEY,
`concept_type` varchar(30) NOT NULL,
`concept_info` varchar(30) NOT NULL,
`concept_main_image_uri` varchar(200) NOT NULL,
`concept_success_image1_uri` varchar(200) NOT NULL,
`concept_success_image2_uri` varchar(200) NOT NULL,
Expand Down

0 comments on commit 8cf1b18

Please sign in to comment.