Skip to content

Commit

Permalink
feat infonoti manage vergion
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong0329 committed Aug 10, 2024
1 parent 271aa35 commit 6c151ff
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

import static com.wable.www.WableServer.common.response.SuccessStatus.*;

@RestController
Expand All @@ -23,7 +25,7 @@ public class LckGameTypeController {

@GetMapping("v1/information/gametype")
@Operation(summary = "Lck Game Type API입니다.", description = "LckGameTypeGet")
public ResponseEntity<ApiResponse<Object>> getGameType() {
public ResponseEntity<ApiResponse<Object>> getGameType(Principal principal) {
return ApiResponse.success(GET_LCK_GAMETYPE_SUCCESS, lckGameTypeQueryService.getLckGameType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

import static com.wable.www.WableServer.common.response.SuccessStatus.*;

@RestController
Expand All @@ -23,7 +25,7 @@ public class LckRankingController {

@GetMapping("v1/information/rank")
@Operation(summary = "Lck Ranking API입니다.", description = "RankingGet")
public ResponseEntity<ApiResponse<Object>> getLckRanking() {
public ResponseEntity<ApiResponse<Object>> getLckRanking(Principal principal) {
return ApiResponse.success(GET_LCK_RANKING_SUCCESS, lckRankingQueryService.getLckRanking());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

import static com.wable.www.WableServer.common.response.SuccessStatus.*;

@RestController
Expand All @@ -23,7 +25,7 @@ public class LckScheduleController {

@GetMapping("v1/information/schedule")
@Operation(summary = "Lck Schedule API입니다.", description = "ScheduleGet")
public ResponseEntity<ApiResponse<Object>> getLckSchedule() {
public ResponseEntity<ApiResponse<Object>> getLckSchedule(Principal principal) {
return ApiResponse.success(GET_LCK_SCHEDULE_SUCCESS, lckScheduleQueryService.getLckSchedule());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wable.www.WableServer.api.notification.controller;

import com.wable.www.WableServer.api.comment.dto.request.CommentPostRequestDto;
import com.wable.www.WableServer.api.notification.service.InfoNotificationCommandService;
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;
Expand All @@ -9,19 +11,20 @@
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 org.springframework.web.bind.annotation.*;

import java.security.Principal;

import static com.wable.www.WableServer.common.response.SuccessStatus.*;

@RestController
@RequestMapping("/api/v1/")
@RequiredArgsConstructor
@SecurityRequirement(name = "JWT Auth")
@Tag(name="정보 노티 관련",description = "Information Notification Api Document")
public class InfoNotificationController {
private final InfoNotificationQueryService infoNotificationQueryService;
private final InfoNotificationCommandService infoNotificationCommandService;

@GetMapping("notification/info/all")
@Operation(summary = "정보 노티 목록 조회 API 입니다.",description = "InfoNotiList")
Expand All @@ -30,4 +33,25 @@ public ResponseEntity<ApiResponse<Object>> getInfoNotification(Principal princip
return ApiResponse.success(SuccessStatus.INFO_NOTIFICATION_ALL_SUCCESS,
infoNotificationQueryService.getInfoNotification(memberId));
}

@PostMapping("notification/info/manage/gamedone")
@Operation(summary = "XX운영용 gamedone 정보 노티 발생.XX", description = "XXXXXXX")
public ResponseEntity<ApiResponse<Object>> postGameDoneInfoNotification() {
infoNotificationCommandService.postGameDoneInfoNotification();
return ApiResponse.success(POST_GAMEDONE_INFONOTIFICATION_SUCCESS);
}

@PostMapping("notification/info/manage/gamestart")
@Operation(summary = "XX운영용 gamestart 정보 노티 발생.XX", description = "XXXXXXX")
public ResponseEntity<ApiResponse<Object>> postGameStartInfoNotification() {
infoNotificationCommandService.postGameStartInfoNotification();
return ApiResponse.success(POST_GAMESTART_INFONOTIFICATION_SUCCESS);
}

@PostMapping("notification/info/manage/gamedone")
@Operation(summary = "XX운영용 weekdone 정보 노티 발생.XX", description = "XXXXXXX")
public ResponseEntity<ApiResponse<Object>> postWeekDoneInfoNotification() {
infoNotificationCommandService.postWeekDoneInfoNotification();
return ApiResponse.success(POST_WEEKDONE_INFONOTIFICATION_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.wable.www.WableServer.api.member.domain.Member;
import com.wable.www.WableServer.common.entity.BaseTimeEntity;
import jakarta.persistence.*;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -21,4 +22,10 @@ public class InfoNotification extends BaseTimeEntity {
private Member infoNotificationTargetMember;

private InfoNotificationType infoNotificationType;

@Builder
public InfoNotification(Member infoNotificationTargetMember, InfoNotificationType infoNotificationType) {
this.infoNotificationTargetMember = infoNotificationTargetMember;
this.infoNotificationType = infoNotificationType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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.domain.InfoNotificationType;
import com.wable.www.WableServer.api.notification.domain.Notification;
import com.wable.www.WableServer.api.notification.repository.InfoNotificationRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional
public class InfoNotificationCommandService {
private final MemberRepository memberRepository;
private final InfoNotificationRepository infoNotificationRepository;

public void postGameStartInfoNotification() {
List<Member> members = memberRepository.findAllActiveMembers();

for (Member member : members) {
InfoNotification gameStartInfoNotification = InfoNotification.builder()
.infoNotificationTargetMember(member)
.infoNotificationType(InfoNotificationType.GAMESTART)
.build();
infoNotificationRepository.save(gameStartInfoNotification);
}
}

public void postGameDoneInfoNotification() {
List<Member> members = memberRepository.findAllActiveMembers();

for (Member member : members) {
InfoNotification gameDoneInfoNotification = InfoNotification.builder()
.infoNotificationTargetMember(member)
.infoNotificationType(InfoNotificationType.GAMEDONE)
.build();
infoNotificationRepository.save(gameDoneInfoNotification);
}
}

public void postWeekDoneInfoNotification() {
List<Member> members = memberRepository.findAllActiveMembers();

for (Member member : members) {
InfoNotification weekDoneInfoNotification = InfoNotification.builder()
.infoNotificationTargetMember(member)
.infoNotificationType(InfoNotificationType.WEEKDONE)
.build();
infoNotificationRepository.save(weekDoneInfoNotification);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public class SecurityConfig {
"/api/v1/auth",
"/health",
"/profile",
"/actuator/health"
"/actuator/health",
"/api/v1/notification/info/manage/**"
};

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public enum SuccessStatus {
*/
READ_NOTIFICATION_SUCCESS(HttpStatus.OK,"노티 체크 성공"),
COUNT_NOTIFICATION_SUCCESS(HttpStatus.OK,"노티 개수 체크 완료"),
POST_GAMEDONE_INFONOTIFICATION_SUCCESS(HttpStatus.CREATED,"게임 종료 정보 노티 생성 완료"),
POST_GAMESTART_INFONOTIFICATION_SUCCESS(HttpStatus.CREATED,"게임 시작 정보 노티 생성 완료"),
POST_WEEKDONE_INFONOTIFICATION_SUCCESS(HttpStatus.CREATED,"한 주 종료 정보 노티 생성 완료"),

/**
* report
*/
Expand Down

0 comments on commit 6c151ff

Please sign in to comment.