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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java

    r3ded84d re0ef1b1  
    11package com.wediscussmovies.project.service.impl;
    22
    3 import com.wediscussmovies.project.model.*;
     3import com.wediscussmovies.project.model.exception.GenreNotExistException;
     4import com.wediscussmovies.project.querymodels.GenreLikes;
    45import com.wediscussmovies.project.repository.GenreRepository;
     6import com.wediscussmovies.project.model.Genre;
    57import com.wediscussmovies.project.service.GenreService;
    68import org.springframework.stereotype.Service;
    79
    810import java.util.List;
    9 import java.util.Optional;
    1011
    1112@Service
     
    1819
    1920    @Override
    20     public Optional<Genre> findById(Integer id) {
    21         return genreRepository.findById(id);
     21    public Genre findById(Integer id) {
     22        return this.genreRepository.findById(id).orElseThrow(() -> new GenreNotExistException(id));
    2223    }
    2324
    2425    @Override
    2526    public List<Genre> findAllByType(String genre) {
    26         return genreRepository.findAllByGenreType(genre);
     27        return this.genreRepository.findAllByGenreType(genre);
    2728    }
    2829
     
    3031    public Genre save(String genreName) {
    3132       Genre genre = new Genre(genreName);
    32         return genreRepository.save(genre);
     33        return this.genreRepository.save(genre);
     34    }
     35
     36    @Override
     37    public List<GenreLikes> findAllWithLikes() {
     38        return this.genreRepository.findAllWithLikes();
    3339    }
    3440
    3541    @Override
    3642    public List<Genre> findAll() {
    37         return genreRepository.findAll();
     43        return this.genreRepository.findAll();
    3844    }
    3945}
Note: See TracChangeset for help on using the changeset viewer.