-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/aws/teamthreefive/photo/controller/PhotoController.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,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
34
src/main/java/aws/teamthreefive/photo/converter/PhotoConverter.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,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(); | ||
|
||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/aws/teamthreefive/photo/dto/response/PhotoResponseDTO.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,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; | ||
} | ||
|
||
} |
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/aws/teamthreefive/photo/service/PhotoQueryService.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 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; | ||
|
||
} | ||
|
||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/aws/teamthreefive/photo/service/PhotoService.java
This file was deleted.
Oops, something went wrong.