-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
최근 조회한 모델,모델 추천 API 추가 + swagger 문서 수정 #31
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7a670ad
feat:#29 이슈 및 뉴스 엔티티 ㅅ ㅐㅇ성
j2noo 8432df6
feat : #18 레포지토리 생성
j2noo ddbecbf
feat : #29 부정이슈 조회 서비스 로직
j2noo 02da8b7
feat : #18 모델이슈 조회 controller 생성
j2noo ed1d2bb
feat
j2noo a3ac232
fix : #18 안쓰는 코드 제거:
j2noo 9e936d3
fix : #29 data.sql 데이터베이스 변경
j2noo 8ecf6ed
feat: 최근 조회한 모델을 조회하는 API 생성
lsm-del 19818ed
feat: 최근 조회한 모델을 조회하는 API 생성
lsm-del 6f69ab7
docs: swagger 명세서 설명 추가
lsm-del 7cfc34f
Merge branch 'feat/#29-issue' of https://github.com/soulive-A/Backend…
lsm-del 5fd0caa
fix: ci build시 발생하는 SQLIntegrityConstraintViolationException 해결
lsm-del 20668ab
refactor: left join을 inner join으로 수정하여 성능 향상
lsm-del 9c2e2e1
docs: swagger 문서 추가
lsm-del 2533b4b
docs: swagger 문서 추가
lsm-del 027f30a
feat: 모델 추천 받기 기능 추가
lsm-del c6d7da5
docs: swagger 수정
lsm-del 5248eb4
feat: 최근 조회 모델 api에서 반환 속성(데이터) 추가
lsm-del File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/backend/soullive_a/controller/ModelIssueController.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.controller; | ||
|
||
import com.backend.soullive_a.dto.response.model.issue.ModelIssueResponse; | ||
import com.backend.soullive_a.exception.base.BaseResponse; | ||
import com.backend.soullive_a.service.ModelIssueService; | ||
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/issue") | ||
public class ModelIssueController { | ||
private final ModelIssueService modelIssueService; | ||
@GetMapping() | ||
public BaseResponse<ModelIssueResponse> getIssue(@RequestParam String modelName) { | ||
return BaseResponse.<ModelIssueResponse>builder() | ||
.code(200) | ||
.message("부정이슈 조회에 성공했습니다.") | ||
.isSuccess(true) | ||
.data(modelIssueService.getIssue(modelName)) | ||
.build(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/backend/soullive_a/dto/response/ModelRecommendResponse.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,15 @@ | ||
package com.backend.soullive_a.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(name = "모델 추천 응답 model") | ||
public record ModelRecommendResponse( | ||
@Schema(name = "imageUrl", example = "https://soullive-bucket.s3.ap-northeast-2.amazonaws.com/heeae_profile.png", description = "모델 이미지 url입니다.") | ||
String imageUrl, | ||
@Schema(name = "name", example = "김희애", description = "모델 이름입니다.") | ||
String name, | ||
@Schema(name = "job", example = "텔런트/영화배우", description = "모델 직업(구분자)입니다.") | ||
String job | ||
) { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/backend/soullive_a/dto/response/RecentModelResponse.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,19 @@ | ||
package com.backend.soullive_a.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "최근 조회한 모델 model 객체") | ||
public record RecentModelResponse( | ||
@Schema(name = "modelId", example = "1", description = "모델 기본키") | ||
Long modelId, | ||
@Schema(name = "imageUrl", example = "https://soullive-bucket.s3.ap-northeast-2.amazonaws.com/heeae_profile.png", description = "모델 이미지 url입니다.") | ||
String imageUrl, | ||
@Schema(name = "modelName", example = "한지민", description = "모델 이름입니다.") | ||
String modelName, | ||
@Schema(name = "aiRate", example = "3.0", description = "ai 추천 점수입니다.") | ||
Float aiRate, | ||
@Schema(name = "job", example = "배우", description = "직업에 대한 값입니다.") | ||
String job | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 직업이 빠져있는것같아요~ 직업도 추가해주세요 |
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/backend/soullive_a/dto/response/model/issue/ModelIssueResponse.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,14 @@ | ||
package com.backend.soullive_a.dto.response.model.issue; | ||
|
||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record ModelIssueResponse( | ||
String scoreUrl, | ||
String aiComment, | ||
Integer crime, | ||
List<ModelNewsResponse> modelNewsResponseList | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/backend/soullive_a/dto/response/model/issue/ModelNewsResponse.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,15 @@ | ||
package com.backend.soullive_a.dto.response.model.issue; | ||
|
||
import jakarta.persistence.Column; | ||
import lombok.Builder; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Builder | ||
public record ModelNewsResponse( | ||
String company, | ||
LocalDate newsDate, | ||
String title, | ||
String newsUrl | ||
) { | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/backend/soullive_a/entity/model/issue/ModelIssue.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.entity.model.issue; | ||
|
||
import com.backend.soullive_a.entity.model.Model; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class ModelIssue { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "MODEL_ISSUE_ID", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "SCORE_URL", nullable = false) | ||
private String scoreUrl; | ||
|
||
@Column(name = "AI_COMMENT", nullable = false) | ||
private String aiComment; | ||
|
||
@Column(name = "CRIME", nullable = false) | ||
private Integer crime; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "MODEL_ID", nullable = false) | ||
private Model model; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/backend/soullive_a/entity/model/issue/ModelNews.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,35 @@ | ||
package com.backend.soullive_a.entity.model.issue; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@Entity | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class ModelNews { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "MODEL_NEWS_ID", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "COMPANY", nullable = false) | ||
private String company; | ||
|
||
@Column(name = "NEWS_DATE", nullable = false) | ||
private LocalDate newsDate; | ||
|
||
@Column(name = "TITLE", nullable = false) | ||
private String title; | ||
|
||
@Column(name = "NEWS_URL", nullable = false) | ||
private String newsUrl; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "MODEL_ISSUE_ID", nullable = false) | ||
private ModelIssue modelIssue; | ||
|
||
} |
10 changes: 9 additions & 1 deletion
10
src/main/java/com/backend/soullive_a/repository/ModelRepository.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,20 @@ | ||
package com.backend.soullive_a.repository; | ||
|
||
import com.backend.soullive_a.dto.response.ModelRecommendResponse; | ||
import com.backend.soullive_a.entity.model.Model; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.Optional; | ||
|
||
|
||
public interface ModelRepository extends JpaRepository<Model, Long> { | ||
|
||
public Optional<Model> findByModelName(String modelName); | ||
|
||
@Query("select " | ||
+ "new com.backend.soullive_a.dto.response.ModelRecommendResponse(m.imageUrl,m.modelName,m.job) " | ||
+ "From Model m ") | ||
List<ModelRecommendResponse> findAllRecommendModel(); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“/recommendation/singer" 를 하면 가수 리스트가 반환되도록 하는 식으로
가수, 배우, 유튜버로 나누는게 좋아보여요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그러면 API를 3개를 만들어야 하는데 job이라는 구분자로 구분하는 경우에 비해 장점이 어떤 것이 있는지 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금 job이라는 구분자로 하나의 api에서 쓰고 있는게 아니라 이 api는 모든 모델을 반환하는 api 아닌가요..?
모델을 다 반환하면 프론트에서 직업에 따라 구분해서 리스트를 만들고 그 리스트를 이용해서 값을 넣어야합니다 그러기 위해서 프론트에서 15명이 있는 리스트를 직업별로 나누는 로직을 만들어어하는데 그건 프론트의 역할이 아니고 백이 데이터를 구분해서 주어야한다고 봐요..!
만약에 api를 한개쓰고 싶은거라면 @RequestParam 을 쓰거나 “api/recommendation/ {job}" 로 해서 직업별로 구분하되 input 값을 프론트와 일치시켜서 singer,actor,idol 로만 입력을 받을 수 있게 해야할 것같아요