-
Notifications
You must be signed in to change notification settings - Fork 5
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 #31 from YooJHyun/main
[Feat] Calendar 기능 구현
- Loading branch information
Showing
14 changed files
with
187 additions
and
8 deletions.
There are no files selected for viewing
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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/org/tenten/bittakotlin/calendar/controller/EventCalendarController.kt
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,22 @@ | ||
package org.tenten.bittakotlin.calendar.controller | ||
|
||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.tenten.bittakotlin.calendar.dto.EventCalendarDTO | ||
import org.tenten.bittakotlin.calendar.service.EventCalendarService | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/calendar") | ||
class EventCalendarController( | ||
private val eventCalendarService: EventCalendarService | ||
) { | ||
|
||
@GetMapping("/{profileId}") | ||
fun getCalendar(@PathVariable profileId: Long): ResponseEntity<List<EventCalendarDTO>> { | ||
val events = eventCalendarService.getEventCalendar(profileId) | ||
return ResponseEntity.ok(events) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/org/tenten/bittakotlin/calendar/dto/EventCalendarDTO.kt
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,24 @@ | ||
package org.tenten.bittakotlin.calendar.dto | ||
|
||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
import jakarta.validation.constraints.Min | ||
import jakarta.validation.constraints.NotNull | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "캘린더 DTO", description = "회원의 일정을 확인할 때 사용하는 DTO입니다.") | ||
data class EventCalendarDTO( | ||
@Schema(title = "캘린더 ID (PK)", description = "캘린더의 고유 ID 입니다.", example = "1", minimum = "1") | ||
@field:Min(value = 1, message = "ID는 음수가 될 수 없습니다") | ||
val id: Long? = null, | ||
|
||
@Schema(title = "회원 ID", description = "회원의 고유 ID 입니다.", example = "1", minimum = "1") | ||
@field:Min(value = 1, message = "ID는 음수가 될 수 없습니다") | ||
@field:NotNull(message = "회원의 ID가 필요합니다") | ||
val profileId: Long? = null, | ||
|
||
val startDate: LocalDate? = null, | ||
val endDate: LocalDate? = null, | ||
val auditionDate: LocalDateTime? = null, | ||
val title: String? = null | ||
) |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/org/tenten/bittakotlin/calendar/entity/EventCalendar.kt
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,29 @@ | ||
package org.tenten.bittakotlin.calendar.entity | ||
|
||
import jakarta.persistence.* | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener | ||
import org.tenten.bittakotlin.profile.entity.Profile | ||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
|
||
@Entity | ||
@Table(name = "event_calendar") | ||
@EntityListeners(AuditingEntityListener::class) | ||
data class EventCalendar( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long? = null, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "profileId", nullable = false) | ||
val profile: Profile? = null, | ||
|
||
@Column(nullable = false) | ||
val title: String, | ||
|
||
val startDate: LocalDate? = null, | ||
|
||
val endDate: LocalDate? = null, | ||
|
||
val auditionDate: LocalDateTime? = null | ||
) |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/org/tenten/bittakotlin/calendar/repository/EventCalendarRepository.kt
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,10 @@ | ||
package org.tenten.bittakotlin.calendar.repository | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import org.tenten.bittakotlin.calendar.entity.EventCalendar | ||
|
||
interface EventCalendarRepository : JpaRepository<EventCalendar, Long> { | ||
@Query("SELECT c FROM EventCalendar c WHERE c.profile.id = :profileId") | ||
fun findAllByProfileId(profileId: Long): List<EventCalendar> | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/org/tenten/bittakotlin/calendar/service/EventCalendarService.kt
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,7 @@ | ||
package org.tenten.bittakotlin.calendar.service | ||
|
||
import org.tenten.bittakotlin.calendar.dto.EventCalendarDTO | ||
|
||
interface EventCalendarService { | ||
fun getEventCalendar(profileId: Long): List<EventCalendarDTO> | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/org/tenten/bittakotlin/calendar/service/EventCalendarServiceImpl.kt
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,31 @@ | ||
package org.tenten.bittakotlin.calendar.service | ||
|
||
import org.slf4j.LoggerFactory | ||
import org.springframework.stereotype.Service | ||
import org.tenten.bittakotlin.calendar.dto.EventCalendarDTO | ||
import org.tenten.bittakotlin.calendar.entity.EventCalendar | ||
import org.tenten.bittakotlin.calendar.repository.EventCalendarRepository | ||
|
||
@Service | ||
class EventCalendarServiceImpl( | ||
private val eventCalendarRepository: EventCalendarRepository | ||
) : EventCalendarService { | ||
|
||
private val logger = LoggerFactory.getLogger(EventCalendarServiceImpl::class.java) | ||
|
||
override fun getEventCalendar(profileId: Long): List<EventCalendarDTO> { | ||
val events = eventCalendarRepository.findAllByProfileId(profileId) | ||
return events.map { entityToDto(it) } | ||
} | ||
|
||
private fun entityToDto(event: EventCalendar): EventCalendarDTO { | ||
return EventCalendarDTO( | ||
id = event.id, | ||
profileId = event.profile!!.id, | ||
startDate = event.startDate, | ||
endDate = event.endDate, | ||
title = event.title, | ||
auditionDate = event.auditionDate | ||
) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,4 +14,3 @@ class JobPostViewController { | |
} | ||
} | ||
|
||
|
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