3737import java .io .OutputStream ;
3838import java .net .URL ;
3939import java .time .LocalDateTime ;
40- import java .util .Comparator ;
4140import java .util .List ;
4241import java .util .UUID ;
4342import java .util .zip .ZipEntry ;
@@ -61,37 +60,21 @@ public List<ScriptListResponseDTO.ProductListDTO> getPlayList(int page, UserEnti
6160 try {
6261 List <ProductStatus > validStatuses = List .of (ProductStatus .PASS , ProductStatus .RE_WAIT , ProductStatus .RE_PASS );
6362
64- // POPULAR(조회수 기준 정렬)는 Java단에서 처리
65- if (sortType == ProductSortType .POPULAR ) {
66- List <ProductEntity > plays = productRepo .findAllValidPlays (
67- playType ,
68- validStatuses ,
69- PageRequest .of (page , pageSize , Sort .unsorted ()) // 정렬 직접 처리
70- );
71-
72- return plays .stream ()
73- .map (play -> getListDTO (userInfo , play ))
74- .sorted (Comparator .comparingLong (ScriptListResponseDTO .ProductListDTO ::getViewCount ).reversed ())
75- .limit (pageSize )
76- .toList ();
77- } else {
78- Sort sort = createProductSort (sortType );
79- List <ProductEntity > plays = productRepo .findAllValidPlays (
80- playType ,
81- validStatuses ,
82- PageRequest .of (page , pageSize , sort )
83- );
84-
85- return plays .stream ()
86- .map (play -> getListDTO (userInfo , play ))
87- .toList ();
88- }
63+ Sort sort = createProductSort (sortType );
64+ List <ProductEntity > plays = productRepo .findAllValidPlays (
65+ playType ,
66+ validStatuses ,
67+ PageRequest .of (page , pageSize , sort )
68+ );
69+
70+ return plays .stream ()
71+ .map (play -> getListDTO (userInfo , play ))
72+ .toList ();
8973 } catch (Exception e ) {
9074 throw new RuntimeException ("작품 목록 조회 실패" , e );
9175 }
9276 }
9377
94-
9578 public ProductEntity getProduct (UUID id ) {
9679 try {
9780 return productRepo .findById (id );
0 commit comments