2424import org .springframework .stereotype .Service ;
2525import org .springframework .transaction .annotation .Transactional ;
2626
27- import java .util .Collections ;
28- import java .util .List ;
29- import java .util .Objects ;
27+ import java .util .*;
3028import java .util .stream .Collectors ;
3129
3230@ Slf4j
@@ -80,8 +78,10 @@ public TrashResultResponse createTrash(CreateTrashRequest request, User user) {
8078 // 5) 업로드
8179 String imageUrl = fileStoragePort .uploadFile (storedKey , contentType , bytes );
8280
81+ String displayName = displayNameFor (analyzedType );
82+
8383 // 6) 저장(타입/요약 적용)
84- Trash trash = Trash .create (user , imageUrl , "쓰레기" );
84+ Trash trash = Trash .create (user , imageUrl , displayName );
8585 trash .applyAnalysis (type , step1 != null ? step1 .description () : null );
8686
8787 // 7) 세부 품목 매핑(있으면)
@@ -113,7 +113,7 @@ public TrashResultResponse createTrash(CreateTrashRequest request, User user) {
113113
114114 var days = (location != null )
115115 ? resolveDisposalDays (location .id (), type .getType ())
116- : java . util . List .<String >of ();
116+ : List .<String >of ();
117117 return TrashResultResponse .of (saved , steps , caution , days , parts , location );
118118
119119 } catch (BusinessException be ) {
@@ -124,6 +124,14 @@ public TrashResultResponse createTrash(CreateTrashRequest request, User user) {
124124 }
125125 }
126126
127+ private String displayNameFor (Type t ) {
128+ return switch (t ) {
129+ case FOOD_WASTE -> "음식물 쓰레기" ;
130+ case NON_RECYCLABLE -> "일반 쓰레기" ;
131+ default -> "쓰레기" ;
132+ };
133+ }
134+
127135 private boolean isRecyclable (Type t ) {
128136 return switch (t ) {
129137 case PAPER , PAPER_PACK , PLASTIC , PET , VINYL_FILM , STYROFOAM , GLASS , METAL , TEXTILES , E_WASTE ,
@@ -135,7 +143,7 @@ private boolean isRecyclable(Type t) {
135143 private List <PartCardResponse > suggestParts (Type baseType ) {
136144 // PET일 때 예시와 동일하게 3개 추천
137145 if (baseType == Type .PET ) {
138- return java . util . List .of (
146+ return List .of (
139147 PartCardResponse .of ("페트병 뚜껑" , Type .PET ),
140148 PartCardResponse .of ("투명 페트병 몸체" , Type .PET ),
141149 PartCardResponse .of ("비닐 라벨" , Type .VINYL_FILM )
@@ -149,13 +157,13 @@ private List<String> parseDays(String json) {
149157 try {
150158 var n = new com .fasterxml .jackson .databind .ObjectMapper ().readTree (json );
151159 if (n .isArray ()) {
152- List <String > out = new java . util . ArrayList <>();
160+ List <String > out = new ArrayList <>();
153161 n .forEach (x -> out .add (x .asText ()));
154162 return out ;
155163 }
156164 var s = n .asText (); // "월요일,화요일" 대응
157165 if (s != null && !s .isBlank ())
158- return java . util . Arrays .stream (s .split ("\\ s*,\\ s*" )).filter (v -> !v .isBlank ()).toList ();
166+ return Arrays .stream (s .split ("\\ s*,\\ s*" )).filter (v -> !v .isBlank ()).toList ();
159167 } catch (Exception ignore ) {}
160168 return List .of ();
161169 }
@@ -209,7 +217,7 @@ public TrashResultResponse getTrash(Long trashId) {
209217
210218 var descOpt = trashDescriptionRepository .findByTrashType (trash .getTrashType ());
211219 var steps = descOpt .map (TrashDescription ::steps )
212- .orElse (java . util . List .of ());
220+ .orElse (List .of ());
213221 var caution = descOpt .map (TrashDescription ::getCautionNote )
214222 .orElse (null );
215223
@@ -221,7 +229,7 @@ public TrashResultResponse getTrash(Long trashId) {
221229 var location = resolveUserDistrictSummary (trash .getUser ().getId ());
222230
223231 // 2) days(enum 기반 조회, 정규화 + id trim)
224- java . util . List <String > days = java . util . Collections .emptyList ();
232+ List <String > days = Collections .emptyList ();
225233 if (location != null && trash .getTrashType () != null ) {
226234 String did = location .id () != null ? location .id ().trim () : null ;
227235 days = resolveDisposalDays (did , trash .getTrashType ().getType ());
@@ -242,7 +250,7 @@ public List<TrashItemResponse> getTrashItemsByTrashId(Long trashId) {
242250 return trashItemRepository .findByTrashTypeId (trash .getTrashType ().getId ())
243251 .stream ()
244252 .map (TrashItemResponse ::from )
245- .collect (java . util . stream . Collectors .toList ());
253+ .collect (Collectors .toList ());
246254 }
247255
248256 @ Transactional
0 commit comments