Ignore:
Timestamp:
02/07/22 19:57:58 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
ad4243e, c02189f
Parents:
7f36551
Message:

Added genre liking, fixed counter, improved paging, improved searches

Location:
src/main/java/com/wediscussmovies/project/repository
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/repository/GenreRepository.java

    r7f36551 r3c0f9a9  
    44import com.wediscussmovies.project.querymodels.GenreLikes;
    55import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.Modifying;
    67import org.springframework.data.jpa.repository.Query;
     8import org.springframework.data.repository.query.Param;
    79import org.springframework.stereotype.Repository;
    810
    911import javax.transaction.Transactional;
     12import java.sql.Date;
    1013import java.util.List;
    1114
     
    1417     List<Genre> findAllByGenreType(String genre);
    1518
    16      @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreType, count(ug.id.userId)) from Genre g" +
     19     @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreId, g.genreType, count(ug.id.userId)) from Genre g" +
    1720             " left join UserGenres ug on ug.id.genreId = g.genreId" +
    18              " group by g.genreType" +
     21             " group by g.genreId, g.genreType" +
    1922             " order by count(ug.id.userId) desc")
    2023     @Transactional
    2124     List<GenreLikes> findAllWithLikes();
     25
     26     @Modifying
     27     @Query(value = "insert into project.user_genres (user_id,genre_id) values(:user_id,:genre_id)",nativeQuery = true)
     28     @Transactional
     29     void insertInto(@Param("user_id")Integer userId, @Param("genre_id")Integer genreId);
    2230}
  • src/main/java/com/wediscussmovies/project/repository/MovieRepository.java

    r7f36551 r3c0f9a9  
    44import com.wediscussmovies.project.model.Person;
    55import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.Query;
    67import org.springframework.stereotype.Repository;
    78
     
    1314     List<Movie> findAllByDirector(Person director);
    1415     List<Movie> findAllByDirectorIsNull();
     16     @Query(value="select m.movieId from Movie m")
     17     List<Integer> findAllMovieIds();
    1518}
Note: See TracChangeset for help on using the changeset viewer.