именены классы избранных, нужно разоьраться с динамическими запросами
This commit is contained in:
parent
d08574bc53
commit
fd09f7b780
@ -7,6 +7,7 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
|
|
||||||
public class FavoriteDto {
|
public class FavoriteDto {
|
||||||
|
|
||||||
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -6,9 +6,21 @@ import com.example.backend.core.model.BaseEntity;
|
|||||||
import com.example.backend.movies.model.MovieEntity;
|
import com.example.backend.movies.model.MovieEntity;
|
||||||
import com.example.backend.users.model.UserEntity;
|
import com.example.backend.users.model.UserEntity;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "favorites")
|
||||||
public class FavoriteEntity extends BaseEntity {
|
public class FavoriteEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "userId", nullable = false)
|
||||||
private UserEntity user;
|
private UserEntity user;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "movieId", nullable = false)
|
||||||
private MovieEntity movie;
|
private MovieEntity movie;
|
||||||
|
|
||||||
public FavoriteEntity() {
|
public FavoriteEntity() {
|
||||||
@ -16,8 +28,6 @@ public class FavoriteEntity extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FavoriteEntity(Integer id, UserEntity user, MovieEntity movie) {
|
public FavoriteEntity(Integer id, UserEntity user, MovieEntity movie) {
|
||||||
|
|
||||||
super(id);
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.movie = movie;
|
this.movie = movie;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.backend.favorites.repository;
|
package com.example.backend.favorites.repository;
|
||||||
|
|
||||||
import org.springframework.stereotype.Repository;
|
import java.util.Optional;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
import com.example.backend.core.repository.MapRepository;
|
|
||||||
import com.example.backend.favorites.model.FavoriteEntity;
|
import com.example.backend.favorites.model.FavoriteEntity;
|
||||||
|
|
||||||
@Repository
|
public interface FavoriteRepository extends CrudRepository<FavoriteEntity, Integer> {
|
||||||
public class FavoriteRepository extends MapRepository<FavoriteEntity> {
|
Optional<FavoriteEntity> findOneByUserIdAndId(long userId, long id);
|
||||||
|
Optional<FavoriteEntity> findOneByMovieIdAndId(long movieId, long id);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user