Skip to content

Commit

Permalink
Feat : 푸시 알림 허용 여부 변경 기능 구현 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
chanmin-00 committed Feb 1, 2025
1 parent eb79080 commit 253e916
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/com/ripple/BE/user/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public ResponseEntity<ApiResponse<?>> profile(
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.EMPTY_RESPONSE);
}

@Operation(summary = "푸시 알림 설정", description = "로그인 후 유저의 푸시 알림 설정을 변경합니다.")
@PostMapping("/alarm")
public ResponseEntity<ApiResponse<?>> alarm(
@RequestParam boolean alarm, @AuthenticationPrincipal CustomUserDetails customUserDetails) {

userService.updateAlarm(alarm, customUserDetails.getId());

return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.EMPTY_RESPONSE);
}

@Operation(summary = "내가 쓴 게시물 조회", description = "로그인한 유저가 작성한 게시물을 조회합니다.")
@GetMapping("/posts")
public ResponseEntity<ApiResponse<Object>> getMyPosts(
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ripple/BE/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Table(name = "users")
@Getter
Expand Down Expand Up @@ -99,6 +100,7 @@ public class User extends BaseEntity {
@Column(name = "is_learning_alarm_allowed")
private boolean isLearningAlarmAllowed = false; // 학습 푸시 알람 여부

@Setter
@Column(name = "is_community_alarm_allowed")
private boolean isCoummunityAlarmAllowed = false; // 커뮤니티 푸시 알람 여부

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/ripple/BE/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class UserService {

private final UserRepository userRepository;

private final PasswordEncoder passwordEncoder;

@Transactional
Expand Down Expand Up @@ -97,7 +98,12 @@ public void updateUserStatsAfterQuiz(
@Transactional
public void updateCompletedCountByLevel(User user, Level level) {
user.increaseCompletedCountByLevel(level);
}

@Transactional
public void updateAlarm(final boolean alarm, final long userId) {

/** TODO: 레벨 업 조건 확인 후 레벨 업 처리 만약 상위 조건의 학습 세트를 완료한 경우 하위 레벨의 학습 세트가 완료되어야지 레벨 업이 가능하다. */
User user = findUserById(userId);
user.setCoummunityAlarmAllowed(alarm);
}
}

0 comments on commit 253e916

Please sign in to comment.