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