-
Notifications
You must be signed in to change notification settings - Fork 1
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
17 changed files
with
358 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/com/backend/soullive_a/controller/ModelPopularityController.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.backend.soullive_a.controller; | ||
|
||
import com.backend.soullive_a.dto.response.model.popularity.ModelPopularityResponse; | ||
import com.backend.soullive_a.exception.base.BaseResponse; | ||
import com.backend.soullive_a.service.ModelPopularityService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/model/popularity") | ||
public class ModelPopularityController { | ||
|
||
private final ModelPopularityService modelPopularityService; | ||
|
||
@GetMapping("") | ||
public BaseResponse<ModelPopularityResponse> getModelPopularity( | ||
@RequestParam String name | ||
) { | ||
return BaseResponse.<ModelPopularityResponse>builder() | ||
.isSuccess(true) | ||
.code(200) | ||
.message(name+" 모델 화제성 조회에 성공했습니다.") | ||
.data(modelPopularityService.getModelPopularity(name)) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...in/java/com/backend/soullive_a/dto/response/model/popularity/ModelPopularAgeResponse.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.backend.soullive_a.dto.response.model.popularity; | ||
|
||
import com.backend.soullive_a.constant.AgeType; | ||
|
||
public record ModelPopularAgeResponse( | ||
Long ageId, | ||
AgeType ageType | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
...java/com/backend/soullive_a/dto/response/model/popularity/ModelPopularGenderResponse.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.backend.soullive_a.dto.response.model.popularity; | ||
|
||
import com.backend.soullive_a.constant.GenderType; | ||
|
||
public record ModelPopularGenderResponse( | ||
Long genderId, | ||
GenderType gender | ||
) { | ||
} |
63 changes: 63 additions & 0 deletions
63
...in/java/com/backend/soullive_a/dto/response/model/popularity/ModelPopularityResponse.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,63 @@ | ||
package com.backend.soullive_a.dto.response.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.popularity.ModelPopularAge; | ||
import com.backend.soullive_a.entity.model.popularity.ModelPopularGender; | ||
import com.backend.soullive_a.entity.model.popularity.ModelPopularity; | ||
import com.backend.soullive_a.entity.model.popularity.ModelScheduledWork; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Builder | ||
public record ModelPopularityResponse( | ||
Long modelPopularityId, | ||
Long modelId, | ||
String scoreUrl, | ||
String aiComment, | ||
List<ModelPopularGenderResponse> genders, | ||
List<ModelPopularAgeResponse> ages, | ||
String snsUrl, | ||
String searchUrl, | ||
String brandScoreUrl, | ||
List<ModelScheduledWorkResponse> modelScheduledWorks | ||
) { | ||
public static ModelPopularityResponse fromModel( | ||
ModelPopularity modelPopularity, | ||
List<ModelPopularGender> modelPopularGender, | ||
List<ModelPopularAge> modelPopularAge, | ||
List<ModelScheduledWork> modelScheduledWork | ||
) { | ||
List<ModelPopularGenderResponse> modelPopularGenders = modelPopularGender.stream() | ||
.map(gender -> new ModelPopularGenderResponse(gender.getId(), gender.getGender())) | ||
.collect(Collectors.toList()); | ||
|
||
List<ModelPopularAgeResponse> modelPopularAges = modelPopularAge.stream() | ||
.map(age -> new ModelPopularAgeResponse(age.getId(), age.getAge())) | ||
.collect(Collectors.toList()); | ||
|
||
List<ModelScheduledWorkResponse> modelScheduledWorks = modelScheduledWork.stream() | ||
.map(work -> new ModelScheduledWorkResponse( | ||
work.getId(), | ||
work.getImageUrl(), | ||
work.getYear(), | ||
work.getCategory(), | ||
work.getTitle(), | ||
work.getIsMainActor(), | ||
work.getGenre())) | ||
.collect(Collectors.toList()); | ||
|
||
return ModelPopularityResponse.builder() | ||
.modelId(modelPopularity.getModel().getId()) | ||
.modelPopularityId(modelPopularity.getId()) | ||
.scoreUrl(modelPopularity.getScoreUrl()) | ||
.aiComment(modelPopularity.getAiComment()) | ||
.genders(modelPopularGenders) | ||
.ages(modelPopularAges) | ||
.snsUrl(modelPopularity.getSnsUrl()) | ||
.searchUrl(modelPopularity.getSearchUrl()) | ||
.brandScoreUrl(modelPopularity.getBrandScoreUrl()) | ||
.modelScheduledWorks(modelScheduledWorks) | ||
.build(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...java/com/backend/soullive_a/dto/response/model/popularity/ModelScheduledWorkResponse.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,12 @@ | ||
package com.backend.soullive_a.dto.response.model.popularity; | ||
|
||
public record ModelScheduledWorkResponse( | ||
Long modelScheduledWorkId, | ||
String imageUrl, | ||
Integer year, | ||
String category, | ||
String title, | ||
Boolean isMainActor, | ||
String genre | ||
) { | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/backend/soullive_a/entity/model/popularity/ModelPopularAge.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,27 @@ | ||
package com.backend.soullive_a.entity.model.popularity; | ||
|
||
import com.backend.soullive_a.constant.AgeType; | ||
import com.backend.soullive_a.entity.Product; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "MODEL_POPULAR_AGE") | ||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ModelPopularAge { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "AGE_ID") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "MODEL_POPULARITY_ID", nullable = false) | ||
private ModelPopularity modelPopularity; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "AGE_TYPE") | ||
private AgeType age; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/backend/soullive_a/entity/model/popularity/ModelPopularGender.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,26 @@ | ||
package com.backend.soullive_a.entity.model.popularity; | ||
|
||
import com.backend.soullive_a.constant.GenderType; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "MODEL_POPULAR_GENDER") | ||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ModelPopularGender { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "GENDER_ID") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "MODEL_POPULARITY_ID", nullable = false) | ||
private ModelPopularity modelPopularity; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "GENDER_TYPE") | ||
private GenderType gender; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/backend/soullive_a/entity/model/popularity/ModelPopularity.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,37 @@ | ||
package com.backend.soullive_a.entity.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.Model; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "MODEL_POPULARITY") | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ModelPopularity{ | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "MODEL_POPULARITY_ID", nullable = false) | ||
private Long id; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "MODEL_ID", nullable = false) | ||
private Model model; | ||
|
||
@Column(name = "SCORE_URL") | ||
private String scoreUrl; | ||
|
||
@Column(name = "AI_COMMENT") | ||
private String aiComment; | ||
|
||
@Column(name = "SNS_URL") | ||
private String snsUrl; | ||
|
||
@Column(name = "SEARCH_URL") | ||
private String searchUrl; | ||
|
||
@Column(name = "BRAND_SCORE_URL") | ||
private String brandScoreUrl; | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/backend/soullive_a/entity/model/popularity/ModelScheduledWork.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,40 @@ | ||
package com.backend.soullive_a.entity.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.Model; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "MODEL_SCHEDULED_WORK") | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ModelScheduledWork { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "MODEL_SCHEDULED_WORK_ID", nullable = false) | ||
private Long id; | ||
|
||
@JoinColumn(name = "IMAGE_URL") | ||
private String imageUrl; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "MODEL_POPULARITY_ID", nullable = false) | ||
private ModelPopularity modelPopularity; | ||
|
||
@Column(name = "YEAR", nullable = false) | ||
private Integer year; | ||
|
||
@Column(name = "CATEGORY", nullable = false) | ||
private String category; | ||
|
||
@Column(name = "TITLE", nullable = false) | ||
private String title; | ||
|
||
@Column(name = "IS_MAIN_ACTOR", nullable = false) | ||
private Boolean isMainActor; | ||
|
||
@Column(name = "GENRE", nullable = false) | ||
private String genre; | ||
} |
12 changes: 12 additions & 0 deletions
12
...in/java/com/backend/soullive_a/repository/model/popularity/ModelPopularAgeRepository.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,12 @@ | ||
package com.backend.soullive_a.repository.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.popularity.ModelPopularAge; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ModelPopularAgeRepository extends JpaRepository<ModelPopularAge, Long> { | ||
|
||
List<ModelPopularAge> findAllByModelPopularityModelModelName(String name); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...java/com/backend/soullive_a/repository/model/popularity/ModelPopularGenderRepository.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,12 @@ | ||
package com.backend.soullive_a.repository.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.popularity.ModelPopularGender; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ModelPopularGenderRepository extends JpaRepository<ModelPopularGender, Long> { | ||
|
||
List<ModelPopularGender> findAllByModelPopularityModelModelName(String name); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...in/java/com/backend/soullive_a/repository/model/popularity/ModelPopularityRepository.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,10 @@ | ||
package com.backend.soullive_a.repository.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.popularity.ModelPopularity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ModelPopularityRepository extends JpaRepository<ModelPopularity, Long> { | ||
|
||
ModelPopularity findByModelModelName(String name); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...java/com/backend/soullive_a/repository/model/popularity/ModelScheduledWorkRepository.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,12 @@ | ||
package com.backend.soullive_a.repository.model.popularity; | ||
|
||
import com.backend.soullive_a.entity.model.popularity.ModelScheduledWork; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ModelScheduledWorkRepository extends JpaRepository<ModelScheduledWork, Long> { | ||
|
||
List<ModelScheduledWork> findAllByModelPopularityModelModelName(String name); | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/backend/soullive_a/service/ModelPopularityService.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,8 @@ | ||
package com.backend.soullive_a.service; | ||
|
||
import com.backend.soullive_a.dto.response.model.popularity.ModelPopularityResponse; | ||
|
||
public interface ModelPopularityService { | ||
|
||
ModelPopularityResponse getModelPopularity(String name); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/backend/soullive_a/service/impl/ModelPopularityServiceImpl.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,37 @@ | ||
package com.backend.soullive_a.service.impl; | ||
|
||
import com.backend.soullive_a.dto.response.model.popularity.ModelPopularityResponse; | ||
import com.backend.soullive_a.entity.model.popularity.ModelPopularAge; | ||
import com.backend.soullive_a.entity.model.popularity.ModelPopularGender; | ||
import com.backend.soullive_a.entity.model.popularity.ModelPopularity; | ||
import com.backend.soullive_a.entity.model.popularity.ModelScheduledWork; | ||
import com.backend.soullive_a.repository.model.popularity.ModelPopularAgeRepository; | ||
import com.backend.soullive_a.repository.model.popularity.ModelPopularGenderRepository; | ||
import com.backend.soullive_a.repository.model.popularity.ModelPopularityRepository; | ||
import com.backend.soullive_a.repository.model.popularity.ModelScheduledWorkRepository; | ||
import com.backend.soullive_a.service.ModelPopularityService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ModelPopularityServiceImpl implements ModelPopularityService { | ||
|
||
private final ModelPopularityRepository modelPopularityRepository; | ||
private final ModelPopularAgeRepository modelPopularAgeRepository; | ||
private final ModelPopularGenderRepository modelPopularGenderRepository; | ||
private final ModelScheduledWorkRepository modelScheduledWorkRepository; | ||
|
||
@Override | ||
@Transactional(readOnly = true) | ||
public ModelPopularityResponse getModelPopularity(String name) { | ||
ModelPopularity modelPopularity = modelPopularityRepository.findByModelModelName(name); | ||
List<ModelPopularGender> modelPopularGenders = modelPopularGenderRepository.findAllByModelPopularityModelModelName(name); | ||
List<ModelPopularAge> modelPopularAges = modelPopularAgeRepository.findAllByModelPopularityModelModelName(name); | ||
List<ModelScheduledWork> modelScheduledWorks = modelScheduledWorkRepository.findAllByModelPopularityModelModelName(name); | ||
return ModelPopularityResponse.fromModel(modelPopularity, modelPopularGenders, modelPopularAges, modelScheduledWorks); | ||
} | ||
} |
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 +1,11 @@ | ||
INSERT INTO soullive.user (user_id, password, phone_number) VALUES (1, 'password', '010-0000-0000'); | ||
-- git 에는 soullive로 해야함 | ||
INSERT INTO soullive.user (user_id, password, phone_number) VALUES (1, 'password', '010-0000-0000'); | ||
INSERT INTO soullive.model (model_id, model_name, birth, age, job, info, agency, ai_rate) VALUES (1,'김희애', '1967-04-23','56세','텔런트/영화배우','','YG 엔터테인먼트',4.0); | ||
INSERT INTO soullive.model_popularity (model_popularity_id,model_id,score_url,ai_comment,sns_url,search_url,brand_score_url) values (1,1,null,'최근 화제성에서는 다소 약한 모습을 보여주고 있지만 3040 남녀 모두에게 높은 인지도를 갖고 있고 앞으로 2개의 주연 활동을 앞두고 있어 더 큰 화제성을 갖을 것으로 예상됩니다.',null,null,null); | ||
INSERT INTO soullive.model_popular_gender (gender_id, model_popularity_id, gender_type) values ('1','1','MALE'); | ||
INSERT INTO soullive.model_popular_gender (gender_id, model_popularity_id, gender_type) values ('2','1','FEMALE'); | ||
INSERT INTO soullive.model_popular_age (age_id, model_popularity_id,age_type) values (1,1,'THIRTY'); | ||
INSERT INTO soullive.model_popular_age (age_id, model_popularity_id,age_type) values (2,1,'FORTY'); | ||
INSERT INTO soullive.model_popular_age (age_id, model_popularity_id,age_type) values (3,1,'FIFTY'); | ||
INSERT INTO soullive.model_scheduled_work (model_scheduled_work_id,image_url,model_popularity_id,year,category,title,is_main_actor,genre) values (1,null, 1, 2024, '방영 예정 영화','돌풍',true,'공포'); | ||
INSERT INTO soullive.model_scheduled_work (model_scheduled_work_id,image_url,model_popularity_id,year,category,title,is_main_actor,genre) values (2,null, 1, 2024, '방영 예정 영화','보통의 가족',true,'공포'); |