Skip to content
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

[Feat] Photo List #19

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading