теперь должно компилироваться
This commit is contained in:
@@ -54,7 +54,13 @@ class MovieNightService(
|
|||||||
println(filmStarWars)
|
println(filmStarWars)
|
||||||
|
|
||||||
println("Редактирование фильма ${filmSpiderMan.title}")
|
println("Редактирование фильма ${filmSpiderMan.title}")
|
||||||
filmSpiderMan = filmService.edit(filmSpiderMan.id, EditFilmCommand("Delayed", "-"))
|
filmSpiderMan = filmService.edit(
|
||||||
|
id = filmSpiderMan.id, // ID имеет тип UUID
|
||||||
|
command = EditFilmCommand(
|
||||||
|
title = "Delayed",
|
||||||
|
description = "-"
|
||||||
|
)
|
||||||
|
)
|
||||||
println(filmSpiderMan)
|
println(filmSpiderMan)
|
||||||
|
|
||||||
println("Редактирование пользователя ${userAboba.name}")
|
println("Редактирование пользователя ${userAboba.name}")
|
||||||
|
|||||||
+13
-12
@@ -3,6 +3,7 @@ package com.project.movienight.adapters.persistence
|
|||||||
import com.project.movienight.domain.model.FilmLibrary
|
import com.project.movienight.domain.model.FilmLibrary
|
||||||
import org.springframework.jdbc.core.JdbcTemplate
|
import org.springframework.jdbc.core.JdbcTemplate
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
||||||
@@ -12,9 +13,9 @@ class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM favorites WHERE id = ?",
|
"SELECT * FROM favorites WHERE id = ?",
|
||||||
{ rs, _ ->
|
{ rs, _ ->
|
||||||
FilmLibrary(
|
FilmLibrary(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
userId = rs.getInt("userid"),
|
userId = UUID.fromString(rs.getString("userid")),
|
||||||
filmId = rs.getInt("film_id"),
|
filmId = UUID.fromString(rs.getString("film_id")),
|
||||||
comment = rs.getString("comment"),
|
comment = rs.getString("comment"),
|
||||||
isViewed = rs.getBoolean("is_viewed"),
|
isViewed = rs.getBoolean("is_viewed"),
|
||||||
)
|
)
|
||||||
@@ -27,9 +28,9 @@ class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM favorites WHERE userid = ?",
|
"SELECT * FROM favorites WHERE userid = ?",
|
||||||
{ rs, _ ->
|
{ rs, _ ->
|
||||||
FilmLibrary(
|
FilmLibrary(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
userId = rs.getInt("userid"),
|
userId = UUID.fromString(rs.getString("userid")),
|
||||||
filmId = rs.getInt("film_id"),
|
filmId = UUID.fromString(rs.getString("film_id")),
|
||||||
comment = rs.getString("comment"),
|
comment = rs.getString("comment"),
|
||||||
isViewed = rs.getBoolean("is_viewed"),
|
isViewed = rs.getBoolean("is_viewed"),
|
||||||
)
|
)
|
||||||
@@ -42,9 +43,9 @@ class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM favorites"
|
"SELECT * FROM favorites"
|
||||||
) { rs, _ ->
|
) { rs, _ ->
|
||||||
FilmLibrary(
|
FilmLibrary(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
userId = rs.getInt("userid"),
|
userId = UUID.fromString(rs.getString("userid")),
|
||||||
filmId = rs.getInt("film_id"),
|
filmId = UUID.fromString(rs.getString("film_id")),
|
||||||
comment = rs.getString("comment"),
|
comment = rs.getString("comment"),
|
||||||
isViewed = rs.getBoolean("is_viewed"),
|
isViewed = rs.getBoolean("is_viewed"),
|
||||||
)
|
)
|
||||||
@@ -55,9 +56,9 @@ class FilmLibraryRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM favorites ORDER BY $sortBy LIMIT ?",
|
"SELECT * FROM favorites ORDER BY $sortBy LIMIT ?",
|
||||||
{ rs, _ ->
|
{ rs, _ ->
|
||||||
FilmLibrary(
|
FilmLibrary(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
userId = rs.getInt("userid"),
|
userId = UUID.fromString(rs.getString("userid")),
|
||||||
filmId = rs.getInt("film_id"),
|
filmId = UUID.fromString(rs.getString("film_id")),
|
||||||
comment = rs.getString("comment"),
|
comment = rs.getString("comment"),
|
||||||
isViewed = rs.getBoolean("is_viewed"),
|
isViewed = rs.getBoolean("is_viewed"),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.project.movienight.domain.model.Film
|
|||||||
import org.springframework.jdbc.core.JdbcTemplate
|
import org.springframework.jdbc.core.JdbcTemplate
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class FilmRepository(private val jdbc: JdbcTemplate) {
|
class FilmRepository(private val jdbc: JdbcTemplate) {
|
||||||
@@ -13,10 +14,9 @@ class FilmRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM films WHERE id = ?",
|
"SELECT * FROM films WHERE id = ?",
|
||||||
{ rs, _ ->
|
{ rs, _ ->
|
||||||
Film(
|
Film(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
title = rs.getString("title"),
|
title = rs.getString("title"),
|
||||||
genreId = rs.getInt("genre_id"),
|
description = rs.getString("description"),
|
||||||
issueDate = rs.getDate("issue_date")?.toLocalDate(),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
id
|
id
|
||||||
@@ -27,10 +27,9 @@ class FilmRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM films"
|
"SELECT * FROM films"
|
||||||
) { rs, _ ->
|
) { rs, _ ->
|
||||||
Film(
|
Film(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
title = rs.getString("title"),
|
title = rs.getString("title"),
|
||||||
genreId = rs.getInt("genre_id"),
|
description = rs.getString("description"),
|
||||||
issueDate = rs.getDate("issue_date")?.toLocalDate(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,10 +38,9 @@ class FilmRepository(private val jdbc: JdbcTemplate) {
|
|||||||
"SELECT * FROM films ORDER BY $sortBy LIMIT ?",
|
"SELECT * FROM films ORDER BY $sortBy LIMIT ?",
|
||||||
{ rs, _ ->
|
{ rs, _ ->
|
||||||
Film(
|
Film(
|
||||||
id = rs.getInt("id"),
|
id = UUID.fromString(rs.getString("id")),
|
||||||
title = rs.getString("title"),
|
title = rs.getString("title"),
|
||||||
genreId = rs.getInt("genre_id"),
|
description = rs.getString("description"),
|
||||||
issueDate = rs.getDate("issue_date")?.toLocalDate(),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
limit
|
limit
|
||||||
@@ -56,8 +54,8 @@ class FilmRepository(private val jdbc: JdbcTemplate) {
|
|||||||
ON CONFLICT (id) DO UPDATE
|
ON CONFLICT (id) DO UPDATE
|
||||||
SET title = ?, genre_id = ?, issue_date = ?
|
SET title = ?, genre_id = ?, issue_date = ?
|
||||||
""",
|
""",
|
||||||
film.title, film.genreId, film.issueDate,
|
film.title,
|
||||||
film.title, film.genreId, film.issueDate
|
film.title,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.project.movienight.domain.model
|
package com.project.movienight.domain.model
|
||||||
|
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
data class Film(
|
data class Film(
|
||||||
val id: Int,
|
val id: UUID,
|
||||||
val title: String,
|
val title: String,
|
||||||
val genreId: Int,
|
val description: String,
|
||||||
val issueDate: LocalDate?,
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.project.movienight.domain.model
|
package com.project.movienight.domain.model
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
data class FilmLibrary(
|
data class FilmLibrary(
|
||||||
val id: Int,
|
val id: UUID,
|
||||||
val userId: Int,
|
val userId: UUID,
|
||||||
val filmId: Int,
|
val filmId: UUID,
|
||||||
val comment: String?,
|
val comment: String?,
|
||||||
val isViewed: Boolean,
|
val isViewed: Boolean,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user