Skip to content

Commit be7e594

Browse files
authored
Merge pull request #194 from Att-ies/Feature/193-add-response-data
Feature/193-add-response-data
2 parents 1a20a3a + 1a0b6c1 commit be7e594

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

src/main/java/com/sptp/backend/art_work/web/dto/response/BiddingListResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static class ArtWorkDto {
2828
private Long beginPrice;
2929
private Long topPrice;
3030
private String image;
31+
private Long artist;
3132

3233
public static ArtWorkDto of(ArtWork artWork, Long topPrice, String image) {
3334
return ArtWorkDto.builder()
@@ -38,6 +39,7 @@ public static ArtWorkDto of(ArtWork artWork, Long topPrice, String image) {
3839
.beginPrice(Long.valueOf(artWork.getPrice()))
3940
.topPrice(topPrice)
4041
.image(image)
42+
.artist(artWork.getMember().getId())
4143
.build();
4244
}
4345
}

src/main/java/com/sptp/backend/notification/service/NotificationService.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
package com.sptp.backend.notification.service;
22

3+
import com.sptp.backend.common.exception.CustomException;
4+
import com.sptp.backend.common.exception.ErrorCode;
35
import com.sptp.backend.member.repository.Member;
6+
import com.sptp.backend.member.repository.MemberRepository;
47
import com.sptp.backend.notification.repository.Notification;
58
import com.sptp.backend.notification.repository.NotificationRepository;
9+
import com.sptp.backend.notification.web.dto.response.NotificationNewResponse;
610
import com.sptp.backend.notification.web.dto.response.NotificationResponse;
711
import lombok.RequiredArgsConstructor;
812
import lombok.extern.slf4j.Slf4j;
913
import org.springframework.stereotype.Service;
1014
import org.springframework.transaction.annotation.Transactional;
1115

1216
import java.util.List;
17+
import java.util.Objects;
1318
import java.util.stream.Collectors;
1419

1520
@Service
@@ -18,6 +23,7 @@
1823
public class NotificationService {
1924

2025
private final NotificationRepository notificationRepository;
26+
private final MemberRepository memberRepository;
2127

2228
@Transactional
2329
public List<NotificationResponse> getNotificationList(Long loginMember){
@@ -44,10 +50,23 @@ public void deleteNotification(Long notificationId) {
4450
}
4551

4652
@Transactional(readOnly = true)
47-
public Boolean getNotificationNew(Member member) {
53+
public NotificationNewResponse getNotificationNew(Member member) {
4854

49-
long count = notificationRepository.countByMemberAndChecked(member, false);
55+
Member findMember = memberRepository.findById(member.getId())
56+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_MEMBER));
5057

51-
return (count > 0);
58+
Long count = notificationRepository.countByMemberAndChecked(member, false);
59+
60+
Boolean isArtist = false;
61+
if(Objects.equals(findMember.getRoles().get(0), "ROLE_ARTIST")) {
62+
isArtist = true;
63+
}
64+
65+
NotificationNewResponse notificationNewResponse = NotificationNewResponse.builder()
66+
.newNotification(count > 0)
67+
.isArtist(isArtist)
68+
.build();
69+
70+
return notificationNewResponse;
5271
}
5372
}

src/main/java/com/sptp/backend/notification/web/NotificationController.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public ResponseEntity<Void> deleteNotification(@PathVariable(value="notification
4545
@GetMapping("/notifications/new")
4646
public ResponseEntity<NotificationNewResponse> getNotificationNew(@AuthenticationPrincipal CustomUserDetails userDetails){
4747

48-
Boolean checked = notificationService.getNotificationNew(userDetails.getMember());
49-
50-
NotificationNewResponse notificationNewResponse = NotificationNewResponse.builder()
51-
.newNotification(checked)
52-
.build();
48+
NotificationNewResponse notificationNewResponse = notificationService.getNotificationNew(userDetails.getMember());
5349

5450
return ResponseEntity.status(HttpStatus.OK).body(notificationNewResponse);
5551
}

src/main/java/com/sptp/backend/notification/web/dto/response/NotificationNewResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
public class NotificationNewResponse {
1111

1212
private Boolean newNotification;
13+
private Boolean isArtist;
1314
}

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spring:
2121

2222
jpa:
2323
hibernate:
24-
ddl-auto: update
24+
ddl-auto: none
2525
properties:
2626
hibernate:
2727
# show_sql: true

0 commit comments

Comments
 (0)