Skip to content

Commit

Permalink
Merge pull request #206 from Genti2024/feat/pgreq-two
Browse files Browse the repository at this point in the history
Fix: #196 사진 생성 예시 뷰(정방형 사진) API 기존의 것을 복구하고(iOS는 업데이트 없기 때문), 이번에 추가…
  • Loading branch information
LeeJae-H authored Dec 2, 2024
2 parents 9e2cb19 + 035c7bf commit 2d0af4f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,12 @@ public interface UserResponseExampleApi {
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateView(String type);
public ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateView();

@Operation(summary = "사진 생성 뷰에서의 예시 사진 조회 V2", description = "예시 사진&프롬프트를 조회합니다." + "<br/>"
+ "정방형 비율의 사진입니다.")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateViewV2(String type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v1/users/examples")
@RequiredArgsConstructor
public class UserExampleController implements UserResponseExampleApi {
private final ResponseExampleService responseExampleService;

@Logging(item = LogItem.RESPONSE_EXAMPLE, action = LogAction.VIEW, requester = LogRequester.USER)
@GetMapping("/with-picture")
@GetMapping("/api/v1/users/examples/with-picture")
public ResponseEntity<ApiResult<List<ExampleWithPictureFindResponseDto>>> getAllResponseExamples() {
return success(responseExampleService.getAllResponseExamples());
}

@Logging(item = LogItem.RESPONSE_EXAMPLE, action = LogAction.VIEW, requester = LogRequester.USER)
@GetMapping("/api/v1/users/examples/with-picture-square")
public ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateView(){
return success(responseExampleService.getAllResponseExamplesInGenerateView());
}

@Logging(item = LogItem.RESPONSE_EXAMPLE, action = LogAction.VIEW, requester = LogRequester.USER)
@GetMapping("/with-picture-square/{type}")
public ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateView(
@GetMapping("/api/v2/users/examples/with-picture-square/{type}")
public ResponseEntity<ApiResult<List<ExampleWithSquarePicture>>> getAllResponseExamplesInGenerateViewV2(
@PathVariable(name = "type") String type
){
return success(responseExampleService.getAllResponseExamplesInGenerateView(type));
return success(responseExampleService.getAllResponseExamplesInGenerateViewV2(type));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ExampleWithSquarePicture {
@Schema(description = "에시 프롬프트", example = "벚꽃길에서 벤치에 앉아있어요")
String prompt;

@Schema(description = "사진 유형", example = "FREE_SINGLE")
@Schema(description = "사진 유형", example = "FREE_ONE")
String type;

public ExampleWithSquarePicture(ResponseExample responseExample) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ public void addResponseExamples(List<ExampleSaveCommand> commandList,
.build()).toList());
}

public List<ExampleWithSquarePicture> getAllResponseExamplesInGenerateView(String type) {
public List<ExampleWithSquarePicture> getAllResponseExamplesInGenerateView() {
final String type = "FREE_ONE";
List<ExampleWithSquarePicture> examples = responseExampleRepository.findAllByType(type)
.stream()
.map(ExampleWithSquarePicture::new)
.collect(Collectors.toList());
Collections.shuffle(examples);

return examples.subList(0, 5);
}

public List<ExampleWithSquarePicture> getAllResponseExamplesInGenerateViewV2(String type) {
List<ExampleWithSquarePicture> examples = responseExampleRepository.findAllByType(type)
.stream()
.map(ExampleWithSquarePicture::new)
Expand Down

0 comments on commit 2d0af4f

Please sign in to comment.