Skip to content

Commit

Permalink
feat : Merge 충돌 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
KJBig committed Sep 26, 2024
2 parents 10a3723 + 5caa52d commit 9729990
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sluv.api.alarm.controller;

import com.sluv.api.alarm.dto.AlarmCheckResponse;
import com.sluv.api.alarm.dto.AlarmResponse;
import com.sluv.api.alarm.service.AlarmService;
import com.sluv.api.common.response.PaginationResponse;
Expand Down Expand Up @@ -46,4 +47,10 @@ public ResponseEntity<SuccessResponse> deleteAllAlarm(@CurrentUserId Long userId
return ResponseEntity.ok().body(SuccessResponse.create());
}

@GetMapping("/check")
public ResponseEntity<SuccessDataResponse<AlarmCheckResponse>> checkAlarmAllRead(@CurrentUserId Long userId) {
AlarmCheckResponse response = alarmService.checkAlarmAllRead(userId);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sluv.api.alarm.dto;

import lombok.*;

@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class AlarmCheckResponse {

private Boolean isAllRead;

public static AlarmCheckResponse of(Boolean isAllRead) {
return AlarmCheckResponse.builder()
.isAllRead(isAllRead)
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sluv.api.alarm.service;

import com.sluv.api.alarm.dto.AlarmCheckResponse;
import com.sluv.api.alarm.dto.AlarmResponse;
import com.sluv.api.common.response.PaginationResponse;
import com.sluv.domain.alarm.dto.AlarmImages;
Expand Down Expand Up @@ -70,4 +71,9 @@ public void deleteAllAlarm(Long useId) {
alarmDomainService.deleteAllAlarm(useId);
}

public AlarmCheckResponse checkAlarmAllRead(Long userId) {
Boolean isAllRead = alarmDomainService.checkAllRead(userId);
return AlarmCheckResponse.of(isAllRead);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,13 @@ public ResponseEntity<SuccessDataResponse<List<ItemSimpleDto>>> getHowAboutItem(
List<ItemSimpleDto> response = itemService.getHowAboutItem(userId);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

@Operation(summary = "*트랜드 셀럽의 아이템", description = "홈 화면 직접 선정한 셀럽의 아이템 조회")
@GetMapping("/trend")
public ResponseEntity<SuccessDataResponse<List<ItemSimpleDto>>> getTrendItems(
@CurrentUserId Long userId, Pageable pageable) {
List<ItemSimpleDto> response = itemService.getTrendItems(userId, pageable);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,12 @@ public List<ItemSimpleDto> getTogetherScrapItem(Long userId, Long itemId) {
List<Item> sameClosetItems = itemDomainService.getSameClosetItems(itemId, recentAddClosets);
return itemDomainService.getItemSimpleDto(user, sameClosetItems);
}

@Transactional(readOnly = true)
public List<ItemSimpleDto> getTrendItems(Long userId, Pageable pageable) {
User user = userDomainService.findById(userId);
Page<Item> itemPage = itemDomainService.getTrendItems(pageable);
return itemDomainService.getItemSimpleDto(user, itemPage.getContent());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

public interface AlarmRepositoryCustom {
Page<Alarm> findAllByUserId(Long userId, Pageable pageable);

Boolean checkAllRead(Long userId);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sluv.domain.alarm.repository.impl;

import static com.sluv.domain.alarm.entity.QAlarm.alarm;
import static com.sluv.domain.alarm.enums.AlarmStatus.ACTIVE;

import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand Down Expand Up @@ -31,4 +32,14 @@ public Page<Alarm> findAllByUserId(Long userId, Pageable pageable) {

return PageableExecutionUtils.getPage(fetch, pageable, () -> countQuery.stream().count());
}

@Override
public Boolean checkAllRead(Long userId) {
List<Alarm> fetch = jpaQueryFactory.selectFrom(alarm)
.where(alarm.user.id.eq(userId)
.and(alarm.alarmStatus.eq(ACTIVE))
).fetch();
return fetch.isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
import com.sluv.domain.alarm.exception.AlarmNotFoundException;
import com.sluv.domain.alarm.repository.AlarmRepository;
import com.sluv.domain.user.entity.User;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Service
@RequiredArgsConstructor
public class AlarmDomainService {
Expand Down Expand Up @@ -66,4 +67,9 @@ public Page<Alarm> findAllByUserId(Long userId, Pageable pageable) {
return alarmRepository.findAllByUserId(userId, pageable);
}

@Transactional(readOnly = true)
public Boolean checkAllRead(Long userId) {
return alarmRepository.checkAllRead(userId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ public interface ItemRepositoryCustom {

List<Item> getItemContainKeyword(String keyword);

Page<Item> getTrendItems(Pageable pageable);
}
Loading

0 comments on commit 9729990

Please sign in to comment.