Ignore:
Timestamp:
02/04/22 23:22:13 (3 years ago)
Author:
Test <matonikolov77@…>
Branches:
main
Children:
5b447b0
Parents:
3ded84d
Message:

Added CRUD for movies,persons,discussion,replies,genres
Added ajaxcalls

Location:
src/main/java/com/wediscussmovies/project/repository
Files:
6 edited

Legend:

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

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
     3import com.wediscussmovies.project.model.Discussion;
     4import com.wediscussmovies.project.model.Movie;
     5import com.wediscussmovies.project.model.Person;
    36import org.springframework.data.jpa.repository.JpaRepository;
    47import org.springframework.stereotype.Repository;
    58
    69import java.util.List;
    7 import com.wediscussmovies.project.model.*;
    810
    911@Repository
    1012public interface DiscussionRepository extends JpaRepository<Discussion, Integer> {
    11     public List<Discussion> findAllByTitleLike(String title);
     13     List<Discussion> findAllByTitleLike(String title);
     14     List<Discussion> findAllByMovie(Movie movie);
     15     List<Discussion> findAllByPerson (Person person);
    1216}
  • src/main/java/com/wediscussmovies/project/repository/GenreRepository.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
    3 import com.wediscussmovies.project.model.*;
     3import com.wediscussmovies.project.model.Genre;
     4import com.wediscussmovies.project.querymodels.GenreLikes;
    45import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.Query;
    57import org.springframework.stereotype.Repository;
    68
     9import javax.transaction.Transactional;
    710import java.util.List;
    811
    912@Repository
    1013public interface GenreRepository extends JpaRepository<Genre, Integer> {
    11     public List<Genre> findAllByGenreType(String genre);
     14     List<Genre> findAllByGenreType(String genre);
     15
     16     @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreType, count(ug.id.userId)) from Genre g" +
     17             " left join UserGenres ug on ug.id.genreId = g.genreId" +
     18             " group by g.genreType" +
     19             " order by count(ug.id.userId) desc")
     20     @Transactional
     21     List<GenreLikes> findAllWithLikes();
    1222}
  • src/main/java/com/wediscussmovies/project/repository/MovieRepository.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
     3import com.wediscussmovies.project.model.Movie;
     4import com.wediscussmovies.project.model.Person;
    35import org.springframework.data.jpa.repository.JpaRepository;
    46import org.springframework.stereotype.Repository;
    57
    68import java.util.List;
    7 import com.wediscussmovies.project.model.*;
    89
    910@Repository
    1011public interface MovieRepository extends JpaRepository<Movie, Integer> {
    11     public List<Movie> findAllByTitleLike(String Title);
     12     List<Movie> findAllByTitleLike(String Title);
     13     List<Movie> findAllByDirector(Person director);
     14     List<Movie> findAllByDirectorIsNull();
    1215}
  • src/main/java/com/wediscussmovies/project/repository/PersonRepository.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
    3 import com.wediscussmovies.project.model.*;
    4 import com.wediscussmovies.project.model.enumerations.PersonType;
     3import com.wediscussmovies.project.model.Person;
    54import org.springframework.data.jpa.repository.JpaRepository;
    65import org.springframework.stereotype.Repository;
    76
    87import java.util.List;
    9 import java.util.Optional;
    108
    119@Repository
    1210public interface PersonRepository extends JpaRepository<Person, Integer> {
    13     public List<Person> findAllByType(Character type);
    14     public List<Person> findAllByTypeAndNameLike(Character type, String name);
    15     public List<Person> findAllByTypeAndSurnameLike(Character type, String surname);
    16     public Optional<Person> findPersonByPersonIdAndType(Integer id, Character type);
     11     List<Person> findAllByType(Character type);
     12     List<Person> findAllByTypeAndNameLike(Character type, String name);
     13     List<Person> findAllByTypeAndSurnameLike(Character type, String surname);
     14    // Optional<Person> findPersonByPersonIdAndType(Integer id, Character type);
     15     List<Person> findAllByTypeAndNameLikeOrSurnameLike(Character type,String name, String surname);
    1716}
  • src/main/java/com/wediscussmovies/project/repository/ReplyRepository.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
     3import com.wediscussmovies.project.model.Discussion;
     4import com.wediscussmovies.project.model.Reply;
     5import com.wediscussmovies.project.model.primarykeys.ReplyPK;
    36import org.springframework.data.jpa.repository.JpaRepository;
     7import org.springframework.data.jpa.repository.Modifying;
     8import org.springframework.data.jpa.repository.Query;
     9import org.springframework.data.repository.query.Param;
    410import org.springframework.stereotype.Repository;
    5 import com.wediscussmovies.project.model.*;
     11
     12import javax.transaction.Transactional;
     13import java.sql.Date;
     14import java.util.List;
    615
    716
    817@Repository
    9 public interface ReplyRepository extends JpaRepository<Reply, Integer> {
     18public interface ReplyRepository extends JpaRepository<Reply, ReplyPK> {
     19    List<Reply> findAllByDiscussion(Discussion discussion);
     20
     21    @Modifying
     22    @Query(value = "insert into project.replies (text,date,user_id,discussion_id) values(:text,:date,:user_id,:discussion_id)",nativeQuery = true)
     23    @Transactional
     24    void insertInto(@Param("text") String text, @Param("date")Date date,
     25                    @Param("user_id")Integer userId,@Param("discussion_id")Integer discussionId);
    1026}
  • src/main/java/com/wediscussmovies/project/repository/UserRepository.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.repository;
    22
    3 import com.wediscussmovies.project.model.*;
     3import com.wediscussmovies.project.model.User;
    44import org.springframework.data.jpa.repository.JpaRepository;
    55import org.springframework.stereotype.Repository;
     
    99@Repository
    1010public interface UserRepository extends JpaRepository<User, Integer> {
    11     public Optional<User> findByEmailAndPassword(String email, String password);
    12     public Optional<User> findByUsernameAndPassword(String email, String password);
    13     public Optional<User> findByUsername(String username);
    14     public Optional<User> findByEmail(String email);
     11     Optional<User> findByUsername(String username);
    1512}
Note: See TracChangeset for help on using the changeset viewer.