Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.moa.controller.screen
import com.moa.common.auth.Auth
import com.moa.common.auth.AuthMemberInfo
import com.moa.common.response.ApiResponse
import com.moa.service.MemberService
import com.moa.service.WorkdayService
import com.moa.service.dto.CalendarResponse
import io.swagger.v3.oas.annotations.tags.Tag
Expand All @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api/v1/calendar")
class CalendarController(
private val memberService: MemberService,
private val workdayService: WorkdayService,
) {

Expand All @@ -27,6 +29,7 @@ class CalendarController(
CalendarResponse(
earnings = workdayService.getMonthlyEarnings(member.id, year, month),
schedules = workdayService.getMonthlyWorkdays(member.id, year, month),
joinedAt = memberService.getJoinedAt(member.id),
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class HomeController(
dailyPay = schedule.dailyPay,
type = schedule.type,
status = schedule.status,
events = schedule.events,
clockInTime = schedule.clockInTime,
clockOutTime = schedule.clockOutTime,
)
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/com/moa/service/MemberService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.moa.service.dto.MemberResponse
import com.moa.service.dto.WithdrawalRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate

@Service
class MemberService(
Expand All @@ -28,6 +29,13 @@ class MemberService(
)
}

@Transactional(readOnly = true)
fun getJoinedAt(memberId: Long): LocalDate =
memberRepository.findById(memberId)
.orElseThrow { NotFoundException() }
.createdAt
.toLocalDate()

@Transactional
fun deleteMember(memberId: Long, req: WithdrawalRequest) {
val member = memberRepository.findById(memberId)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/moa/service/dto/CalendarResponse.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.moa.service.dto

import java.time.LocalDate

data class CalendarResponse(
val earnings: MonthlyEarningsResponse,
val schedules: List<WorkdayResponse>,
val joinedAt: LocalDate,
)
2 changes: 2 additions & 0 deletions src/main/kotlin/com/moa/service/dto/HomeResponse.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.moa.service.dto

import com.fasterxml.jackson.annotation.JsonFormat
import com.moa.entity.DailyEventType
import com.moa.entity.DailyWorkScheduleType
import com.moa.entity.DailyWorkStatusType
import java.time.LocalTime
Expand All @@ -12,6 +13,7 @@ data class HomeResponse(
val dailyPay: Int,
val type: DailyWorkScheduleType,
val status: DailyWorkStatusType,
val events: List<DailyEventType> = emptyList(),
@field:JsonFormat(pattern = "HH:mm")
val clockInTime: LocalTime?,
@field:JsonFormat(pattern = "HH:mm")
Expand Down
Loading