Skip to content

Commit

Permalink
[Feat] Photo List
Browse files Browse the repository at this point in the history
하단 전체 NG 사진 리스트
  • Loading branch information
melitina915 committed Nov 27, 2024
1 parent 68a8da2 commit a5c339c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
package aws.teamthreefive.photo.controller;

import aws.teamthreefive.photo.converter.PhotoConverter;
import aws.teamthreefive.photo.dto.response.PhotoResponseDTO;
import aws.teamthreefive.photo.entity.Photo;
import aws.teamthreefive.photo.service.PhotoQueryService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/photo")
public class PhotoController {

private final PhotoQueryService photoQueryService;

@GetMapping("/list/ng/all")
@Operation(summary = "하단 전체 NG 사진 리스트", description = "전체 NG 사진 리스트 ALL")
public PhotoResponseDTO.PhotoListDTO getPhotoListNgAll() {

List<Photo> photoList = photoQueryService.getPhotoListNgAll();

return PhotoConverter.photoListDTO(photoList);

}

}
34 changes: 20 additions & 14 deletions src/main/java/aws/teamthreefive/photo/converter/PhotoConverter.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
package aws.teamthreefive.photo.converter;

import aws.teamthreefive.photo.dto.response.PhotoResponseDTO;
import aws.teamthreefive.photo.entity.Photo;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

public class PhotoConverter {

/*
public static Photo toPhoto(String photoUrl, Photo photo) {
return Photo.builder()
.photoUrl(photoUrl)
public static PhotoResponseDTO.PhotoDTO photoDTO(Photo photo) {
return PhotoResponseDTO.PhotoDTO.builder()
.photoUuid(photo.getPhotoUuid())
.photoUrl(photo.getPhotoUrl())
.photoPosition(photo.getPhotoPosition())
.photoNgtype(photo.getPhotoNgtype())
.photoCroplt(photo.getPhotoCroplt())
.photoCroprb(photo.getPhotoCroprb())
.createdAt(LocalDateTime.now())
.diecast(photo.getDiecast())
.createdAt(photo.getCreatedAt())
.diecastUuid(photo.getDiecast().getDiecastUuid())
.build();
}
*/

// public static Photo toPhoto(String photoUrl) {
// return Photo.builder()
// .photoUrl(photoUrl)
// .createdAt(LocalDateTime.now())
// .build();
// }

public static PhotoResponseDTO.PhotoListDTO photoListDTO(List<Photo> photoList) {

List<PhotoResponseDTO.PhotoDTO> photoDTOList = photoList.stream()
.map(PhotoConverter::photoDTO).collect(Collectors.toList());

return PhotoResponseDTO.PhotoListDTO.builder()
.photoList(photoDTOList)
.build();

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
package aws.teamthreefive.photo.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

public class PhotoResponseDTO {

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class PhotoListDTO {
List<PhotoResponseDTO.PhotoDTO> photoList;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class PhotoDTO {
Long photoUuid;
String photoUrl;
int photoPosition;
int photoNgtype;
Float photoCroplt;
Float photoCroprb;
LocalDateTime createdAt;
Long diecastUuid;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface PhotoRepository extends JpaRepository<Photo, Long> {

List<Photo> findAllByDiecast(Diecast diecast);

List<Photo> findAllByPhotoNgtypeNot(int photoNgtype);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aws.teamthreefive.photo.service;

import aws.teamthreefive.photo.entity.Photo;
import aws.teamthreefive.photo.repository.PhotoRepository;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional
public class PhotoQueryService {

private final PhotoRepository photoRepository;

public List<Photo> getPhotoListNgAll() {

List<Photo> photoList = photoRepository.findAllByPhotoNgtypeNot(0);

return photoList;

}

}

This file was deleted.

0 comments on commit a5c339c

Please sign in to comment.