Skip to content

Commit

Permalink
feat : 유저 출석 정보 조회 추가 중
Browse files Browse the repository at this point in the history
  • Loading branch information
dlgocks1 committed Jul 16, 2024
1 parent eb4b974 commit 01f4dfa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AdminAttendanceController(
}

@GetMapping("/code/page")
@Operation(summary = "03-03-01 모든 코드 정보 조회")
@Operation(summary = "03-03-01 모든 코드 정보 조회 페이징")
fun getCodeInfoPage(
@AuthenticationPrincipal user: User,
@RequestParam("page") page: Int,
Expand All @@ -85,13 +85,16 @@ class AdminAttendanceController(
return CommonResponse.onSuccess(qrCodeService.getAllCodePage(page, size))
}

@GetMapping("/all")
@Operation(summary = "03-04 기수별 모든 출석 현황 체크")
fun getParticipantsAttendance(

@GetMapping("/all/page")
@Operation(summary = "03-04 특정 기수 전체 유저 출석 정보 조회")
fun getUserAttendanceDashboard(
@AuthenticationPrincipal user: User,
@Parameter(description = "기수", example = "13") @RequestParam generation: Int,
): CommonResponse<List<AllAttendanceInfos>> {
return CommonResponse.onSuccess(attendanceService.getParticipantsAttendance(generation))
@RequestParam generation: Int,
@RequestParam page: Int,
@RequestParam size: Int,
): CommonResponse<PageResponse<AllAttendanceInfos>> {
return CommonResponse.onSuccess(attendanceService.getParticipantsAttendance(generation, page, size))
}

@DeleteMapping("/code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.example.cmc_be.attendance.dto.res.AllAttendanceInfos
import com.example.cmc_be.attendance.dto.res.AttendanceDashboardInfo
import com.example.cmc_be.attendance.dto.res.AttendanceInfo
import com.example.cmc_be.attendance.dto.res.AttendancesDashboard
import com.example.cmc_be.common.dto.response.PageResponse
import com.example.cmc_be.common.exeption.NotFoundException
import com.example.cmc_be.domain.attendance.entity.Attendance
import com.example.cmc_be.domain.attendance.enums.AttendanceCategory
Expand All @@ -14,6 +15,8 @@ import com.example.cmc_be.domain.generation.repository.GenerationWeeksInfoReposi
import com.example.cmc_be.domain.notification.exception.NotificationExceptionErrorCode
import com.example.cmc_be.domain.user.entity.User
import com.example.cmc_be.domain.user.repository.UserRepository
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import org.springframework.stereotype.Service
import java.time.ZoneId
import java.time.ZonedDateTime
Expand Down Expand Up @@ -73,11 +76,12 @@ class AttendanceService(
return "${attendanceCategory.status}하였습니다."
}

fun getParticipantsAttendance(generation: Int): List<AllAttendanceInfos> {
fun getParticipantsAttendance(generation: Int, page: Int, size: Int): PageResponse<AllAttendanceInfos> {
val pageable = PageRequest.of(page, size, Sort.by("id").descending())
val allGeneration = generationWeeksInfoRepository.findAllByGeneration(generation).sortedBy { it.week }
val allUsers = userRepository.findAllByNowGeneration(generation)
val allUsers = userRepository.findAllByNowGeneration(generation, pageable)
val allAttendances = attendanceRepository.findAllByGenerationWeeksInfoGeneration(generation)
return allUsers.map { user ->
return PageResponse.from(allUsers.map { user ->
val userAttandances = allAttendances.filter { it.user.id == user.id }
val attendanceInfos = allGeneration.map { generationWeekInfo ->
val userAllAttendanceData =
Expand All @@ -104,6 +108,6 @@ class AttendanceService(
attendanceStatus = AttendanceDashboardInfo.from(attendanceInfos),
attandances = attendanceInfos
)
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserAdminController(
}

@GetMapping("/management/user")
@Operation(summary = "05-01 특정 기수 유저 회원가입 수락")
@Operation(summary = "05-02 특정 기수 유저 회원가입 수락")
fun handleSignUpApprove(
@RequestParam userId: Long,
@RequestParam approve: Boolean
Expand Down

0 comments on commit 01f4dfa

Please sign in to comment.