Ignore:
Timestamp:
08/24/23 02:28:14 (15 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
bcb4acc
Parents:
40935d3
Message:

fix

Location:
src/main/java/com/example/moviezone/service
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/service/CustomerService.java

    r40935d3 r1e7126f  
    77import java.util.Optional;
    88
    9 @Repository
    109public interface CustomerService {
    1110    List<Customer> findAllCustomers();
  • src/main/java/com/example/moviezone/service/DiscountService.java

    r40935d3 r1e7126f  
    1 package com.example.moviezone.service;public interface DiscountService {
     1package com.example.moviezone.service;
     2
     3import com.example.moviezone.model.Discount;
     4import org.springframework.stereotype.Repository;
     5
     6import java.time.LocalDate;
     7import java.util.List;
     8
     9
     10public interface DiscountService {
     11    Discount save(String code, String type, LocalDate validity, Integer percent);
     12    List<Discount> getValidDiscounts();
    213}
  • src/main/java/com/example/moviezone/service/Impl/DiscountServiceImpl.java

    r40935d3 r1e7126f  
    1 package com.example.moviezone.service.Impl;public class DiscountServiceImpl {
     1package com.example.moviezone.service.Impl;
     2
     3import com.example.moviezone.model.Discount;
     4import com.example.moviezone.repository.DiscountRepository;
     5import com.example.moviezone.service.DiscountService;
     6import org.springframework.stereotype.Service;
     7
     8import java.time.LocalDate;
     9import java.util.List;
     10
     11@Service
     12public class DiscountServiceImpl implements DiscountService {
     13    private final DiscountRepository discountRepository;
     14
     15    public DiscountServiceImpl(DiscountRepository discountRepository) {
     16        this.discountRepository = discountRepository;
     17    }
     18
     19    @Override
     20    public Discount save(String code, String type, LocalDate validity, Integer percent) {
     21        return discountRepository.save(new Discount(validity,code,type,percent));
     22    }
     23
     24    @Override
     25    public List<Discount> getValidDiscounts() {
     26        return discountRepository.getValidDiscounts();
     27    }
    228}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    r40935d3 r1e7126f  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.Discount;
    34import com.example.moviezone.model.Film;
    45import com.example.moviezone.model.Projection;
     6import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
     7import com.example.moviezone.repository.DiscountRepository;
    58import com.example.moviezone.repository.FilmRepository;
     9import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
    610import com.example.moviezone.repository.ProjectionRepository;
    711import com.example.moviezone.service.ProjectionService;
     
    913
    1014import java.time.LocalDate;
     15import java.time.LocalDateTime;
    1116import java.util.List;
    1217
     
    1419public class ProjectionServiceImpl implements ProjectionService {
    1520    private final ProjectionRepository projectionRepository;
     21    private final ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository;
    1622    private final FilmRepository filmRepository;
    17     public ProjectionServiceImpl(ProjectionRepository projectionRepository, FilmRepository filmRepository) {
     23    private final DiscountRepository discountRepository;
     24    public ProjectionServiceImpl(ProjectionRepository projectionRepository, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository, FilmRepository filmRepository, DiscountRepository discountRepository) {
    1825        this.projectionRepository = projectionRepository;
     26        this.projectionIsPlayedInRoomRepository = projectionIsPlayedInRoomRepository;
    1927        this.filmRepository = filmRepository;
     28        this.discountRepository = discountRepository;
    2029    }
    2130
     
    3140
    3241    @Override
     42    public List<Projection> getProjectionsNow() {
     43        return projectionRepository.getProjectionsNow();
     44    }
     45
     46    @Override
    3347    public Projection findById(Integer id_projection) {
    3448        return projectionRepository.findById(id_projection).orElseThrow(RuntimeException::new);
     
    3751
    3852    @Override
    39     public Projection save(LocalDate date_time_start, LocalDate date_time_end, String type_of_technology, Integer id_film) {
     53    public Projection save(LocalDateTime date_time_start, LocalDateTime date_time_end, String type_of_technology, Integer id_film, Integer id_room, Integer id_discount) {
    4054       Film film=filmRepository.findById(id_film).orElseThrow(RuntimeException::new);
    41         return projectionRepository.save(new Projection(date_time_start,type_of_technology,date_time_end,film));
     55        Discount discount = discountRepository.findById(id_discount).orElseThrow(RuntimeException::new);
     56        Projection projection =  projectionRepository.save(new Projection(date_time_start,type_of_technology,date_time_end,film,discount));
     57        projectionIsPlayedInRoomRepository.save(new ProjectionIsPlayedInRoom(projection.getId_projection(),id_room));
     58        return projection;
    4259    }
    4360
  • src/main/java/com/example/moviezone/service/Impl/SeatServiceImpl.java

    r40935d3 r1e7126f  
    11package com.example.moviezone.service.Impl;
    22
    3 import com.example.moviezone.model.Category;
    4 import com.example.moviezone.model.Projection_Room;
    5 import com.example.moviezone.model.Seat;
    6 import com.example.moviezone.model.Ticket;
     3import com.example.moviezone.model.*;
    74import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
    85import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
     
    4340
    4441    @Override
    45     public List<Seat> findAllByRoomAndCategory(Projection_Room projectionRoom, Category category) {
     42    public List<Seat> findAllByRoomAndCategory(Projection projection, Projection_Room projectionRoom, Category category) {
    4643        List<Ticket> tickets=ticketService.findAllTickets();
    4744        List<Seat> seats=seatRepository.findAllByCategoryAndProjection(category,projectionRoom);
    48         List<Seat> s=new ArrayList<>();
    49         List<Projection_Room> projection_rooms=new ArrayList<>();
     45
    5046        for (int i = 0; i < tickets.size(); i++) {
    51             List<ProjectionIsPlayedInRoom> projectionIsPlayedInRooms= projectionIsPlayedInRoomRepository.findAllByProjectionId(tickets.get(i).getProjection().getId_projection());
    52             for (int j = 0; j < projectionIsPlayedInRooms.size(); j++) {
    53                 projection_rooms.add(projection_roomRepository.getById(projectionIsPlayedInRooms.get(j).getIdroom()));
     47            if(tickets.get(i).getProjection()==projection){
     48                if(seats.contains(tickets.get(i).getSeat())){
     49                    seats.remove(tickets.get(i).getSeat());
     50                }
    5451            }
    5552        }
    56         int f=0;
    57         for (int i = 0; i < seats.size(); i++) {
    58             for (int j = 0; j < tickets.size(); j++) {
    59                 if(seats.get(i).getId_seat().equals(tickets.get(j).getSeat().getId_seat())){
    60                     for (int k = 0; k < projection_rooms.size(); k++) {
    61                         if(seats.get(i).getProjection().getId_room().equals(projection_rooms.get(k).getId_room()))
    62                             f=1;
    63                     }
    64                 }
    65 
    66             }
    67 
    68             if(f==0){
    69                 s.add(seats.get(i));
    70             }
    71             f=0;
    72         }
    73         return s;
     53        return seats;
    7454    }
    7555
  • src/main/java/com/example/moviezone/service/Impl/TicketServiceImpl.java

    r40935d3 r1e7126f  
    4848        return ticketRepository.getPriceForTicket(id);
    4949    }
     50
     51    @Override
     52    public void delete(int id) {
     53        ticketRepository.deleteById(id);
     54    }
    5055}
  • src/main/java/com/example/moviezone/service/ProjectionService.java

    r40935d3 r1e7126f  
    55
    66import java.time.LocalDate;
     7import java.time.LocalDateTime;
    78import java.util.List;
    89
     
    1011    List<Projection> findAllProjections();
    1112    List<Projection> getProjectionsForFilms(int id);
     13    List<Projection> getProjectionsNow();
    1214    Projection findById(Integer id_projection);
    13 Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film );
     15    Projection save(LocalDateTime date_time_start, LocalDateTime date_time_end, String type_of_technology, Integer id_film, Integer id_room, Integer id_discount);
    1416}
  • src/main/java/com/example/moviezone/service/SeatService.java

    r40935d3 r1e7126f  
    22
    33import com.example.moviezone.model.Category;
     4import com.example.moviezone.model.Projection;
    45import com.example.moviezone.model.Projection_Room;
    56import com.example.moviezone.model.Seat;
     
    1112    List<Seat> findAllSeats();
    1213    List<Seat> findAllByProjection_Room(Projection_Room projection_room);
    13     List<Seat> findAllByRoomAndCategory(Projection_Room projectionRoom, Category category);
     14    List<Seat> findAllByRoomAndCategory(Projection projection, Projection_Room projectionRoom, Category category);
    1415    Optional<Seat> getSeatById(int id);
    1516}
  • src/main/java/com/example/moviezone/service/TicketService.java

    r40935d3 r1e7126f  
    1313    Ticket save(long price,Customer customer);
    1414    Integer priceForTicket(int id);
     15    void delete(int id);
    1516}
Note: See TracChangeset for help on using the changeset viewer.