Skip to content

Commit

Permalink
✨ Add: Webcam API logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Oct 3, 2024
1 parent 790e993 commit 3d83e1c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/kotlin/nexters/weski/webcam/Webcam.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package nexters.weski.webcam

import jakarta.persistence.*
import nexters.weski.common.BaseEntity
import nexters.weski.ski_resort.SkiResort

@Entity
@Table(name = "webcams")
data class Webcam(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0,

val name: String,
val number: Int,
val description: String?,
val url: String,

@ManyToOne
@JoinColumn(name = "resort_id")
val skiResort: SkiResort
) : BaseEntity()
19 changes: 19 additions & 0 deletions src/main/kotlin/nexters/weski/webcam/WebcamDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package nexters.weski.webcam

data class WebcamDto(
val name: String,
val number: Int,
val description: String?,
val url: String?
) {
companion object {
fun fromEntity(entity: Webcam): WebcamDto {
return WebcamDto(
name = entity.name,
number = entity.number,
description = entity.description,
url = entity.url
)
}
}
}
7 changes: 7 additions & 0 deletions src/main/kotlin/nexters/weski/webcam/WebcamRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package nexters.weski.webcam

import org.springframework.data.jpa.repository.JpaRepository

interface WebcamRepository : JpaRepository<Webcam, Long> {
fun findAllBySkiResortResortId(resortId: Long): List<Webcam>
}

0 comments on commit 3d83e1c

Please sign in to comment.