-
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.
Merge pull request #56 from IT-Cotato/feat/my-page-#25
Feat : 마이페이지, 출석 관련 기능 구현 #25
- Loading branch information
Showing
32 changed files
with
652 additions
and
57 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
src/main/java/com/ripple/BE/auth/dto/kakao/KakaoUserInfoResponse.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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
package com.ripple.BE.auth.dto.kakao; | ||
|
||
public record KakaoUserInfoResponse( | ||
Long id, KakaoProperties properties, KakaoAccount kakao_account) {} | ||
public record KakaoUserInfoResponse(Long id, KakaoAccount kakao_account) {} |
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
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
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
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
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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
src/main/java/com/ripple/BE/user/controller/AttendanceController.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,56 @@ | ||
package com.ripple.BE.user.controller; | ||
|
||
import com.ripple.BE.global.dto.response.ApiResponse; | ||
import com.ripple.BE.user.domain.CustomUserDetails; | ||
import com.ripple.BE.user.dto.QuestDTO; | ||
import com.ripple.BE.user.dto.response.QuestResponse; | ||
import com.ripple.BE.user.service.AttendanceService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/v1/attencance") | ||
@Tag(name = "Attendance", description = "출석 API") | ||
public class AttendanceController { | ||
|
||
private final AttendanceService attendanceService; | ||
|
||
@Operation(summary = "연속 출석 날짜 조회", description = "현재 사용자의 연속 출석 날짜를 조회합니다.") | ||
@GetMapping("/current-streak") | ||
public ResponseEntity<ApiResponse<?>> currentStreak( | ||
@AuthenticationPrincipal CustomUserDetails customUserDetails) { | ||
|
||
Long currentStreak = attendanceService.getCurrentStreak(customUserDetails.getId()); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.from(currentStreak)); | ||
} | ||
|
||
@Operation( | ||
summary = "오늘의 퀘스트 완료 여부 조회", | ||
description = "오늘의 퀘스트 완료 여부를 조회합니다. 퍼센트로 반환됩니다. (0~100)") | ||
@GetMapping("/today-quest") | ||
public ResponseEntity<ApiResponse<?>> todayQuest( | ||
@AuthenticationPrincipal CustomUserDetails customUserDetails) { | ||
|
||
QuestDTO todayQuest = attendanceService.getTodayQuest(customUserDetails.getId()); | ||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(ApiResponse.from(QuestResponse.toQuestResponse(todayQuest))); | ||
} | ||
|
||
@Operation(summary = "요일별 출석 현황 조회", description = "요일별 출석 현황을 조회합니다. 매주 자동으로 초기화됩니다.") | ||
@GetMapping("/weekly-attendance") | ||
public ResponseEntity<ApiResponse<?>> weeklyAttendance( | ||
@AuthenticationPrincipal CustomUserDetails customUserDetails) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(ApiResponse.from(attendanceService.getWeeklyAttendance(customUserDetails.getId()))); | ||
} | ||
} |
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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/ripple/BE/user/domain/AttendanceLog.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,44 @@ | ||
package com.ripple.BE.user.domain; | ||
|
||
import com.ripple.BE.global.entity.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDate; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Table(name = "attendance_logs") | ||
@Getter | ||
@Builder | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class AttendanceLog extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "attendance_log_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "attendance_id") | ||
private Attendance attendance; | ||
|
||
private LocalDate date; // 출석 날짜 | ||
|
||
private boolean isAttended; // 출석 여부 | ||
|
||
public void updateIsAttended() { | ||
this.isAttended = true; | ||
} | ||
} |
Oops, something went wrong.