Ignore:
Timestamp:
05/06/25 00:44:02 (2 weeks ago)
Author:
Aleksandar Panovski <apano77@…>
Branches:
main
Children:
e48199a
Parents:
142c0f8
Message:

Normalization needed to continue, till here done

Location:
src/main/java/com/example/rezevirajmasa/demo/service/impl
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationHistoryServiceImpl.java

    r142c0f8 rb67dfd3  
    11package com.example.rezevirajmasa.demo.service.impl;
    22
    3 import com.example.rezevirajmasa.demo.model.Customer;
    43import com.example.rezevirajmasa.demo.model.Reservation;
    54import com.example.rezevirajmasa.demo.model.Restaurant;
  • src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java

    r142c0f8 rb67dfd3  
    22
    33import com.example.rezevirajmasa.demo.dto.ReservationDTO;
    4 import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
    5 import com.example.rezevirajmasa.demo.dto.UserDto;
    64import com.example.rezevirajmasa.demo.mappers.UserMapper;
    75import com.example.rezevirajmasa.demo.model.*;
    86import com.example.rezevirajmasa.demo.model.exceptions.InvalidReservationException;
    97import com.example.rezevirajmasa.demo.model.exceptions.InvalidReservationIdException;
    10 import com.example.rezevirajmasa.demo.repository.CustomerRepository;
    118import com.example.rezevirajmasa.demo.repository.ReservationRepository;
    12 import com.example.rezevirajmasa.demo.repository.RestaurantRepository;
    139import com.example.rezevirajmasa.demo.repository.TableRepository;
    1410import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
    1511import com.example.rezevirajmasa.demo.service.ReservationService;
    16 import com.example.rezevirajmasa.demo.service.RestaurantService;
    1712import com.example.rezevirajmasa.demo.service.UserService;
    1813import org.springframework.beans.factory.annotation.Autowired;
    19 import org.springframework.cglib.core.Local;
    20 import org.springframework.security.core.Authentication;
    21 import org.springframework.security.core.annotation.AuthenticationPrincipal;
    22 import org.springframework.security.core.context.SecurityContextHolder;
    23 import org.springframework.security.core.userdetails.UserDetails;
    2414import org.springframework.stereotype.Service;
    25 import org.springframework.web.bind.annotation.RequestBody;
    26 
    27 import javax.swing.text.html.Option;
    28 import java.math.BigDecimal;
     15
    2916import java.time.LocalDateTime;
    30 import java.time.LocalTime;
    31 import java.time.format.DateTimeFormatter;
    3217import java.util.ArrayList;
    3318import java.util.List;
     
    9176            reservation.setSpecialRequests(reservationDTO.getSpecialRequests());
    9277            reservation.setPartySize(reservationDTO.getPartySize());
    93             reservation.setStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : "Pending");
     78            reservation.setReservationStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : "Pending");
    9479            reservation.setPaymentStatus(reservationDTO.getPaymentStatus() != null ? reservationDTO.getPaymentStatus() : "Unpaid");
    9580            reservation.setUser(user);
     
    9984            for (PreorderedItem dtoItem : reservationDTO.getPreOrderedItems()) {
    10085                PreorderedItem item = new PreorderedItem();
    101                 item.setName(dtoItem.getName());
     86                item.setPreorderedItemName(dtoItem.getPreorderedItemName());
    10287                item.setQuantity(dtoItem.getQuantity());
    10388                item.setPrice(dtoItem.getPrice());
     
    144129        existingReservation.setPartySize(reservationDTO.getPartySize());
    145130        existingReservation.setSpecialRequests(reservationDTO.getSpecialRequests());
    146         existingReservation.setStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : existingReservation.getStatus());
     131        existingReservation.setReservationStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : existingReservation.getReservationStatus());
    147132        existingReservation.setPaymentStatus(reservationDTO.getPaymentStatus() != null ? reservationDTO.getPaymentStatus() : existingReservation.getPaymentStatus());
    148133
  • src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java

    r142c0f8 rb67dfd3  
    104104                TableEntity table = new TableEntity();
    105105                table.setCapacity(tableCapacities.get(i));
    106                 table.setLocation(tableLocations.get(i));
     106                table.setTableLocation(tableLocations.get(i));
    107107                table.setSmokingArea(tableSmokingAreas.get(i).equalsIgnoreCase("on"));
    108108                table.setDescription(tableDescriptions.get(i));
  • src/main/java/com/example/rezevirajmasa/demo/service/impl/TableServiceImpl.java

    r142c0f8 rb67dfd3  
    7676            TableEntity table = new TableEntity();
    7777            table.setCapacity(tableCapacities.get(i));
    78             table.setLocation(tableLocations.get(i));
     78            table.setTableLocation(tableLocations.get(i));
    7979            table.setSmokingArea(Boolean.valueOf(tableSmokingAreas.get(i)));
    8080            table.setDescription(tableDescriptions.get(i));
  • src/main/java/com/example/rezevirajmasa/demo/service/impl/UserServiceImpl.java

    r142c0f8 rb67dfd3  
    1616import org.openqa.selenium.InvalidArgumentException;
    1717import org.springframework.http.HttpStatus;
     18import org.springframework.security.core.userdetails.UserDetails;
     19import org.springframework.security.core.userdetails.UserDetailsService;
     20import org.springframework.security.core.userdetails.UsernameNotFoundException;
    1821import org.springframework.security.crypto.password.PasswordEncoder;
    1922import org.springframework.stereotype.Service;
     
    2528@RequiredArgsConstructor
    2629@Service
    27 public class UserServiceImpl implements UserService {
     30public class UserServiceImpl implements UserService, UserDetailsService {
    2831    private final UserRepository userRepository;
    2932    private final UserMapperImpl userMapper;
     
    7881        return userRepository.findById(userId).orElseThrow(()->new InvalidArgumentException("Invalid user Id"));
    7982    }
     83
     84    @Override
     85    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
     86        User user = userRepository.findByEmail(email)
     87                .orElseThrow(()-> new UsernameNotFoundException("User not found"));
     88        return org.springframework.security.core.userdetails.User
     89                .withUsername(user.getEmail())
     90                .password(user.getPassword())
     91                .authorities(user.getRole().name()) // adjust if needed
     92                .build();
     93    }
    8094}
Note: See TracChangeset for help on using the changeset viewer.