Index: src/main/java/com/example/fooddeliverysystem/FooddeliverysystemApplication.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/FooddeliverysystemApplication.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/FooddeliverysystemApplication.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,19 @@
+package com.example.fooddeliverysystem;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+@SpringBootApplication
+public class FooddeliverysystemApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(FooddeliverysystemApplication.class, args);
+	}
+	@Bean
+	public PasswordEncoder passwordEncoder(){
+		return new BCryptPasswordEncoder();
+	}
+}
Index: src/main/java/com/example/fooddeliverysystem/configuration/UsernameAndPasswordAuthProvider.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/configuration/UsernameAndPasswordAuthProvider.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/configuration/UsernameAndPasswordAuthProvider.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,42 @@
+package com.example.fooddeliverysystem.configuration;
+
+import com.example.fooddeliverysystem.service.UserService;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UsernameAndPasswordAuthProvider implements AuthenticationProvider {
+
+
+    private final UserService userService;
+    private final PasswordEncoder passwordEncoder;
+
+    public UsernameAndPasswordAuthProvider(UserService userService, PasswordEncoder passwordEncoder) {
+        this.userService = userService;
+        this.passwordEncoder = passwordEncoder;
+    }
+
+    @Override
+    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
+        String username = authentication.getName();
+        String password = authentication.getCredentials().toString();
+
+        UserDetails userDetails = this.userService.loadUserByUsername(username);
+        if (!passwordEncoder.matches(password, userDetails.getPassword())) {
+            throw new BadCredentialsException("Password is incorrect!");
+        }
+
+        return new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
+    }
+
+    @Override
+    public boolean supports(Class<?> authentication) {
+        return authentication.equals(UsernamePasswordAuthenticationToken.class);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/configuration/WebSecurityConfiguration.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/configuration/WebSecurityConfiguration.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/configuration/WebSecurityConfiguration.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,58 @@
+package com.example.fooddeliverysystem.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
+
+
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfiguration {
+
+    private final PasswordEncoder passwordEncoder;
+    private final UsernameAndPasswordAuthProvider usernameAndPasswordAuthProvider;
+
+    public WebSecurityConfiguration(PasswordEncoder passwordEncoder, UsernameAndPasswordAuthProvider usernameAndPasswordAuthProvider) {
+        this.passwordEncoder = passwordEncoder;
+        this.usernameAndPasswordAuthProvider = usernameAndPasswordAuthProvider;
+    }
+
+    @Bean
+    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+        http.csrf()
+                .disable()
+                .authorizeHttpRequests()
+                .requestMatchers("/salePlaces").hasAnyRole("ADMIN", "CONSUMER")
+                .requestMatchers("/checkOrderStatus").hasAnyRole("ADMIN", "CONSUMER")
+                .requestMatchers("/salePlace/Orders").hasAnyRole("ADMIN", "SALEPLACEEMPLOYEE")
+                .requestMatchers("/salePlace/**").hasAnyRole("ADMIN", "CONSUMER")
+                .requestMatchers("/checkOrderStatus").hasAnyRole("ADMIN", "CONSUMER")
+                .requestMatchers("/deliveryOrders").hasAnyRole("ADMIN", "DELIVER")
+                .requestMatchers("/takeOrder/*").hasAnyRole("ADMIN", "DELIVER")
+                .requestMatchers("/showOrderDeliverer").hasAnyRole("ADMIN", "DELIVER")
+                .requestMatchers("/orderPayment/*").hasAnyRole("ADMIN", "DELIVER")
+                .requestMatchers("/reports/**").hasRole("ADMIN")
+                .requestMatchers("/images/**","/home","/").permitAll()
+                .anyRequest()
+                .authenticated()
+                .and()
+                .formLogin()
+                .permitAll()
+                .failureUrl("/login?error=BadCredentials")
+                .defaultSuccessUrl("/home", true)
+                .and()
+                .logout()
+                .logoutUrl("/logout")
+                .clearAuthentication(true)
+                .invalidateHttpSession(true)
+                .deleteCookies("JSESSIONID")
+                .logoutSuccessUrl("/home");
+
+
+        return http.build();
+
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/exceptions/BadCredentialsException.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/exceptions/BadCredentialsException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/exceptions/BadCredentialsException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,8 @@
+package com.example.fooddeliverysystem.exceptions;
+
+public class BadCredentialsException extends Exception{
+
+    public BadCredentialsException(String message) {
+        super(message);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/exceptions/FoodItemNotFoundException.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/exceptions/FoodItemNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/exceptions/FoodItemNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,8 @@
+package com.example.fooddeliverysystem.exceptions;
+
+public class FoodItemNotFoundException extends Exception{
+
+    public FoodItemNotFoundException(String message){
+        super(message);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/exceptions/OrderNotFoundException.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/exceptions/OrderNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/exceptions/OrderNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,8 @@
+package com.example.fooddeliverysystem.exceptions;
+
+public class OrderNotFoundException extends Exception{
+
+    public OrderNotFoundException(String message) {
+        super(message);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/exceptions/SalePlaceNotFoundException.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/exceptions/SalePlaceNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/exceptions/SalePlaceNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,11 @@
+package com.example.fooddeliverysystem.exceptions;
+
+
+import com.example.fooddeliverysystem.repository.SalePlaceRepository;
+
+public class SalePlaceNotFoundException extends Exception{
+
+    public SalePlaceNotFoundException(String message){
+        super(message);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/exceptions/UserNotFoundException.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/exceptions/UserNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/exceptions/UserNotFoundException.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.exceptions;
+
+public class UserNotFoundException extends Exception{
+
+    public UserNotFoundException(String message){
+        super(message);
+    }
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Admin.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Admin.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Admin.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,20 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "admin_table")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Admin {
+    @Id
+    @Column(name = "korisnik_id")
+    private Long adminId;
+
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Consumer.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Consumer.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Consumer.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,28 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "potrosuvac")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Consumer {
+
+    @Id
+    @Column(name = "korisnik_id")
+    private Long consumerId;
+
+    @Column(name = "broj_naracki")
+    private Integer numberOfOrders;
+
+    @ManyToOne
+    @JoinColumn(name = "lokacija_id")
+    private Location location;
+
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Deliver.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Deliver.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Deliver.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,30 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "dostavuvac")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Deliver {
+
+    @Id
+    @Column(name = "korisnik_id")
+    private Long delivererId;
+
+    @ManyToOne
+    @JoinColumn(name = "admin_id")
+    private Admin admin;
+
+    @ManyToOne
+    @JoinColumn(name = "vozilo_id")
+    private Vehicle vehicle;
+
+
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/FoodItem.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/FoodItem.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/FoodItem.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,58 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Entity
+@Table(name = "hrana")
+
+@AllArgsConstructor
+@NoArgsConstructor
+public class FoodItem {
+
+    @Id
+    @Column(name = "id_stavka")
+    private Long foodItemId;
+
+    @Column(name = "ime_hra")
+    private String foodItemName;
+
+    @ManyToOne
+    @JoinColumn(name = "vrabotenpd_id")
+    private SalePlaceEmployee salePlaceEmployee;
+
+    @ManyToOne
+    @JoinColumn(name = "id_mesto")
+    private SalePlace salePlace;
+
+    @ManyToMany(fetch = FetchType.EAGER)
+    @JoinTable(name = "hrana_e_napravena_namirnica",
+    joinColumns = @JoinColumn(name = "id_stavka"),
+    inverseJoinColumns = @JoinColumn(name = "id_namirnica"))
+    private List<FoodStructure> foodStructures;
+
+    public Long getFoodItemId() {
+        return foodItemId;
+    }
+
+    public String getFoodItemName() {
+        return foodItemName;
+    }
+
+    public SalePlaceEmployee getSalePlaceEmployee() {
+        return salePlaceEmployee;
+    }
+
+    public SalePlace getSalePlace() {
+        return salePlace;
+    }
+
+    public List<FoodStructure> getFoodStructures() {
+        return foodStructures;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/FoodStructure.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/FoodStructure.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/FoodStructure.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,28 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "namirnica")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class FoodStructure {
+
+    @Id
+    @Column(name = "id_namirnica")
+    private Long foodStructureId;
+
+    @Column(name = "ime_name")
+    private String foodStructureName;
+
+    @Column(name = "dali_alergent")
+    private Boolean isAllergen;
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Franchize.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Franchize.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Franchize.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,24 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "franshiza")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Franchize {
+
+    @Id
+    @Column(name = "franshiza_id")
+    private Long franchizeId;
+
+    @Column(name = "ime")
+    private String franchizeName;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Location.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Location.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Location.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,27 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "lokacija")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Location {
+    @Id
+    @Column(name = "lokacija_id")
+    private Long locationId;
+
+
+    @Column(name = "adresa")
+    private String address;
+
+    @Column(name = "broj")
+    private Integer number;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Order.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Order.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Order.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,74 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "naracka")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@NamedStoredProcedureQuery(
+        name = "calculate_cost_of_order_food2",
+        procedureName = "calculate_cost_of_order_food2",
+        parameters = {
+                @StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "order_id")
+        }
+)
+public class Order {
+
+    @Id
+    @Column(name = "naracka_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long orderId;
+
+    @Column(name = "nacinplakjanje")
+    private String typeOfPayment;
+
+    @Column(name = "status")
+    private String orderStatus;
+
+    @Column(name = "datum_naracka")
+    private Timestamp orderDate;
+
+    @ManyToOne
+    @JoinColumn(name = "dostavuvac_id")
+    private Deliver deliver;
+
+    @ManyToOne
+    @JoinColumn(name = "id_mesto")
+    private SalePlace salePlace;
+
+    @ManyToOne
+    @JoinColumn(name = "potrosuvac_id")
+    private Consumer consumer;
+
+    @ManyToOne
+    @JoinColumn(name = "naplata_id")
+    private OrderPayment orderPayment;
+
+    @Transient
+    private Integer orderCost;
+    public Order(String orderStatus, Timestamp orderDate, SalePlace salePlace, Consumer consumer) {
+        this.orderStatus = orderStatus;
+        this.orderDate = orderDate;
+        this.salePlace = salePlace;
+        this.consumer = consumer;
+
+    }
+
+    public Order(String typeOfPayment, String orderStatus, Timestamp orderDate, SalePlace salePlace, Consumer consumer) {
+        this.typeOfPayment = typeOfPayment;
+        this.orderStatus = orderStatus;
+        this.orderDate = orderDate;
+        this.salePlace = salePlace;
+        this.consumer = consumer;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/OrderHasFood.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/OrderHasFood.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/OrderHasFood.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,21 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Entity
+@Table(name = "naracka_sodrzi_hrana")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OrderHasFood {
+
+    @EmbeddedId
+    private OrderHasFoodKey orderHasFoodKey;
+
+
+
+    @Column(name = "kolicina")
+    private Integer quantity;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/OrderHasFoodKey.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/OrderHasFoodKey.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/OrderHasFoodKey.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,27 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Embeddable
+@Data
+@NoArgsConstructor
+
+public class OrderHasFoodKey implements Serializable {
+
+    @Column(name = "id_stavka")
+    private Long foodItemId;
+
+    @Column(name = "naracka_id")
+    private Long orderId;
+
+    public OrderHasFoodKey(Long foodItemId, Long orderId) {
+        this.foodItemId = foodItemId;
+        this.orderId = orderId;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/OrderPayment.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/OrderPayment.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/OrderPayment.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,44 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.*;
+
+import java.sql.Timestamp;
+import java.time.LocalDate;
+
+@Entity
+@Table(name = "naplata")
+public class OrderPayment {
+
+    @Id
+    @Column(name = "naplata_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long orderPaymentId;
+
+    @Column(name = "iznos")
+    private Integer orderCost;
+
+    @Column(name = "nplakjanje")
+    private String orderPaymentType;
+
+    @Column(name = "datum_naplata")
+    private Timestamp orderPaymentDate;
+
+    @ManyToOne
+    @JoinColumn(name = "potrosuvac_id")
+    private Consumer consumer;
+
+    @ManyToOne
+    @JoinColumn(name = "dostavuvac_id")
+    private Deliver deliver;
+
+    public OrderPayment(Integer orderCost, String orderPaymentType, Timestamp orderPaymentDate, Consumer consumer, Deliver deliver) {
+        this.orderCost = orderCost;
+        this.orderPaymentType = orderPaymentType;
+        this.orderPaymentDate = orderPaymentDate;
+        this.consumer = consumer;
+        this.deliver = deliver;
+    }
+    public OrderPayment(){
+
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/Price.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Price.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Price.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,38 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDate;
+
+@Entity
+@Table(name = "cena")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+
+public class Price {
+
+
+   // @JoinColumn(name = "id_stavka", referencedColumnName = "id_stavka", nullable = false)
+    //@ManyToOne
+   // private FoodItem foodItem;
+
+   // @Id
+    //@Column(name = "broj_cena")
+    //private Long priceNumber;
+
+    @EmbeddedId
+    private PriceKey priceKey;
+
+    @Column(name = "iznos")
+    private Integer cost;
+
+    @Column(name = "vazi_od")
+    private LocalDate validFrom;
+
+    @Column(name = "vazi_do")
+    private LocalDate validTo;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/PriceKey.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/PriceKey.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/PriceKey.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,32 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.OneToOne;
+
+import java.io.Serializable;
+
+@Embeddable
+public class PriceKey implements Serializable {
+
+    @OneToOne(optional = false)
+    @JoinColumn(name = "id_stavka", nullable = false)
+    private FoodItem foodItem;
+
+    @Column(name = "broj_cena", nullable = false)
+    private Long priceNumber;
+
+
+    public PriceKey(){
+
+    }
+
+    public FoodItem getFoodItem() {
+        return foodItem;
+    }
+
+    public Long getPriceNumber() {
+        return priceNumber;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/SalePlace.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/SalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/SalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,68 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Entity
+@Table(name = "prodazhnomesto")
+
+@NoArgsConstructor
+@AllArgsConstructor
+public class SalePlace {
+    @Id
+    @Column(name = "id_mesto")
+    private Long salePalceId;
+
+    @Column(name = "ime")
+    private String salePlaceName;
+
+    @Column(name = "ulica")
+    private String salePlaceStreetName;
+
+    @Column(name = "broj")
+    private Integer salePlaceStreetNumber;
+
+    @ManyToOne
+    @JoinColumn(name = "franshiza_id")
+    private Franchize franchize;
+
+    @ManyToOne
+    @JoinColumn(name = "admin_id")
+    private Admin admin;
+
+    @OneToMany(mappedBy = "salePlace", fetch = FetchType.EAGER)
+    List<FoodItem> foodItemList;
+
+    public Long getSalePalceId() {
+        return salePalceId;
+    }
+
+    public String getSalePlaceName() {
+        return salePlaceName;
+    }
+
+    public String getSalePlaceStreetName() {
+        return salePlaceStreetName;
+    }
+
+    public Integer getSalePlaceStreetNumber() {
+        return salePlaceStreetNumber;
+    }
+
+    public Franchize getFranchize() {
+        return franchize;
+    }
+
+    public Admin getAdmin() {
+        return admin;
+    }
+
+    public List<FoodItem> getFoodItemList() {
+        return foodItemList;
+    }
+}
+
Index: src/main/java/com/example/fooddeliverysystem/model/SalePlaceEmployee.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/SalePlaceEmployee.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/SalePlaceEmployee.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,31 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "vrabotenpd")
+
+@AllArgsConstructor
+@NoArgsConstructor
+public class SalePlaceEmployee {
+
+    @Id
+    @Column(name = "korisnik_id")
+    private Long salePlaceEmployeeId;
+
+    @ManyToOne
+    @JoinColumn(name = "id_mesto")
+    private SalePlace salePlace;
+
+    public Long getSalePlaceEmployeeId() {
+        return salePlaceEmployeeId;
+    }
+
+    public SalePlace getSalePlace() {
+        return salePlace;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/User.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/User.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/User.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,36 @@
+package com.example.fooddeliverysystem.model;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import jakarta.persistence.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDate;
+
+@Entity
+@Table(name = "korisnik")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class User {
+
+    @Id
+    @Column(name = "korisnik_id")
+    private Long user_id;
+
+    @Column(name = "ime")
+    private String name;
+
+    @Column(name = "datum_kreiranje")
+    private LocalDate dateCreated;
+
+    @Column(name = "username")
+    private String username;
+
+    @Column(name = "password")
+    private String password;
+
+    @Transient
+    private Role userRole;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/UserPrincipal.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/UserPrincipal.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/UserPrincipal.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,50 @@
+//package com.example.fooddeliverysystem.model;
+//
+//import org.springframework.security.core.GrantedAuthority;
+//import org.springframework.security.core.userdetails.UserDetails;
+//
+//import java.util.Collection;
+//
+//public class UserPrincipal {
+//
+//    private User user;
+//
+//    public UserPrincipal(User user){
+//        this.user = user;
+//    }
+//
+//    @Override
+//    public Collection<? extends GrantedAuthority> getAuthorities() {
+//        return null;
+//    }
+//
+//    @Override
+//    public String getPassword() {
+//        return null;
+//    }
+//
+//    @Override
+//    public String getUsername() {
+//        return null;
+//    }
+//
+//    @Override
+//    public boolean isAccountNonExpired() {
+//        return false;
+//    }
+//
+//    @Override
+//    public boolean isAccountNonLocked() {
+//        return false;
+//    }
+//
+//    @Override
+//    public boolean isCredentialsNonExpired() {
+//        return false;
+//    }
+//
+//    @Override
+//    public boolean isEnabled() {
+//        return false;
+//    }
+//}
Index: src/main/java/com/example/fooddeliverysystem/model/Vehicle.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/Vehicle.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/Vehicle.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,24 @@
+package com.example.fooddeliverysystem.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "vozilo")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Vehicle {
+
+    @Id
+    @Column(name = "vozilo_id")
+    private Long vehicleId;
+
+    @Column(name = "tip_vozilo")
+    private String vehichleName;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/enums/Role.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/enums/Role.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/enums/Role.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,8 @@
+package com.example.fooddeliverysystem.model.enums;
+
+public enum Role {
+    ADMIN,
+    CONSUMER,
+    DELIVER,
+    SALEPLACEEMPLOYEE
+}
Index: src/main/java/com/example/fooddeliverysystem/model/objects/FoodItemsWithQuantity.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/objects/FoodItemsWithQuantity.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/objects/FoodItemsWithQuantity.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,13 @@
+package com.example.fooddeliverysystem.model.objects;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class FoodItemsWithQuantity{
+    private String foodName;
+    private Integer foodQuantity;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/userssecurity/UserPrincipal.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/userssecurity/UserPrincipal.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/userssecurity/UserPrincipal.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,56 @@
+package com.example.fooddeliverysystem.model.userssecurity;
+
+import com.example.fooddeliverysystem.model.User;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class UserPrincipal implements UserDetails {
+
+    private final User user;
+
+    public UserPrincipal(User user) {
+        this.user = user;
+    }
+
+    @Override
+    public Collection<? extends GrantedAuthority> getAuthorities() {
+        List<GrantedAuthority> authorityList = new ArrayList<>();
+        authorityList.add(new SimpleGrantedAuthority("ROLE_" + this.user.getUserRole().name()));
+        return authorityList;
+    }
+
+    @Override
+    public String getPassword() {
+        return this.user.getPassword();
+    }
+
+    @Override
+    public String getUsername() {
+        return this.user.getUsername();
+    }
+
+    @Override
+    public boolean isAccountNonExpired() {
+        return true;
+    }
+
+    @Override
+    public boolean isAccountNonLocked() {
+        return true;
+    }
+
+    @Override
+    public boolean isCredentialsNonExpired() {
+        return true;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return true;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/model/views/BestPacketsForEachSalePlace.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/views/BestPacketsForEachSalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/views/BestPacketsForEachSalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,32 @@
+package com.example.fooddeliverysystem.model.views;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Immutable;
+
+@Entity(name = "najdobri_paketi_za_sekoe_prodazno_mesto")
+@Immutable
+@Data
+@NoArgsConstructor
+public class BestPacketsForEachSalePlace {
+
+
+    @Column(name = "ime")
+    private String namePlace;
+
+    @Id
+    @Column(name = "paket_id")
+    private Long packetId;
+
+    @Column(name = "se_sostoi_od")
+    private String contains;
+
+    @Column(name = "vkupno_prodadeni")
+    private Integer totalSold;
+
+    @Column(name = "ime_vraboten")
+    private String employeeThatAddedName;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/views/DeliverNumberOfOrdersDeliveredBySalePlace.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/views/DeliverNumberOfOrdersDeliveredBySalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/views/DeliverNumberOfOrdersDeliveredBySalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,31 @@
+package com.example.fooddeliverysystem.model.views;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Immutable;
+
+@Entity(name = "dostavuvac_dostavi_za_sekoe_prod_mesto")
+@Immutable
+@Data
+@NoArgsConstructor
+public class DeliverNumberOfOrdersDeliveredBySalePlace {
+
+    @Id
+    @Column(name = "id_mesto")
+    private Long salePlaceId;
+
+    @Column(name = "ime")
+    private String deliverName;
+
+    @Column(name = "ime_mesto")
+    private String salePlaceName;
+
+    @Column(name = "broj_naracki")
+    private Integer numberOfOrders;
+
+    @Column(name = "vkupna_suma")
+    private Integer totalSum;
+}
Index: src/main/java/com/example/fooddeliverysystem/model/views/FranchizeEarningsBySalePlace.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/views/FranchizeEarningsBySalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/views/FranchizeEarningsBySalePlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,26 @@
+package com.example.fooddeliverysystem.model.views;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Immutable;
+
+@Entity(name = "franshiza_promet_mesta_tri_meseci")
+@Immutable
+@Data
+@NoArgsConstructor
+public class FranchizeEarningsBySalePlace {
+
+    @Id
+    @Column(name = "ime_franshiza")
+    private String franchizeName;
+
+    @Column(name = "ime_prodaznomesto")
+    private String salePlaceName;
+
+    @Column(name = "vkupen_promet")
+    private Integer totalSold;
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/views/MostLoyalCustomerForEachPlace.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/views/MostLoyalCustomerForEachPlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/views/MostLoyalCustomerForEachPlace.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,34 @@
+package com.example.fooddeliverysystem.model.views;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Immutable;
+
+@Entity(name = "najveren_potrosuvac_za_sekoe_prodazno_mesto")
+@Immutable
+@Data
+@NoArgsConstructor
+public class MostLoyalCustomerForEachPlace {
+
+    @Column(name = "ime_potrosuvac")
+    private String customerName;
+
+    @Column(name = "ime_mesto")
+    private String salePlaceName;
+
+    @Column(name = "adresa_potrosuvac")
+    private String customerAdress;
+
+    @Column(name = "broj_adresa_potrosuvac")
+    private Integer customerAdressNumber;
+
+    @Id
+    @Column(name = "broj_naracka")
+    private Long orderNumber;
+
+
+
+}
Index: src/main/java/com/example/fooddeliverysystem/model/views/TotalCouponsByCustomer.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/model/views/TotalCouponsByCustomer.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/model/views/TotalCouponsByCustomer.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,25 @@
+package com.example.fooddeliverysystem.model.views;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Immutable;
+
+@Entity(name = "potrosuvaci_vkupen_iznos_kuponi")
+@Immutable
+@Data
+@NoArgsConstructor
+public class TotalCouponsByCustomer {
+
+    @Id
+    @Column(name = "korisnik_id")
+    private Long userId;
+
+    @Column(name = "ime")
+    private String userName;
+
+    @Column(name = "vkupen_iznos")
+    private Integer totalSum;
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/AdminRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/AdminRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/AdminRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.Admin;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface AdminRepository extends JpaRepository<Admin, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/ConsumerRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/ConsumerRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/ConsumerRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.Consumer;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ConsumerRepository extends JpaRepository<Consumer, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/DeliverRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/DeliverRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/DeliverRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.Deliver;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DeliverRepository extends JpaRepository<Deliver, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/FoodItemRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/FoodItemRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/FoodItemRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,7 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.FoodItem;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface FoodItemRepository extends JpaRepository<FoodItem, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/OrderHasFoodRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/OrderHasFoodRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/OrderHasFoodRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,13 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.OrderHasFood;
+import com.example.fooddeliverysystem.model.OrderHasFoodKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface OrderHasFoodRepository extends JpaRepository<OrderHasFood, OrderHasFoodKey> {
+    List<OrderHasFood> findAllByOrderHasFoodKeyOrderId(Long orderId);
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/OrderPaymentRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/OrderPaymentRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/OrderPaymentRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.OrderPayment;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface OrderPaymentRepository extends JpaRepository<OrderPayment, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/OrderRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/OrderRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/OrderRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.Consumer;
+import com.example.fooddeliverysystem.model.Deliver;
+import com.example.fooddeliverysystem.model.Order;
+import com.example.fooddeliverysystem.model.SalePlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.query.Procedure;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface OrderRepository extends JpaRepository<Order, Long> {
+
+    List<Order> findAllBySalePlaceAndOrderStatus(SalePlace salePlace, String orderStatus);
+
+    List<Order> findAllByOrderStatus(String status);
+
+    List<Order> findAllByOrderStatusAndDeliver(String status, Deliver deliver);
+
+    List<Order> findAllByConsumer(Consumer consumer);
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/PriceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/PriceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/PriceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,15 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.FoodItem;
+import com.example.fooddeliverysystem.model.Price;
+import com.example.fooddeliverysystem.model.PriceKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface PriceRepository extends JpaRepository<Price, PriceKey> {
+    List<Price> findAllByPriceKey_FoodItem(FoodItem foodItem);
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/SalePlaceEmployeeRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/SalePlaceEmployeeRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/SalePlaceEmployeeRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.SalePlaceEmployee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SalePlaceEmployeeRepository extends JpaRepository<SalePlaceEmployee, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/SalePlaceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/SalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/SalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.SalePlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SalePlaceRepository extends JpaRepository<SalePlace, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/UserRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/UserRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/UserRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,13 @@
+package com.example.fooddeliverysystem.repository;
+
+import com.example.fooddeliverysystem.model.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.Optional;
+
+@Repository
+public interface UserRepository extends JpaRepository<User, Long> {
+
+    Optional<User> findByUsername(String username);
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/storedprocedure/OrderCostCalcualte.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/storedprocedure/OrderCostCalcualte.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/storedprocedure/OrderCostCalcualte.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.repository.storedprocedure;
+
+import jakarta.persistence.*;
+import org.springframework.data.jpa.repository.query.Procedure;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+
+@Component
+public class OrderCostCalcualte {
+
+    @PersistenceContext
+    private EntityManager em;
+
+    @Procedure
+    public Integer calculate_cost_of_order_food(Long orderId){
+        StoredProcedureQuery query = em.createNamedStoredProcedureQuery("calculate_cost_of_order_food2");
+        query = query.setParameter("order_id", Integer.valueOf(String.valueOf(orderId)));
+        query.execute();
+       // System.out.println(query.getOutputParameterValue("vkupno_cena_hrana"));
+        return null;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/BestPacketsForEachSalePlaceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/BestPacketsForEachSalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/BestPacketsForEachSalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository.viewsrepos;
+
+import com.example.fooddeliverysystem.model.views.BestPacketsForEachSalePlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface BestPacketsForEachSalePlaceRepository extends JpaRepository<BestPacketsForEachSalePlace, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/DeliverNumberOfOrdersDeliveredBySalePlaceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/DeliverNumberOfOrdersDeliveredBySalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/DeliverNumberOfOrdersDeliveredBySalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository.viewsrepos;
+
+import com.example.fooddeliverysystem.model.views.DeliverNumberOfOrdersDeliveredBySalePlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DeliverNumberOfOrdersDeliveredBySalePlaceRepository extends JpaRepository<DeliverNumberOfOrdersDeliveredBySalePlace, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/FranchizeEarningsBySalePlaceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/FranchizeEarningsBySalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/FranchizeEarningsBySalePlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository.viewsrepos;
+
+import com.example.fooddeliverysystem.model.views.FranchizeEarningsBySalePlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface FranchizeEarningsBySalePlaceRepository extends JpaRepository<FranchizeEarningsBySalePlace, String> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/MostLoyalCustomerForEachPlaceRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/MostLoyalCustomerForEachPlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/MostLoyalCustomerForEachPlaceRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository.viewsrepos;
+
+import com.example.fooddeliverysystem.model.views.MostLoyalCustomerForEachPlace;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MostLoyalCustomerForEachPlaceRepository extends JpaRepository<MostLoyalCustomerForEachPlace, Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/TotalCouponsByCustomerRepository.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/TotalCouponsByCustomerRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/repository/viewsrepos/TotalCouponsByCustomerRepository.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.repository.viewsrepos;
+
+import com.example.fooddeliverysystem.model.views.TotalCouponsByCustomer;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface TotalCouponsByCustomerRepository extends JpaRepository<TotalCouponsByCustomer,Long> {
+}
Index: src/main/java/com/example/fooddeliverysystem/service/BestPacketsForEachSalePlaceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/BestPacketsForEachSalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/BestPacketsForEachSalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,10 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.views.BestPacketsForEachSalePlace;
+
+import java.util.List;
+
+public interface BestPacketsForEachSalePlaceService {
+
+    List<BestPacketsForEachSalePlace> listAll();
+}
Index: src/main/java/com/example/fooddeliverysystem/service/DeliverNumberOfOrdersDeliveredBySalePlaceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/DeliverNumberOfOrdersDeliveredBySalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/DeliverNumberOfOrdersDeliveredBySalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,10 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.views.DeliverNumberOfOrdersDeliveredBySalePlace;
+
+import java.util.List;
+
+public interface DeliverNumberOfOrdersDeliveredBySalePlaceService {
+
+    List<DeliverNumberOfOrdersDeliveredBySalePlace> listAll();
+}
Index: src/main/java/com/example/fooddeliverysystem/service/FoodItemService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/FoodItemService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/FoodItemService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,11 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.FoodItem;
+
+import java.util.List;
+
+public interface FoodItemService {
+
+    List<FoodItem> findAllFoodItemsByIds(List<Long> foodItemIds);
+    FoodItem findFoodItemById(Long id);
+}
Index: src/main/java/com/example/fooddeliverysystem/service/FranchizeEarningsBySalePlaceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/FranchizeEarningsBySalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/FranchizeEarningsBySalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,10 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.views.FranchizeEarningsBySalePlace;
+
+import java.util.List;
+
+public interface FranchizeEarningsBySalePlaceService {
+
+    List<FranchizeEarningsBySalePlace> listAll();
+}
Index: src/main/java/com/example/fooddeliverysystem/service/HasFoodService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/HasFoodService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/HasFoodService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,12 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.OrderHasFood;
+import com.example.fooddeliverysystem.model.objects.FoodItemsWithQuantity;
+
+import java.util.List;
+
+public interface HasFoodService {
+    List<OrderHasFood> findAllFoodsInOrder(Long orderId);
+
+    List<FoodItemsWithQuantity> findAllFoodnamesInOrder(Long orderId);
+}
Index: src/main/java/com/example/fooddeliverysystem/service/MostLoyalCustomerForEachPlaceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/MostLoyalCustomerForEachPlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/MostLoyalCustomerForEachPlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,10 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.views.MostLoyalCustomerForEachPlace;
+
+import java.util.List;
+
+public interface MostLoyalCustomerForEachPlaceService {
+
+    List<MostLoyalCustomerForEachPlace> listAll();
+}
Index: src/main/java/com/example/fooddeliverysystem/service/OrderPaymentService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/OrderPaymentService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/OrderPaymentService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.OrderNotFoundException;
+
+public interface OrderPaymentService {
+
+    void createOrderPayment(Long orderId) throws OrderNotFoundException, FoodItemNotFoundException;
+}
Index: src/main/java/com/example/fooddeliverysystem/service/OrderService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/OrderService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/OrderService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,28 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.OrderNotFoundException;
+import com.example.fooddeliverysystem.exceptions.SalePlaceNotFoundException;
+import com.example.fooddeliverysystem.model.Order;
+
+import java.util.List;
+
+public interface OrderService {
+
+    void placeOrder(String typeOfPayment, Long salePlaceId, List<Long> foodIds, List<Integer> foodPrices, List<Integer> foodQuantities, String username) throws SalePlaceNotFoundException;
+
+    Order changeOrderStatus(Long orderId, String status);
+
+    Integer calculateCostOfOrder(Long orderId) throws FoodItemNotFoundException;
+    List<Order> findAllOrdersReadyToBeDelivered();
+
+    List<Order> findAllOrdersForDeliver(String username);
+
+    Order updateOrderDeliver(String username, Long orderId);
+
+    Order findOrderById(Long orderId) throws OrderNotFoundException;
+
+    List<Order> findAllOrdersForCustomer(String username);
+
+    void saveOrder(Order order);
+}
Index: src/main/java/com/example/fooddeliverysystem/service/PriceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/PriceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/PriceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,13 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.model.FoodItem;
+import com.example.fooddeliverysystem.model.Price;
+
+import java.util.List;
+
+public interface PriceService {
+
+    List<Price> findAllPrices();
+    Price findCurrentPriceForFoodItem(FoodItem foodItem) throws FoodItemNotFoundException;
+}
Index: src/main/java/com/example/fooddeliverysystem/service/SalePlaceService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/SalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/SalePlaceService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,16 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.exceptions.SalePlaceNotFoundException;
+import com.example.fooddeliverysystem.model.Order;
+import com.example.fooddeliverysystem.model.SalePlace;
+
+import java.util.List;
+
+public interface SalePlaceService {
+
+    List<SalePlace> findAll();
+    SalePlace findSalePlaceServiceById(Long id) throws SalePlaceNotFoundException;
+
+    List<Order> findAllCreatedOrders(String username) throws SalePlaceNotFoundException;
+     SalePlace findSalePlaceForUser(String username);
+}
Index: src/main/java/com/example/fooddeliverysystem/service/TotalCouponsByCustomerService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/TotalCouponsByCustomerService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/TotalCouponsByCustomerService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,9 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.model.views.TotalCouponsByCustomer;
+
+import java.util.List;
+
+public interface TotalCouponsByCustomerService {
+    List<TotalCouponsByCustomer> listAll();
+}
Index: src/main/java/com/example/fooddeliverysystem/service/UserService.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/UserService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/UserService.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,14 @@
+package com.example.fooddeliverysystem.service;
+
+import com.example.fooddeliverysystem.exceptions.UserNotFoundException;
+import com.example.fooddeliverysystem.model.User;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.List;
+
+public interface UserService {
+
+    List<User> findAllUsers();
+
+    UserDetails loadUserByUsername(String username);
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/BestPacketsForEachSalePlaceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/BestPacketsForEachSalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/BestPacketsForEachSalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.views.BestPacketsForEachSalePlace;
+import com.example.fooddeliverysystem.repository.viewsrepos.BestPacketsForEachSalePlaceRepository;
+import com.example.fooddeliverysystem.service.BestPacketsForEachSalePlaceService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class BestPacketsForEachSalePlaceServiceImpl implements BestPacketsForEachSalePlaceService {
+
+    private final BestPacketsForEachSalePlaceRepository bestPacketsForEachSalePlaceRepository;
+
+    public BestPacketsForEachSalePlaceServiceImpl(BestPacketsForEachSalePlaceRepository bestPacketsForEachSalePlaceRepository) {
+        this.bestPacketsForEachSalePlaceRepository = bestPacketsForEachSalePlaceRepository;
+    }
+
+    @Override
+    public List<BestPacketsForEachSalePlace> listAll() {
+        return this.bestPacketsForEachSalePlaceRepository.findAll();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/DeliverNumberOfOrdersDeliveredBySalePlaceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/DeliverNumberOfOrdersDeliveredBySalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/DeliverNumberOfOrdersDeliveredBySalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.views.DeliverNumberOfOrdersDeliveredBySalePlace;
+import com.example.fooddeliverysystem.repository.viewsrepos.DeliverNumberOfOrdersDeliveredBySalePlaceRepository;
+import com.example.fooddeliverysystem.service.DeliverNumberOfOrdersDeliveredBySalePlaceService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class DeliverNumberOfOrdersDeliveredBySalePlaceServiceImpl implements DeliverNumberOfOrdersDeliveredBySalePlaceService {
+
+    private final DeliverNumberOfOrdersDeliveredBySalePlaceRepository deliverNumberOfOrdersDeliveredBySalePlaceRepository;
+
+    public DeliverNumberOfOrdersDeliveredBySalePlaceServiceImpl(DeliverNumberOfOrdersDeliveredBySalePlaceRepository deliverNumberOfOrdersDeliveredBySalePlaceRepository) {
+        this.deliverNumberOfOrdersDeliveredBySalePlaceRepository = deliverNumberOfOrdersDeliveredBySalePlaceRepository;
+    }
+
+    @Override
+    public List<DeliverNumberOfOrdersDeliveredBySalePlace> listAll() {
+        return this.deliverNumberOfOrdersDeliveredBySalePlaceRepository.findAll();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/FoodItemServceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/FoodItemServceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/FoodItemServceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,28 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.FoodItem;
+import com.example.fooddeliverysystem.repository.FoodItemRepository;
+import com.example.fooddeliverysystem.service.FoodItemService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FoodItemServceImpl implements FoodItemService {
+
+    private final FoodItemRepository foodItemRepository;
+
+    public FoodItemServceImpl(FoodItemRepository foodItemRepository) {
+        this.foodItemRepository = foodItemRepository;
+    }
+
+    @Override
+    public List<FoodItem> findAllFoodItemsByIds(List<Long> foodItemIds) {
+        return this.foodItemRepository.findAllById(foodItemIds);
+    }
+
+    @Override
+    public FoodItem findFoodItemById(Long id) {
+        return this.foodItemRepository.findById(id).get();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/FranchizeEarningsBySalePlaceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/FranchizeEarningsBySalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/FranchizeEarningsBySalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,24 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.views.FranchizeEarningsBySalePlace;
+import com.example.fooddeliverysystem.repository.viewsrepos.FranchizeEarningsBySalePlaceRepository;
+import com.example.fooddeliverysystem.service.FranchizeEarningsBySalePlaceService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FranchizeEarningsBySalePlaceServiceImpl implements FranchizeEarningsBySalePlaceService {
+
+
+    private final FranchizeEarningsBySalePlaceRepository franchizeEarningsBySalePlaceRepository;
+
+    public FranchizeEarningsBySalePlaceServiceImpl(FranchizeEarningsBySalePlaceRepository franchizeEarningsBySalePlaceRepository) {
+        this.franchizeEarningsBySalePlaceRepository = franchizeEarningsBySalePlaceRepository;
+    }
+
+    @Override
+    public List<FranchizeEarningsBySalePlace> listAll() {
+        return this.franchizeEarningsBySalePlaceRepository.findAll();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/HasFoodServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/HasFoodServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/HasFoodServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,49 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.FoodItem;
+import com.example.fooddeliverysystem.model.OrderHasFood;
+import com.example.fooddeliverysystem.model.objects.FoodItemsWithQuantity;
+import com.example.fooddeliverysystem.repository.FoodItemRepository;
+import com.example.fooddeliverysystem.repository.OrderHasFoodRepository;
+import com.example.fooddeliverysystem.service.FoodItemService;
+import com.example.fooddeliverysystem.service.HasFoodService;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class HasFoodServiceImpl implements HasFoodService {
+
+
+    private final OrderHasFoodRepository orderHasFoodRepository;
+    private final FoodItemRepository foodItemRepository;
+    public HasFoodServiceImpl(OrderHasFoodRepository orderHasFoodRepository, FoodItemRepository foodItemRepository) {
+        this.orderHasFoodRepository = orderHasFoodRepository;
+        this.foodItemRepository = foodItemRepository;
+    }
+    @Override
+    public List<OrderHasFood> findAllFoodsInOrder(Long orderId) {
+        return this.orderHasFoodRepository.findAllByOrderHasFoodKeyOrderId(orderId);
+    }
+
+    @Override
+    public List<FoodItemsWithQuantity> findAllFoodnamesInOrder(Long orderId) {
+        List<FoodItemsWithQuantity> foodNamesAndQuantites = new ArrayList<>();
+
+        List<OrderHasFood> orderHasFoodList = this.orderHasFoodRepository.findAll();
+        for(OrderHasFood orderHasFood: orderHasFoodList){
+            if(orderId.equals(orderHasFood.getOrderHasFoodKey().getOrderId())){
+                FoodItem foodItem = this.foodItemRepository.findById(orderHasFood.getOrderHasFoodKey().getFoodItemId()).get();
+                String name = foodItem.getFoodItemName();
+                Integer quantity = orderHasFood.getQuantity();
+                foodNamesAndQuantites.add(new FoodItemsWithQuantity(name, quantity));
+
+            }
+
+
+        }
+
+        return foodNamesAndQuantites;
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/MostLoyalCustomerForEachPlaceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/MostLoyalCustomerForEachPlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/MostLoyalCustomerForEachPlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.views.MostLoyalCustomerForEachPlace;
+import com.example.fooddeliverysystem.repository.viewsrepos.MostLoyalCustomerForEachPlaceRepository;
+import com.example.fooddeliverysystem.service.MostLoyalCustomerForEachPlaceService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class MostLoyalCustomerForEachPlaceServiceImpl implements MostLoyalCustomerForEachPlaceService {
+
+    private final MostLoyalCustomerForEachPlaceRepository mostLoyalCustomerForEachPlaceRepository;
+
+    public MostLoyalCustomerForEachPlaceServiceImpl(MostLoyalCustomerForEachPlaceRepository mostLoyalCustomerForEachPlaceRepository) {
+        this.mostLoyalCustomerForEachPlaceRepository = mostLoyalCustomerForEachPlaceRepository;
+    }
+
+    @Override
+    public List<MostLoyalCustomerForEachPlace> listAll() {
+        return this.mostLoyalCustomerForEachPlaceRepository.findAll();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/OrderPaymentServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/OrderPaymentServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/OrderPaymentServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,43 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.OrderNotFoundException;
+import com.example.fooddeliverysystem.model.Consumer;
+import com.example.fooddeliverysystem.model.Deliver;
+import com.example.fooddeliverysystem.model.Order;
+import com.example.fooddeliverysystem.model.OrderPayment;
+import com.example.fooddeliverysystem.repository.OrderPaymentRepository;
+import com.example.fooddeliverysystem.service.OrderPaymentService;
+import com.example.fooddeliverysystem.service.OrderService;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+
+@Service
+public class OrderPaymentServiceImpl implements OrderPaymentService {
+
+    private final OrderService orderService;
+    private final OrderPaymentRepository orderPaymentRepository;
+
+    public OrderPaymentServiceImpl(OrderService orderService, OrderPaymentRepository orderPaymentRepository) {
+        this.orderService = orderService;
+        this.orderPaymentRepository = orderPaymentRepository;
+    }
+
+
+
+    @Override
+    public void createOrderPayment(Long orderId) throws OrderNotFoundException, FoodItemNotFoundException {
+      Order order = this.orderService.findOrderById(orderId);
+      Integer orderCost = this.orderService.calculateCostOfOrder(orderId);
+      Deliver deliver = order.getDeliver();
+      Consumer consumer = order.getConsumer();
+      OrderPayment orderPayment = new OrderPayment(orderCost, order.getTypeOfPayment(), Timestamp.valueOf(LocalDateTime.now()), consumer, deliver);
+      order.setOrderStatus("zavrsena");
+      OrderPayment orderPayment1 = this.orderPaymentRepository.save(orderPayment);
+      Order order1 = this.orderService.findOrderById(orderId);
+      order1.setOrderPayment(orderPayment1);
+      this.orderService.saveOrder(order1);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/OrderServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/OrderServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/OrderServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,127 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.OrderNotFoundException;
+import com.example.fooddeliverysystem.exceptions.SalePlaceNotFoundException;
+import com.example.fooddeliverysystem.model.*;
+import com.example.fooddeliverysystem.repository.*;
+import com.example.fooddeliverysystem.service.OrderService;
+import com.example.fooddeliverysystem.service.PriceService;
+import com.example.fooddeliverysystem.service.SalePlaceService;
+import com.example.fooddeliverysystem.service.UserService;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class OrderServiceImpl implements OrderService {
+
+    private final SalePlaceService salePlaceService;
+    private final OrderRepository orderRepository;
+    private final OrderHasFoodRepository orderHasFoodRepository;
+    private final UserRepository userRepository;
+    private final ConsumerRepository consumerRepository;
+
+    private final FoodItemRepository foodItemRepository;
+    private final DeliverRepository deliverRepository;
+    private final PriceService priceService;
+    public OrderServiceImpl(SalePlaceService salePlaceRepository, OrderRepository orderRepository, OrderHasFoodRepository orderHasFoodRepository, UserRepository userRepository,
+                            ConsumerRepository consumerRepository, FoodItemRepository foodItemRepository, PriceService priceService, DeliverRepository deliverRepository) {
+        this.salePlaceService = salePlaceRepository;
+        this.orderRepository = orderRepository;
+        this.orderHasFoodRepository = orderHasFoodRepository;
+        this.userRepository = userRepository;
+        this.consumerRepository = consumerRepository;
+        this.foodItemRepository = foodItemRepository;
+        this.priceService = priceService;
+        this.deliverRepository = deliverRepository;
+    }
+
+    @Override
+    public void placeOrder(String typeOfPayment, Long salePlaceId, List<Long> foodIds, List<Integer> foodPrices, List<Integer> foodQuantities, String username) throws SalePlaceNotFoundException {
+        SalePlace salePlace = this.salePlaceService.findSalePlaceServiceById(salePlaceId);
+        User user = this.userRepository.findByUsername(username).get();
+        Consumer consumer = this.consumerRepository.findById(user.getUser_id()).get();
+
+        Order order = new Order(typeOfPayment,"kreirana", Timestamp.valueOf(LocalDateTime.now()), salePlace ,consumer);
+        List<OrderHasFood> orderHasFoodList = new ArrayList<>();
+        order = orderRepository.save(order);
+        for(int i = 0; i < foodIds.size(); i++){
+
+            if(foodQuantities.get(i) != null) {
+                OrderHasFood orderHasFood = new OrderHasFood(new OrderHasFoodKey(foodIds.get(i), order.getOrderId()), foodQuantities.get(i));
+                orderHasFoodList.add(orderHasFood);
+            }
+        }
+        this.orderHasFoodRepository.saveAll(orderHasFoodList);
+
+
+
+    }
+
+    @Override
+    public Order changeOrderStatus(Long orderId, String status) {
+        Order order = this.orderRepository.findById(orderId).get();
+        order.setOrderStatus(status);
+
+        return this.orderRepository.save(order);
+    }
+
+    @Override
+    public Integer calculateCostOfOrder(Long orderId)  throws FoodItemNotFoundException {
+        Integer totalCost = 0;
+        List<OrderHasFood> orderHasFoodList = this.orderHasFoodRepository.findAllByOrderHasFoodKeyOrderId(orderId);
+        for(OrderHasFood orderHasFood: orderHasFoodList){
+            Long foodItemId = orderHasFood.getOrderHasFoodKey().getFoodItemId();
+            FoodItem foodItem = this.foodItemRepository.findById(foodItemId).get();
+            Integer quantity = orderHasFood.getQuantity();
+            Integer price = this.priceService.findCurrentPriceForFoodItem(foodItem).getCost();
+            totalCost += quantity * price;
+
+        }
+
+        return totalCost;
+    }
+
+    @Override
+    public List<Order> findAllOrdersReadyToBeDelivered() {
+        return this.orderRepository.findAllByOrderStatus("spremna");
+    }
+
+    @Override
+    public List<Order> findAllOrdersForDeliver(String username) {
+        User user = this.userRepository.findByUsername(username).get();
+        Deliver deliver = this.deliverRepository.findById(user.getUser_id()).get();
+        return this.orderRepository.findAllByOrderStatusAndDeliver("prevzemena", deliver);
+    }
+
+    @Override
+    public Order updateOrderDeliver(String username, Long orderId) {
+        User user = this.userRepository.findByUsername(username).get();
+        Deliver deliver = this.deliverRepository.findById(user.getUser_id()).get();
+        Order order = this.orderRepository.findById(orderId).get();
+        order.setDeliver(deliver);
+        return this.orderRepository.save(order);
+    }
+
+    @Override
+    public Order findOrderById(Long orderId) throws OrderNotFoundException {
+        return this.orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException("order cannot be found"));
+    }
+
+    @Override
+    public List<Order> findAllOrdersForCustomer(String username) {
+        User user = this.userRepository.findByUsername(username).get();
+        Consumer customer = this.consumerRepository.findById(user.getUser_id()).get();
+        return this.orderRepository.findAllByConsumer(customer);
+    }
+
+    @Override
+    public void saveOrder(Order order) {
+        this.orderRepository.save(order);
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/PriceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/PriceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/PriceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,36 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.model.FoodItem;
+import com.example.fooddeliverysystem.model.Price;
+import com.example.fooddeliverysystem.repository.PriceRepository;
+import com.example.fooddeliverysystem.service.PriceService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+@Service
+public class PriceServiceImpl implements PriceService {
+
+    private final PriceRepository priceRepository;
+
+    public PriceServiceImpl(PriceRepository priceRepository) {
+        this.priceRepository = priceRepository;
+    }
+
+    @Override
+    public List<Price> findAllPrices() {
+        return this.priceRepository.findAll();
+    }
+
+    @Override
+    public Price findCurrentPriceForFoodItem(FoodItem foodItem) throws FoodItemNotFoundException {
+        List<Price> pricesForFoodItem = this.priceRepository.findAllByPriceKey_FoodItem(foodItem);
+        Optional<Price> currentPrice = pricesForFoodItem.stream()
+                .sorted((price1, price2) -> (int) (price2.getPriceKey().getPriceNumber() - price1.getPriceKey().getPriceNumber()))
+                .findFirst();
+        return currentPrice.orElseThrow(() -> new FoodItemNotFoundException("food item cannot be found"));
+
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/SalePlaceServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/SalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/SalePlaceServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,59 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.exceptions.SalePlaceNotFoundException;
+import com.example.fooddeliverysystem.model.Order;
+import com.example.fooddeliverysystem.model.SalePlace;
+import com.example.fooddeliverysystem.model.SalePlaceEmployee;
+import com.example.fooddeliverysystem.model.User;
+import com.example.fooddeliverysystem.repository.OrderRepository;
+import com.example.fooddeliverysystem.repository.SalePlaceEmployeeRepository;
+import com.example.fooddeliverysystem.repository.SalePlaceRepository;
+import com.example.fooddeliverysystem.repository.UserRepository;
+import com.example.fooddeliverysystem.service.SalePlaceService;
+import com.example.fooddeliverysystem.service.UserService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class SalePlaceServiceImpl implements SalePlaceService {
+
+    private SalePlaceRepository salePlaceRepository;
+    private OrderRepository orderRepository;
+
+    private UserRepository userRepository;
+    private SalePlaceEmployeeRepository salePlaceEmployeeRepository;
+    public SalePlaceServiceImpl(SalePlaceRepository salePlaceRepository, OrderRepository orderRepository, UserRepository userRepository,
+                                SalePlaceEmployeeRepository salePlaceEmployeeRepository) {
+        this.salePlaceRepository = salePlaceRepository;
+        this.orderRepository = orderRepository;
+        this.userRepository = userRepository;
+        this.salePlaceEmployeeRepository = salePlaceEmployeeRepository;
+    }
+
+    @Override
+    public List<SalePlace> findAll() {
+        return this.salePlaceRepository.findAll();
+    }
+
+    @Override
+    public SalePlace findSalePlaceServiceById(Long id) throws SalePlaceNotFoundException {
+        return this.salePlaceRepository.findById(id).orElseThrow(() -> new SalePlaceNotFoundException("Sale place not found"));
+
+    }
+
+    @Override
+    public List<Order> findAllCreatedOrders(String username) throws SalePlaceNotFoundException{
+
+        return this.orderRepository.findAllBySalePlaceAndOrderStatus(findSalePlaceForUser(username), "kreirana");
+    }
+
+    @Override
+    public SalePlace findSalePlaceForUser(String username){
+        User user = this.userRepository.findByUsername(username).get();
+
+        SalePlaceEmployee salePlaceEmployee = this.salePlaceEmployeeRepository.findById(user.getUser_id()).get();
+        return salePlaceEmployee.getSalePlace();
+    }
+}
+
Index: src/main/java/com/example/fooddeliverysystem/service/impl/TotalCouponsByCustomerServiceImpl.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/TotalCouponsByCustomerServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/TotalCouponsByCustomerServiceImpl.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,23 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.model.views.TotalCouponsByCustomer;
+import com.example.fooddeliverysystem.repository.viewsrepos.TotalCouponsByCustomerRepository;
+import com.example.fooddeliverysystem.service.TotalCouponsByCustomerService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class TotalCouponsByCustomerServiceImpl implements TotalCouponsByCustomerService {
+
+    private  final TotalCouponsByCustomerRepository totalCouponsByCustomerRepository;
+
+    public TotalCouponsByCustomerServiceImpl(TotalCouponsByCustomerRepository totalCouponsByCustomerRepository) {
+        this.totalCouponsByCustomerRepository = totalCouponsByCustomerRepository;
+    }
+
+    @Override
+    public List<TotalCouponsByCustomer> listAll() {
+        return this.totalCouponsByCustomerRepository.findAll();
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/service/impl/UserServiceImplementation.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/service/impl/UserServiceImplementation.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/service/impl/UserServiceImplementation.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,58 @@
+package com.example.fooddeliverysystem.service.impl;
+
+import com.example.fooddeliverysystem.exceptions.UserNotFoundException;
+import com.example.fooddeliverysystem.model.User;
+
+import com.example.fooddeliverysystem.model.enums.Role;
+import com.example.fooddeliverysystem.model.userssecurity.UserPrincipal;
+import com.example.fooddeliverysystem.repository.*;
+import com.example.fooddeliverysystem.service.UserService;
+import org.springframework.security.config.authentication.UserServiceBeanDefinitionParser;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class UserServiceImplementation implements UserService, UserDetailsService {
+    private final UserRepository userRepository;
+    private final AdminRepository adminRepository;
+    private final ConsumerRepository consumerRepository;
+    private final SalePlaceEmployeeRepository salePlaceEmployeeRepository;
+
+    private final DeliverRepository deliverRepository;
+    public UserServiceImplementation(UserRepository userRepository, AdminRepository adminRepository, ConsumerRepository consumerRepository, SalePlaceEmployeeRepository salePlaceEmployeeRepository,
+                                     DeliverRepository deliverRepository) {
+        this.userRepository = userRepository;
+        this.adminRepository = adminRepository;
+        this.consumerRepository = consumerRepository;
+        this.salePlaceEmployeeRepository = salePlaceEmployeeRepository;
+        this.deliverRepository = deliverRepository;
+    }
+
+    @Override
+    public List<User> findAllUsers() {
+        return this.userRepository.findAll();
+    }
+
+
+
+    @Override
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+        User user = this.userRepository.findByUsername(username).orElseThrow(() -> new UsernameNotFoundException("Username not found"));
+        Long id = user.getUser_id();
+        if(this.adminRepository.findById(id).isPresent())
+            user.setUserRole(Role.ADMIN);
+        else if(this.consumerRepository.findById(id).isPresent())
+            user.setUserRole(Role.CONSUMER);
+        else if(this.deliverRepository.findById(id).isPresent())
+            user.setUserRole(Role.DELIVER);
+        else
+            user.setUserRole(Role.SALEPLACEEMPLOYEE);
+        return new UserPrincipal(user);
+    }
+
+
+}
Index: src/main/java/com/example/fooddeliverysystem/web/DeliveryController.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/web/DeliveryController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/web/DeliveryController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,79 @@
+package com.example.fooddeliverysystem.web;
+
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.OrderNotFoundException;
+import com.example.fooddeliverysystem.model.Order;
+import com.example.fooddeliverysystem.service.OrderPaymentService;
+import com.example.fooddeliverysystem.service.OrderService;
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Controller
+public class DeliveryController {
+
+    private final OrderService orderService;
+
+    private final OrderPaymentService orderPaymentService;
+    public DeliveryController(OrderService orderService, OrderPaymentService orderPaymentService) {
+        this.orderService = orderService;
+        this.orderPaymentService = orderPaymentService;
+    }
+
+    @GetMapping("/deliveryOrders")
+    public String showOrdersForDelivery(Model model){
+        List<Integer> costs = new ArrayList<>();
+        List<Order> orders = this.orderService.findAllOrdersReadyToBeDelivered();
+        for(Order order: orders){
+            try {
+                costs.add(this.orderService.calculateCostOfOrder(order.getOrderId()));
+            } catch (FoodItemNotFoundException e) {
+                System.out.println(e.getMessage());
+            }
+        }
+        model.addAttribute("orders", orders);
+        model.addAttribute("costs", costs);
+        return "delivery";
+    }
+
+    @GetMapping("/takeOrder/{id}")
+    public String deliverTakesOrder(@PathVariable Long id, HttpServletRequest httpServletRequest){
+        this.orderService.changeOrderStatus(id, "prevzemena");
+        this.orderService.updateOrderDeliver(httpServletRequest.getRemoteUser(), id);
+        return "redirect:/showOrderDeliverer";
+    }
+    @GetMapping("/showOrderDeliverer")
+    public String showDelivererAllOrders(Model model, HttpServletRequest httpServletRequest){
+        List<Integer> costs = new ArrayList<>();
+        List<Order> orders = this.orderService.findAllOrdersForDeliver(httpServletRequest.getRemoteUser());
+        System.out.println(orders);
+        for(Order order: orders){
+            try {
+                costs.add(this.orderService.calculateCostOfOrder(order.getOrderId()));
+            } catch (FoodItemNotFoundException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        model.addAttribute("orders", orders);
+        model.addAttribute("costs", costs);
+        return "ordersfordeliver";
+    }
+    @GetMapping("/orderPayment/{id}")
+    public String markOrderAsPayed(@PathVariable Long id){
+        try {
+            this.orderPaymentService.createOrderPayment(id);
+        } catch (OrderNotFoundException e) {
+            System.out.println(e.getMessage());
+        } catch (FoodItemNotFoundException e) {
+            System.out.println(e.getMessage());
+        }
+        return "redirect:/showOrderDeliverer";
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/web/ReportsController.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/web/ReportsController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/web/ReportsController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,62 @@
+package com.example.fooddeliverysystem.web;
+
+import com.example.fooddeliverysystem.service.*;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.HashSet;
+import java.util.Set;
+
+@Controller
+public class ReportsController {
+
+    private final BestPacketsForEachSalePlaceService bestPacketsForEachSalePlaceService;
+    private final MostLoyalCustomerForEachPlaceService mostLoyalCustomerForEachPlaceService;
+
+    private final FranchizeEarningsBySalePlaceService franchizeEarningsBySalePlaceService;
+
+    private final DeliverNumberOfOrdersDeliveredBySalePlaceService deliverNumberOfOrdersDeliveredBySalePlaceService;
+
+    private final TotalCouponsByCustomerService totalCouponsByCustomerService;
+    public ReportsController(BestPacketsForEachSalePlaceService bestPacketsForEachSalePlaceService,
+                             MostLoyalCustomerForEachPlaceService mostLoyalCustomerForEachPlaceService,
+                             FranchizeEarningsBySalePlaceService franchizeEarningsBySalePlaceService,
+                             DeliverNumberOfOrdersDeliveredBySalePlaceService deliverNumberOfOrdersDeliveredBySalePlaceService,
+                             TotalCouponsByCustomerService totalCouponsByCustomerService) {
+        this.bestPacketsForEachSalePlaceService = bestPacketsForEachSalePlaceService;
+        this.mostLoyalCustomerForEachPlaceService = mostLoyalCustomerForEachPlaceService;
+        this.franchizeEarningsBySalePlaceService = franchizeEarningsBySalePlaceService;
+        this.deliverNumberOfOrdersDeliveredBySalePlaceService = deliverNumberOfOrdersDeliveredBySalePlaceService;
+        this.totalCouponsByCustomerService = totalCouponsByCustomerService;
+    }
+
+    @GetMapping("/reports/bestPacketsEachSalePlace")
+    public String getBestPacketsEachSalePlace(Model model){
+        model.addAttribute("report", this.bestPacketsForEachSalePlaceService.listAll());
+        return "reportsBestPacketsEachSalePlace";
+    }
+    @GetMapping("/reports/mostLoyalCustomerForEachPlace")
+    public String getMostLoyalCustomerForEachPlace(Model model){
+        model.addAttribute("report", this.mostLoyalCustomerForEachPlaceService.listAll());
+        return "reportsMostLoyalCustomerForEachPlace";
+    }
+    @GetMapping("/reports/franchizeEarningsBySalePlace")
+    public String getFranchizeEarningsBySalePlace(Model model){
+        model.addAttribute("report", this.franchizeEarningsBySalePlaceService.listAll());
+        return "reportsFranchizeEarningsBySalePlace";
+    }
+
+    @GetMapping("/reports/DeliverNumberOfOrdersDeliveredBySalePlace")
+    public String getDeliverNumberOfOrdersDeliveredBySalePlace(Model model){
+        Set s = new HashSet(this.deliverNumberOfOrdersDeliveredBySalePlaceService.listAll());
+        model.addAttribute("report", s);
+        return "reportsDeliverNumberOfOrdersDeliveredBySalePlace";
+    }
+
+    @GetMapping("/reports/TotalCouponsByCustomer")
+    public String getTotalCouponsByCustomer(Model model){
+        model.addAttribute("report", this.totalCouponsByCustomerService.listAll());
+        return "reportsTotalCouponsByCustomer";
+    }
+}
Index: src/main/java/com/example/fooddeliverysystem/web/SalePlaceController.java
===================================================================
--- src/main/java/com/example/fooddeliverysystem/web/SalePlaceController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
+++ src/main/java/com/example/fooddeliverysystem/web/SalePlaceController.java	(revision 8d11f8c8bebea20f293d0a27e03c1e19c049ba9b)
@@ -0,0 +1,156 @@
+package com.example.fooddeliverysystem.web;
+
+import com.example.fooddeliverysystem.exceptions.FoodItemNotFoundException;
+import com.example.fooddeliverysystem.exceptions.SalePlaceNotFoundException;
+import com.example.fooddeliverysystem.model.*;
+import com.example.fooddeliverysystem.model.objects.FoodItemsWithQuantity;
+import com.example.fooddeliverysystem.repository.PriceRepository;
+import com.example.fooddeliverysystem.repository.storedprocedure.OrderCostCalcualte;
+import com.example.fooddeliverysystem.service.*;
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Controller
+public class SalePlaceController {
+
+    private final OrderCostCalcualte orderCostCalcualte;
+
+    private final SalePlaceService salePlaceService;
+    private final PriceService priceService;
+    private final OrderService orderService;
+    private final HasFoodService hasFoodService;
+    private final FoodItemService foodItemService;
+
+
+    public SalePlaceController(SalePlaceService salePlaceService, PriceService priceService, OrderService orderService, HasFoodService hasFoodService,
+                               FoodItemService foodItemService, OrderCostCalcualte orderCostCalcualte) {
+        this.salePlaceService = salePlaceService;
+        this.priceService = priceService;
+        this.orderService = orderService;
+        this.hasFoodService = hasFoodService;
+        this.foodItemService = foodItemService;
+        this.orderCostCalcualte = orderCostCalcualte;
+    }
+
+    @GetMapping("/salePlaces")
+    public String showSalePlaces(Model model) {
+        List<SalePlace> salePlaceList = this.salePlaceService.findAll();
+        model.addAttribute("salePlaces", salePlaceList);
+
+        return "saleplaces";
+    }
+
+    @GetMapping("/salePlace/{id}")
+    public String showSalePlaceFooItems(@PathVariable Long id, Model model) {
+        try {
+            model.addAttribute("foodItems", this.salePlaceService.findSalePlaceServiceById(id).getFoodItemList());
+            model.addAttribute("salePlaceId", id);
+            List<Price> prices = new ArrayList<>();
+            this.salePlaceService.findSalePlaceServiceById(id)
+                    .getFoodItemList()
+                    .forEach(foodItem -> {
+                        try {
+                            prices.add(this.priceService.findCurrentPriceForFoodItem(foodItem));
+                        } catch (FoodItemNotFoundException e) {
+                            model.addAttribute("foodItemError", e.getMessage());
+                        }
+                    });
+            System.out.println(prices);
+
+            model.addAttribute("prices", prices);
+        } catch (SalePlaceNotFoundException salePlaceNotFoundException) {
+            model.addAttribute("error", salePlaceNotFoundException.getMessage());
+        }
+        return "saleplacefooditems";
+    }
+
+    @PostMapping("/salePlace/{id}")
+    public String createOrderInSalePlace(@PathVariable Long id,
+                                         @RequestParam List<Long> foodIds,
+                                         @RequestParam List<Integer> foodPrice,
+                                         @RequestParam List<Integer> quantity,
+                                         @RequestParam String typeOfPayment,
+                                         HttpServletRequest httpServletRequest) {
+        try {
+            this.orderService.placeOrder(typeOfPayment, id, foodIds, foodPrice, quantity, httpServletRequest.getRemoteUser());
+
+        } catch (SalePlaceNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+        return "redirect:/checkOrderStatus";
+    }
+
+    @GetMapping("/salePlace/Orders")
+    public String showSalePlaceOrders(Model model, HttpServletRequest httpServletRequest) {
+
+        Map<Long, List<FoodItem>> map = new HashMap<>();
+        String username = httpServletRequest.getRemoteUser();
+        try {
+            List<Order> orders = this.salePlaceService.findAllCreatedOrders(username).stream().sorted(Comparator.comparingLong(Order::getOrderId)).collect(Collectors.toList());
+            List<OrderHasFood> orderHasFoodList = new ArrayList<>();
+            model.addAttribute("orders", orders);
+            List<List<OrderHasFood>> outer = new ArrayList<>();
+            for (Order order : orders) {
+                List<OrderHasFood> inner = this.hasFoodService.findAllFoodsInOrder(order.getOrderId());
+                outer.add(inner);
+                List<FoodItem> items = new ArrayList<>();
+                for (OrderHasFood orderHasFood : inner) {
+                    FoodItem foodItems = this.salePlaceService.findSalePlaceServiceById(this.salePlaceService.findSalePlaceForUser(username).getSalePalceId())
+                            .getFoodItemList()
+                            .stream().filter(foodItem -> foodItem.getFoodItemId().equals(orderHasFood.getOrderHasFoodKey().getFoodItemId()))
+                            .findFirst().get();
+                    items.add(foodItems);
+
+                }
+                map.put(order.getOrderId(), items);
+                model.addAttribute("quantity", outer);
+            }
+
+            model.addAttribute("orderHasFoods", map);
+
+        } catch (SalePlaceNotFoundException e) {
+            model.addAttribute("error", "sale place not found");
+        }
+        return "saleplaceorders";
+
+    }
+
+    @GetMapping("/changeOrderStatus/{id}")
+    public String changeOrderStauts(@PathVariable Long id) {
+        this.orderService.changeOrderStatus(id, "spremna");
+        return "redirect:/salePlace/Orders";
+    }
+
+    @GetMapping("/checkOrderStatus")
+    public String showOrderStatusToUser(HttpServletRequest httpServletRequest, Model model) {
+        String username = httpServletRequest.getRemoteUser();
+        List<Order> orders = this.orderService.findAllOrdersForCustomer(username);
+        model.addAttribute("orders", orders.stream().sorted((a,b) -> Long.compare(b.getOrderId(), a.getOrderId())).collect(Collectors.toList()));
+        Map<Long, List<FoodItemsWithQuantity>> foodNamesInOrder = new HashMap<>();
+        for(Order order: orders){
+            foodNamesInOrder.put(order.getOrderId(), this.hasFoodService.findAllFoodnamesInOrder(order.getOrderId()));
+        }
+
+        model.addAttribute("foodNames", foodNamesInOrder);
+        return "showOrderStatusCustomer";
+    }
+
+    @GetMapping("/home")
+    public String showHomePage() {
+
+        return "home";
+    }
+    @GetMapping("/")
+    public String showHome() {
+        return "home";
+    }
+}
