-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...ava/com/wable/www/WableServer/api/notification/controller/InfoNotificationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.wable.www.WableServer.api.notification.controller; | ||
|
||
import com.wable.www.WableServer.api.notification.service.InfoNotificationQueryService; | ||
import com.wable.www.WableServer.common.response.ApiResponse; | ||
import com.wable.www.WableServer.common.response.SuccessStatus; | ||
import com.wable.www.WableServer.common.util.MemberUtil; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.security.Principal; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/") | ||
@RequiredArgsConstructor | ||
@SecurityRequirement(name = "JWT Auth") | ||
@Tag(name="정보 노티 관련",description = "Information Notification Api Document") | ||
public class InfoNotificationController { | ||
private final InfoNotificationQueryService infoNotificationQueryService; | ||
|
||
@GetMapping("notification/info/all") | ||
@Operation(summary = "정보 노티 목록 조회 API 입니다.",description = "InfoNotiList") | ||
public ResponseEntity<ApiResponse<Object>> getInfoNotification(Principal principal) { | ||
Long memberId = MemberUtil.getMemberId(principal); | ||
return ApiResponse.success(SuccessStatus.INFO_NOTIFICATION_ALL_SUCCESS, | ||
infoNotificationQueryService.getInfoNotification(memberId)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ver/src/main/java/com/wable/www/WableServer/api/notification/domain/InfoNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.wable.www.WableServer.api.notification.domain; | ||
|
||
import com.wable.www.WableServer.api.member.domain.Member; | ||
import com.wable.www.WableServer.common.entity.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class InfoNotification extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "target_member_id") | ||
private Member infoNotificationTargetMember; | ||
|
||
private InfoNotificationType infoNotificationType; | ||
} |
5 changes: 5 additions & 0 deletions
5
...src/main/java/com/wable/www/WableServer/api/notification/domain/InfoNotificationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wable.www.WableServer.api.notification.domain; | ||
|
||
public enum InfoNotificationType { | ||
GAMEDONE, GAMESTART, WEEKDONE | ||
} |
18 changes: 18 additions & 0 deletions
18
...m/wable/www/WableServer/api/notification/dto/response/InfoNotificationAllResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wable.www.WableServer.api.notification.dto.response; | ||
|
||
import com.wable.www.WableServer.api.notification.domain.InfoNotification; | ||
import com.wable.www.WableServer.common.util.TimeUtilCustom; | ||
|
||
public record InfoNotificationAllResponseDto( | ||
String InfoNotificationType, | ||
String time, | ||
String imageUrl | ||
) { | ||
public static InfoNotificationAllResponseDto of(InfoNotification infoNotification, String imageUrl) { | ||
return new InfoNotificationAllResponseDto( | ||
infoNotification.getInfoNotificationType().name(), | ||
TimeUtilCustom.refineTime(infoNotification.getCreatedAt()), | ||
imageUrl | ||
); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ava/com/wable/www/WableServer/api/notification/repository/InfoNotificationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.wable.www.WableServer.api.notification.repository; | ||
|
||
import com.wable.www.WableServer.api.member.domain.Member; | ||
import com.wable.www.WableServer.api.notification.domain.InfoNotification; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface InfoNotificationRepository extends JpaRepository<InfoNotification, Long> { | ||
List<InfoNotification> findAllByInfoNotificationTargetMemberOrderByCreatedAtDesc(Member member); | ||
} |
35 changes: 35 additions & 0 deletions
35
...java/com/wable/www/WableServer/api/notification/service/InfoNotificationQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.wable.www.WableServer.api.notification.service; | ||
|
||
import com.wable.www.WableServer.api.member.domain.Member; | ||
import com.wable.www.WableServer.api.member.repository.MemberRepository; | ||
import com.wable.www.WableServer.api.notification.domain.InfoNotification; | ||
import com.wable.www.WableServer.api.notification.dto.response.InfoNotificationAllResponseDto; | ||
import com.wable.www.WableServer.api.notification.repository.InfoNotificationRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class InfoNotificationQueryService { | ||
@Value("${aws-property.s3-info-image-url}") | ||
private String INFO_IMAGE_S3; | ||
|
||
private final InfoNotificationRepository infoNotificationRepository; | ||
private final MemberRepository memberRepository; | ||
public List<InfoNotificationAllResponseDto> getInfoNotification(Long memberId) { | ||
Member member = memberRepository.findMemberByIdOrThrow(memberId); | ||
List<InfoNotification> infoNotifications = | ||
infoNotificationRepository.findAllByInfoNotificationTargetMemberOrderByCreatedAtDesc(member); | ||
|
||
return infoNotifications.stream() | ||
.map(infoNotification -> InfoNotificationAllResponseDto.of( | ||
infoNotification, | ||
INFO_IMAGE_S3 | ||
)).collect(Collectors.toList()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters