Index: src/main/java/project/fmo/app/projcetfmo/Model/AdminKorisnik.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/AdminKorisnik.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/AdminKorisnik.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
@@ -8,5 +8,5 @@
 @Table(name = "admin_korisnik", schema = "project", catalog = "db_202223z_va_prj_fmo")
 public class AdminKorisnik {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "id_korisnik")
Index: src/main/java/project/fmo/app/projcetfmo/Model/Cena.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Cena.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Cena.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.sql.Date;
@@ -7,11 +7,10 @@
 
 @Entity
+@Table(schema = "project", name = "cena",  catalog = "db_202223z_va_prj_fmo")
 @IdClass(CenaPK.class)
 public class Cena {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_produkt")
-    private int idProdukt;
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int  idProdukt;
     @Id
     @Column(name = "cena_od")
@@ -23,4 +22,18 @@
     @Column(name = "iznos")
     private int iznos;
+
+    public Cena(){}
+    public Cena(int idProdukt, Date cenaOd, Date cenaDo, int iznos) {
+        this.idProdukt = idProdukt;
+        this.cenaOd = cenaOd;
+        this.cenaDo = cenaDo;
+        this.iznos = iznos;
+    }
+
+    public Cena(int idProdukt, Date cenaOd, int iznos) {
+        this.idProdukt = idProdukt;
+        this.cenaOd = cenaOd;
+        this.iznos = iznos;
+    }
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/CenaPK.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/CenaPK.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/CenaPK.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,8 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import javax.persistence.*;
 
 import java.io.Serializable;
@@ -13,10 +10,14 @@
     @Column(name = "id_produkt")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int idProdukt;
     @Column(name = "cena_od")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Date cenaOd;
+
+    public CenaPK (){}
+    public CenaPK(Integer idProdukt, Date cenaOd) {
+        this.idProdukt = idProdukt;
+        this.cenaOd = cenaOd;
+    }
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/Dostava.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Dostava.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Dostava.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,7 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import project.fmo.app.projcetfmo.Service.impl.DostavaServiceImpl;
+
+import javax.persistence.*;
 
 import java.sql.Date;
@@ -7,12 +9,12 @@
 
 @Entity
+@Table(schema = "project", name = "dostava",  catalog = "db_202223z_va_prj_fmo")
 public class Dostava {
-    @Basic
-    @Column(name = "id_korisnik")
-    private int idKorisnik;
-    @Basic
-    @Column(name = "id_naracka")
-    private int idNaracka;
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @ManyToOne
+    @JoinColumn(name = "id_korisnik")
+    private Dostavuvac dostavuvac;
+    @OneToOne
+    @JoinColumn(name = "id_naracka")
+    private Naracka naracka;
     @Id
     @Column(name = "id_dostava")
@@ -25,18 +27,28 @@
     private String status;
 
+    public Dostava (){}
+
+    public Dostava(Dostavuvac dostavuvac, Naracka naracka, int idDostava, Date datum, String status) {
+        this.dostavuvac = dostavuvac;
+        this.naracka = naracka;
+        this.idDostava = idDostava;
+        this.datum = datum;
+        this.status = status;
+    }
+
     public int getIdKorisnik() {
-        return idKorisnik;
+        return dostavuvac.getIdKorisnik();
     }
 
     public void setIdKorisnik(int idKorisnik) {
-        this.idKorisnik = idKorisnik;
+        this.dostavuvac.setIdKorisnik(idKorisnik);
     }
 
     public int getIdNaracka() {
-        return idNaracka;
+        return naracka.getIdNaracka();
     }
 
     public void setIdNaracka(int idNaracka) {
-        this.idNaracka = idNaracka;
+        this.naracka.setIdNaracka(idNaracka);
     }
 
@@ -70,10 +82,10 @@
         if (o == null || getClass() != o.getClass()) return false;
         Dostava dostava = (Dostava) o;
-        return idKorisnik == dostava.idKorisnik && idNaracka == dostava.idNaracka && idDostava == dostava.idDostava && Objects.equals(datum, dostava.datum) && Objects.equals(status, dostava.status);
+        return dostavuvac == dostava.dostavuvac && naracka == dostava.naracka && idDostava == dostava.idDostava && Objects.equals(datum, dostava.datum) && Objects.equals(status, dostava.status);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(idKorisnik, idNaracka, idDostava, datum, status);
+        return Objects.hash(dostavuvac, naracka, idDostava, datum, status);
     }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Model/Dostavuvac.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Dostavuvac.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Dostavuvac.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,14 +1,17 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "dostavuvac",  catalog = "db_202223z_va_prj_fmo")
 public class Dostavuvac {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "id_korisnik")
     private int idKorisnik;
+
+    public Dostavuvac(){}
 
     public int getIdKorisnik() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/Kategorija.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Kategorija.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Kategorija.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,9 +1,10 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "kategorija",  catalog = "db_202223z_va_prj_fmo")
 public class Kategorija {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -14,4 +15,10 @@
     @Column(name = "ime")
     private String ime;
+
+
+    public Kategorija(){}
+    public Kategorija(String ime) {
+        this.ime = ime;
+    }
 
     public int getIdKategorija() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/Korisnik.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Korisnik.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Korisnik.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,11 +1,17 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
 
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import javax.persistence.*;
 import java.sql.Timestamp;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Objects;
 
 @Entity
-public class Korisnik {
+@Table(schema = "project", name = "korisnik",  catalog = "db_202223z_va_prj_fmo")
+public class Korisnik implements UserDetails {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
@@ -21,4 +27,14 @@
     @Column(name = "kreiran_na_datum")
     private Timestamp kreiranNaDatum;
+
+
+    public Korisnik(){
+
+    }
+    public Korisnik(String imePrezime, String passwordKorisnik, Timestamp kreiranNaDatum) {
+        this.imePrezime = imePrezime;
+        this.passwordKorisnik = passwordKorisnik;
+        this.kreiranNaDatum = kreiranNaDatum;
+    }
 
     public int getIdKorisnik() {
@@ -66,3 +82,38 @@
         return Objects.hash(idKorisnik, imePrezime, passwordKorisnik, kreiranNaDatum);
     }
+
+    @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/project/fmo/app/projcetfmo/Model/Kupuvac.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Kupuvac.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Kupuvac.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,11 +1,12 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
 
+import javax.persistence.*;
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "kupuvac",  catalog = "db_202223z_va_prj_fmo")
 public class Kupuvac {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "id_korisnik")
@@ -14,4 +15,12 @@
     @Column(name = "mail")
     private String mail;
+
+    public Kupuvac(int idKorisnik, String mail) {
+        this.idKorisnik=idKorisnik;
+        this.mail=mail;
+    }
+
+    public Kupuvac() {
+    }
 
     public int getIdKorisnik() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/Magacin.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Magacin.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Magacin.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,11 +1,12 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "magacin",  catalog = "db_202223z_va_prj_fmo")
 public class Magacin {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "id_magacin")
Index: src/main/java/project/fmo/app/projcetfmo/Model/Magacioner.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Magacioner.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Magacioner.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,17 +1,17 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "magacioner",  catalog = "db_202223z_va_prj_fmo")
 public class Magacioner {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_korisnik")
     private int idKorisnik;
-    @Basic
-    @Column(name = "id_magacin")
-    private int idMagacin;
+    @ManyToOne
+    @JoinColumn(name = "id_magacin")
+    private Magacin magacin;
 
     public int getIdKorisnik() {
@@ -23,10 +23,10 @@
     }
 
-    public int getIdMagacin() {
-        return idMagacin;
+    public Magacin getMagacin() {
+        return magacin;
     }
 
-    public void setIdMagacin(int idMagacin) {
-        this.idMagacin = idMagacin;
+    public void setMagacin(Magacin magacin) {
+        this.magacin = magacin;
     }
 
@@ -36,10 +36,10 @@
         if (o == null || getClass() != o.getClass()) return false;
         Magacioner that = (Magacioner) o;
-        return idKorisnik == that.idKorisnik && idMagacin == that.idMagacin;
+        return idKorisnik == that.idKorisnik && magacin == that.magacin;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(idKorisnik, idMagacin);
+        return Objects.hash(idKorisnik, magacin);
     }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Model/Naracka.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Naracka.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Naracka.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.sql.Date;
@@ -7,4 +7,5 @@
 
 @Entity
+@Table(schema = "project", name = "naracka",  catalog = "db_202223z_va_prj_fmo")
 public class Naracka {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -24,7 +25,17 @@
     @Column(name = "adresa")
     private String adresa;
-    @Basic
-    @Column(name = "id_korisnik")
-    private int idKorisnik;
+    @ManyToOne
+    @JoinColumn(name = "id_korisnik")
+    private Kupuvac kupuvac;
+
+    public Naracka(){}
+
+    public Naracka(int vkupnoSuma, Date datum, String status, String adresa, Kupuvac kupuvac) {
+        this.vkupnoSuma = vkupnoSuma;
+        this.datum = datum;
+        this.status = status;
+        this.adresa = adresa;
+        this.kupuvac = kupuvac;
+    }
 
     public int getIdNaracka() {
@@ -69,9 +80,9 @@
 
     public int getIdKorisnik() {
-        return idKorisnik;
+        return kupuvac.getIdKorisnik();
     }
 
     public void setIdKorisnik(int idKorisnik) {
-        this.idKorisnik = idKorisnik;
+        this.kupuvac.setIdKorisnik(idKorisnik);
     }
 
@@ -81,10 +92,10 @@
         if (o == null || getClass() != o.getClass()) return false;
         Naracka naracka = (Naracka) o;
-        return idNaracka == naracka.idNaracka && vkupnoSuma == naracka.vkupnoSuma && idKorisnik == naracka.idKorisnik && Objects.equals(datum, naracka.datum) && Objects.equals(status, naracka.status) && Objects.equals(adresa, naracka.adresa);
+        return idNaracka == naracka.idNaracka && vkupnoSuma == naracka.vkupnoSuma && kupuvac == naracka.kupuvac && Objects.equals(datum, naracka.datum) && Objects.equals(status, naracka.status) && Objects.equals(adresa, naracka.adresa);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(idNaracka, vkupnoSuma, datum, status, adresa, idKorisnik);
+        return Objects.hash(idNaracka, vkupnoSuma, datum, status, adresa, kupuvac);
     }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProdukt.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProdukt.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProdukt.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
@@ -9,9 +9,7 @@
 @IdClass(NarackaSodrziProduktPK.class)
 public class NarackaSodrziProdukt {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_produkt")
     private int idProdukt;
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_naracka")
@@ -23,4 +21,13 @@
     @Column(name = "cena")
     private int cena;
+
+    public NarackaSodrziProdukt(){}
+
+    public NarackaSodrziProdukt(int idProdukt, int idNaracka, int kolicina, int cena) {
+        this.idProdukt = idProdukt;
+        this.idNaracka = idNaracka;
+        this.kolicina = kolicina;
+        this.cena = cena;
+    }
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProduktPK.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProduktPK.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/NarackaSodrziProduktPK.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,8 +1,6 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import javax.persistence.*;
+
 
 import java.io.Serializable;
@@ -12,10 +10,10 @@
     @Column(name = "id_produkt")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int idProdukt;
     @Column(name = "id_naracka")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int idNaracka;
+
+    public NarackaSodrziProduktPK(){}
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/Produkt.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Produkt.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Produkt.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,9 +1,11 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
+import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "produkt",  catalog = "db_202223z_va_prj_fmo")
 public class Produkt {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -17,7 +19,16 @@
     @Column(name = "opis")
     private String opis;
-    @Basic
-    @Column(name = "id_korisnik")
-    private int idKorisnik;
+
+    @ManyToOne
+    @JoinColumn(name = "id_korisnik")
+    private AdminKorisnik adminKorisnik;
+
+    public Produkt(){}
+
+    public Produkt(String ime, String opis, AdminKorisnik adminKorisnik) {
+        this.ime = ime;
+        this.opis = opis;
+        this.adminKorisnik = adminKorisnik;
+    }
 
     public int getIdProdukt() {
@@ -46,9 +57,9 @@
 
     public int getIdKorisnik() {
-        return idKorisnik;
+        return adminKorisnik.getIdKorisnik();
     }
 
-    public void setIdKorisnik(int idKorisnik) {
-        this.idKorisnik = idKorisnik;
+    public void setIdKorisnik(AdminKorisnik idKorisnik) {
+        this.adminKorisnik = idKorisnik;
     }
 
@@ -58,10 +69,10 @@
         if (o == null || getClass() != o.getClass()) return false;
         Produkt produkt = (Produkt) o;
-        return idProdukt == produkt.idProdukt && idKorisnik == produkt.idKorisnik && Objects.equals(ime, produkt.ime) && Objects.equals(opis, produkt.opis);
+        return idProdukt == produkt.idProdukt && adminKorisnik == produkt.adminKorisnik && Objects.equals(ime, produkt.ime) && Objects.equals(opis, produkt.opis);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(idProdukt, ime, opis, idKorisnik);
+        return Objects.hash(idProdukt, ime, opis, adminKorisnik);
     }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorija.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorija.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorija.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
@@ -9,12 +9,23 @@
 @IdClass(ProduktEOdKategorijaPK.class)
 public class ProduktEOdKategorija {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_produkt")
     private int idProdukt;
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
     @Column(name = "id_kategorija")
     private int idKategorija;
+
+    public ProduktEOdKategorija(int idProdukt, int idKategorija) {
+        this.idProdukt = idProdukt;
+        this.idKategorija = idKategorija;
+    }
+
+    public ProduktEOdKategorija() {
+    }
+
+    public ProduktEOdKategorija(ProduktEOdKategorijaPK produktEOdKategorijaPK) {
+        this.idKategorija= produktEOdKategorijaPK.getIdKategorija();
+        this.idProdukt=produktEOdKategorijaPK.getIdProdukt();
+    }
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorijaPK.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorijaPK.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/ProduktEOdKategorijaPK.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,8 +1,6 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import javax.persistence.*;
+
 
 import java.io.Serializable;
@@ -12,10 +10,16 @@
     @Column(name = "id_produkt")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int idProdukt;
     @Column(name = "id_kategorija")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     private int idKategorija;
+
+
+    public ProduktEOdKategorijaPK(){}
+    public ProduktEOdKategorijaPK(int idProdukt, int idKategorija) {
+        this.idKategorija=idKategorija;
+        this.idProdukt=idProdukt;
+    }
 
     public int getIdProdukt() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacin.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacin.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacin.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,5 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
Index: src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacinPK.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacinPK.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/ProduktEVoMagacinPK.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,8 +1,6 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import javax.persistence.*;
+
 
 import java.io.Serializable;
Index: src/main/java/project/fmo/app/projcetfmo/Model/Telefonskibroj.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/Telefonskibroj.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/Telefonskibroj.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,19 +1,27 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.*;
+import javax.persistence.*;
 
 import java.util.Objects;
 
 @Entity
+@Table(schema = "project", name = "telefonskibroj",  catalog = "db_202223z_va_prj_fmo")
 @IdClass(TelefonskibrojPK.class)
 public class Telefonskibroj {
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "id_korisnik")
     private int idKorisnik;
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
     @Id
     @Column(name = "telefonski_broj")
     private String telefonskiBroj;
+
+    public Telefonskibroj(){}
+
+    public Telefonskibroj(TelefonskibrojPK telefonskibrojPK) {
+        this.idKorisnik = telefonskibrojPK.getIdKorisnik();
+        this.telefonskiBroj = telefonskibrojPK.getTelefonskiBroj();
+    }
 
     public int getIdKorisnik() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/TelefonskibrojPK.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/TelefonskibrojPK.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/TelefonskibrojPK.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,8 +1,5 @@
-package model;
+package project.fmo.app.projcetfmo.Model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import javax.persistence.*;
 
 import java.io.Serializable;
@@ -12,10 +9,17 @@
     @Column(name = "id_korisnik")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int idKorisnik;
     @Column(name = "telefonski_broj")
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private String telefonskiBroj;
+
+
+    public TelefonskibrojPK(){
+
+    }
+    public TelefonskibrojPK(int idKorisnik, String telefonskiBroj) {
+        this.idKorisnik = idKorisnik;
+        this.telefonskiBroj = telefonskiBroj;
+    }
 
     public int getIdKorisnik() {
Index: src/main/java/project/fmo/app/projcetfmo/Model/exception/InvalidUserCredentialsException.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Model/exception/InvalidUserCredentialsException.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Model/exception/InvalidUserCredentialsException.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,8 @@
-package project.fmo.app.projcetfmo.Model.exception;public class InvalidUserCredentialsException {
+package project.fmo.app.projcetfmo.Model.exception;
+
+public class InvalidUserCredentialsException extends RuntimeException {
+
+    public InvalidUserCredentialsException() {
+        super("Invalid user credentials exception");
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/AdminRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/AdminRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/AdminRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,14 @@
-package project.fmo.app.projcetfmo.Repository;public interface AdminRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.apache.catalina.User;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import project.fmo.app.projcetfmo.Model.AdminKorisnik;
+
+import java.util.Collection;
+
+public interface AdminRepository extends JpaRepository<AdminKorisnik, Integer> {
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/CenaRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/CenaRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/CenaRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,10 @@
-package project.fmo.app.projcetfmo.Repository;public interface CenaRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Cena;
+import project.fmo.app.projcetfmo.Model.CenaPK;
+
+public interface CenaRepository extends JpaRepository<Cena, CenaPK> {
+    Cena findByIdProdukt(Integer idProdukt);
+    void deleteByIdProdukt(Integer idProdukt);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/DostavaRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/DostavaRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/DostavaRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,12 @@
-package project.fmo.app.projcetfmo.Repository;public interface DostavaRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Dostava;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+
+import java.util.List;
+
+public interface DostavaRepository extends JpaRepository<Dostava, Integer> {
+    List<Dostava> findByDostavuvacAndStatus(Dostavuvac dostavuvac, String status);
+    List<Dostava> findByStatus(String status);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/DostavuvacRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/DostavuvacRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/DostavuvacRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,7 @@
-package project.fmo.app.projcetfmo.Repository;public interface DostavuvacRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+
+public interface DostavuvacRepository extends JpaRepository<Dostavuvac, Integer> {
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/KategorijaRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/KategorijaRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/KategorijaRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,7 @@
-package project.fmo.app.projcetfmo.Repository;public interface KategorijaRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Kategorija;
+
+public interface KategorijaRepository extends JpaRepository<Kategorija, Integer> {
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/KorisnikRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/KorisnikRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/KorisnikRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,43 @@
-package project.fmo.app.projcetfmo.Repository;public interface KorisnikRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+
+import java.util.List;
+
+public interface KorisnikRepository extends JpaRepository<Korisnik, Integer> {
+    Korisnik findByImePrezime(String s);
+    Korisnik findByImePrezimeAndPasswordKorisnik(String s, String p);
+
+    @Query(value ="select k.id_korisnik,k.ime_prezime,\n" +
+            "\n" +
+            "(select count(n) from project.naracka as n\n" +
+            "where n.id_korisnik  = k.id_korisnik)\n" +
+            "as vkupno_naracki, \n" +
+            "\n" +
+            "(select avg(vkupno_suma) from project.naracka )\n" +
+            "as prosecna_suma_na_naracka_za_site_kupuvaci,\n" +
+            "\n" +
+            "(select sum(n3.vkupno_suma) from project.naracka as n3 \n" +
+            "where k.id_korisnik = n3.id_korisnik) \n" +
+            "as vkupno_suma_od_site_naracki_na_kupuvacot,\n" +
+            "\n" +
+            "(select count(n2) from project.naracka as n2\n" +
+            "where k.id_korisnik = n2.id_korisnik \n" +
+            "and n2.datum between now() - interval '1year'  and now() \n" +
+            "and n2.vkupno_suma > (select avg(vkupno_suma) from project.naracka) )\n" +
+            "as vkupno_naracki_nad_prosek_na_korisnikot,\n" +
+            "\n" +
+            "(select sum(n4.vkupno_suma) from project.naracka as n4 \n" +
+            "where  k.id_korisnik = n4.id_korisnik \n" +
+            "and n4.datum between now() - interval '1year' and now() \n" +
+            "and n4.vkupno_suma > (select avg(vkupno_suma) from project.naracka) ) \n" +
+            "as vkupno_suma_na_naracki_nad_prosek_za_korisnikot\n" +
+            "\n" +
+            "from project.korisnik as k \n" +
+            "inner join project.kupuvac as  k2 on k.id_korisnik = k2.id_korisnik \n" +
+            "group by k.ime_prezime,k.id_korisnik ;" ,
+    nativeQuery = true)
+    List<Object> statistics2();
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/KupuvacRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/KupuvacRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/KupuvacRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,7 @@
-package project.fmo.app.projcetfmo.Repository;public interface KupuvacRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+
+public interface KupuvacRepository extends JpaRepository<Kupuvac, Integer> {
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/NarackaRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/NarackaRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/NarackaRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,12 @@
-package project.fmo.app.projcetfmo.Repository;public class NarackaRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+import project.fmo.app.projcetfmo.Model.Naracka;
+
+public interface NarackaRepository extends JpaRepository<Naracka, Integer> {
+    Naracka findByKupuvacAndStatus(Kupuvac kupuvac, String status);
+    Naracka findByKupuvacAndIdNaracka(Kupuvac kupuvac, Integer idN);
+    Naracka findByKupuvac(Kupuvac k);
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/NarackaSodrziProduktRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/NarackaSodrziProduktRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/NarackaSodrziProduktRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,15 @@
-package project.fmo.app.projcetfmo.Repository;public interface NarackaSodrziProduktRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.NarackaSodrziProdukt;
+import project.fmo.app.projcetfmo.Model.NarackaSodrziProduktPK;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import java.util.List;
+
+public interface NarackaSodrziProduktRepository extends JpaRepository<NarackaSodrziProdukt, NarackaSodrziProduktPK> {
+    NarackaSodrziProdukt findByIdProduktAndIdNaracka(Integer idP, Integer idN);
+    List<NarackaSodrziProdukt> findByIdNaracka(Integer id);
+    void deleteByIdProdukt(Integer id);
+    List<NarackaSodrziProdukt> findByIdProdukt(Integer id);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/ProduktEOdKategorijaRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/ProduktEOdKategorijaRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/ProduktEOdKategorijaRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,11 @@
-package project.fmo.app.projcetfmo.Repository;public interface ProduktEOdKategorijaRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.ProduktEOdKategorija;
+import project.fmo.app.projcetfmo.Model.ProduktEOdKategorijaPK;
+
+public interface ProduktEOdKategorijaRepository extends JpaRepository<ProduktEOdKategorija, ProduktEOdKategorijaPK> {
+    ProduktEOdKategorija findByIdProdukt(Integer idProdukt);
+    void deleteByIdProdukt(Integer idProdukt);
+    ProduktEOdKategorija findByIdProduktAndIdKategorija(Integer idProdukt,Integer idKategorija);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/ProduktRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/ProduktRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/ProduktRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,52 @@
-package project.fmo.app.projcetfmo.Repository;public interface ProduktRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import project.fmo.app.projcetfmo.Model.Produkt;
+
+import java.util.List;
+
+public interface ProduktRepository extends JpaRepository<Produkt, Integer> {
+    @Query(value = """
+            select p.id_produkt,p.ime,\s
+            count(nsp) as broj_na_naracki_vo_koi_e_prisuten_produktot,\s
+            sum(nsp.kolicina) as kolicina_prodadeno_od_produktot,\s
+
+            (select avg(n4.vkupno_suma) from project.naracka as n4\s
+            join project.naracka_sodrzi_produkt nsp4 on n4.id_naracka = nsp4.id_naracka \s
+            where n4.id_naracka =nsp4.id_naracka and p.id_produkt = nsp4.id_produkt and n4.datum between now() - interval '3months'\s
+            and now())
+            as prosecna_suma_na_naracka_vo_koja_se_sodrzi_produktot,
+
+            (select count(n2) from project.naracka as n2\040
+            join project.naracka_sodrzi_produkt nsp2 on n2.id_naracka = nsp2.id_naracka\s
+            where nsp2.id_produkt = p.id_produkt and n2.adresa like '/'\s
+            and n2.datum between now() - interval '3months' and now())
+            as broj_na_naracki_na_produktot_koi_korisnikot_sam_ke_gi_podigne,
+
+            (select sum(nsp2.kolicina) from project.naracka as n2\s
+            join project.naracka_sodrzi_produkt nsp2 on n2.id_naracka = nsp2.id_naracka\s
+            where nsp2.id_produkt = p.id_produkt and n2.adresa like '/'\s
+            and n2.datum between now() - interval '3months' and now())\s
+            as  kolicina_prodadena_na_produktot_bez_dostava,
+
+            (select count(n3) from project.naracka as n3\s
+            join project.naracka_sodrzi_produkt nsp3 on n3.id_naracka = nsp3.id_naracka\s
+            where nsp3.id_produkt = p.id_produkt and n3.adresa not like '/' and n3.datum between now() - interval '3months' and now())
+            as broj_na_naracki_na_produktot_koi_ke_bidat_dostaveni_na_korisnikot,
+
+            (select sum(nsp3.kolicina) from project.naracka as n3\s
+            join project.naracka_sodrzi_produkt nsp3 on n3.id_naracka = nsp3.id_naracka
+            where nsp3.id_produkt = p.id_produkt and n3.adresa not like '/' and n3.datum between now() - interval '3months' and now())
+            as kolicina_prodadena_na_produktot_preku_dostava
+
+            from project.produkt as p
+            join project.naracka_sodrzi_produkt as nsp on p.id_produkt = nsp.id_produkt\s
+            join project.naracka as n on nsp.id_naracka = n.id_naracka\s
+            where n.datum between now() - interval '3months' and now()
+            group by p.ime,p.id_produkt;""",
+    nativeQuery = true)
+    List<Object> statistics1();
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Repository/TelefnoskiBrojRepository.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Repository/TelefnoskiBrojRepository.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Repository/TelefnoskiBrojRepository.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,9 @@
-package project.fmo.app.projcetfmo.Repository;public class TelefnoskiBrojRepository {
+package project.fmo.app.projcetfmo.Repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import project.fmo.app.projcetfmo.Model.Telefonskibroj;
+import project.fmo.app.projcetfmo.Model.TelefonskibrojPK;
+
+public interface TelefnoskiBrojRepository extends JpaRepository<Telefonskibroj, TelefonskibrojPK> {
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/AdminService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/AdminService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/AdminService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,4 @@
-package project.fmo.app.projcetfmo.Service;public interface AdminService {
+package project.fmo.app.projcetfmo.Service;
+
+public interface AdminService {
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/AuthService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/AuthService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/AuthService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,7 @@
-package project.fmo.app.projcetfmo.Service;public interface AuthService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Korisnik;
+
+public interface AuthService {
+    Korisnik login(String username, String password);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/CenaService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/CenaService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/CenaService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,20 @@
-package project.fmo.app.projcetfmo.Service;public interface CenaService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Cena;
+
+import java.util.Date;
+import java.util.List;
+
+public interface CenaService {
+
+
+    Cena save(Integer idProdukt, java.sql.Date cenaOd, java.sql.Date cenaDo, int iznos);
+    Cena edit (Integer idProdukt, java.sql.Date cenaOd, java.sql.Date cenaDo, int iznos);
+
+    List<Cena> findAll();
+
+    Cena findByIdProdukt(int idProdukt);
+    void deleteByIdProdukt(int idProdukt);
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/DostavaService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/DostavaService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/DostavaService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,14 @@
-package project.fmo.app.projcetfmo.Service;public interface DostavaService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Dostava;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+
+import java.util.List;
+
+public interface DostavaService {
+
+    List<Dostava> findByIdKorisnikAndStatus(Dostavuvac dostavuvac, String status);
+    Dostava edit(Integer id);
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/DostavuvaceService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/DostavuvaceService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/DostavuvaceService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,10 @@
-package project.fmo.app.projcetfmo.Service;public interface DostavuvaceService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+
+import javax.persistence.criteria.CriteriaBuilder;
+
+public interface DostavuvaceService {
+
+    Dostavuvac findById(Integer id);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/KategorijaService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/KategorijaService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/KategorijaService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,14 @@
-package project.fmo.app.projcetfmo.Service;public interface KategorijaService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Kategorija;
+
+import java.util.List;
+
+public interface KategorijaService {
+
+
+    List<Kategorija> findAll();
+    Kategorija save(String ime);
+    Kategorija edit(Integer id, String ime);
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/KorisnikService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/KorisnikService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/KorisnikService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,17 @@
-package project.fmo.app.projcetfmo.Service;public interface KorisnikService {
+package project.fmo.app.projcetfmo.Service;
+
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+import project.fmo.app.projcetfmo.Repository.KorisnikRepository;
+
+import java.sql.Date;
+import java.util.List;
+
+public interface KorisnikService extends UserDetailsService {
+    Korisnik findbyImePrezime (String ime);
+    Korisnik findById(Integer id);
+    Korisnik register(String username, String password, String repeatPassword, String mail, String number);
+
+    List<Object> statistics2();
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/KupuvacService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/KupuvacService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/KupuvacService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,8 @@
-package project.fmo.app.projcetfmo.Service;public class KupuvacRepository {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+
+public interface KupuvacService {
+
+    Kupuvac findById(Integer id);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/NarackaService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/NarackaService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/NarackaService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,23 @@
-package project.fmo.app.projcetfmo.Service;public interface NarackaService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+import project.fmo.app.projcetfmo.Model.Naracka;
+import project.fmo.app.projcetfmo.Model.Produkt;
+
+import java.sql.Date;
+import java.util.List;
+
+public interface NarackaService {
+
+    List<Produkt> allProductsInOrder(Integer narackaId);
+    Naracka getActiveOrder(String username);
+    Naracka findByIdKorisniktAndStatus(Integer id, String s);
+
+    Naracka save(int vkupnoSuma, Date date, String status, String adresa, Kupuvac k);
+    Naracka edit(int vkupnoSuma,String status,String adresa, Integer idK, Integer idN);
+    Naracka findByKupuvac(Kupuvac k);
+    Naracka findByIdNaracka(Integer id);
+    List<Naracka> findAll();
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/NarackaSodrziProduktService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/NarackaSodrziProduktService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/NarackaSodrziProduktService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,18 @@
-package project.fmo.app.projcetfmo.Service;public interface NarackaSodrziProduktService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.NarackaSodrziProdukt;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import java.util.List;
+
+public interface NarackaSodrziProduktService {
+    NarackaSodrziProdukt findByIdProduktAndIdNaracka(Integer idP, Integer idN);
+    NarackaSodrziProdukt edit(Integer idP, Integer idN, Integer quantity, Integer price);
+    NarackaSodrziProdukt save(Integer idP, Integer idN, Integer quantity, Integer price);
+    List<NarackaSodrziProdukt> findByIdNaracka(Integer id);
+    void deleteProduct(Integer id);
+
+    List<NarackaSodrziProdukt> findAll();
+
+    List<NarackaSodrziProdukt> findByIdProdukt(Integer id);
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/ProduktEOdKategorijaService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/ProduktEOdKategorijaService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/ProduktEOdKategorijaService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,20 @@
-package project.fmo.app.projcetfmo.Service;public interface ProduktEOdKategorijaService {
+package project.fmo.app.projcetfmo.Service;
+
+import project.fmo.app.projcetfmo.Model.ProduktEOdKategorija;
+
+import java.util.List;
+
+public interface ProduktEOdKategorijaService {
+
+
+    ProduktEOdKategorija save(int idProdukt, int idKategorija);
+    ProduktEOdKategorija edit(int idProdukt, int idKategorija);
+
+    List<ProduktEOdKategorija> findAll();
+
+    ProduktEOdKategorija findByIdProdukt(int idProdukt);
+    void deleteByIdProdukt(int idProdukt);
+
+    ProduktEOdKategorija findByIdProduktAndIdKategorija(int idProdukt, int idKategorija);
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/ProduktService.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/ProduktService.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/ProduktService.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,19 @@
-package project.fmo.app.projcetfmo.Service;public interface ProduktService {
+package project.fmo.app.projcetfmo.Service;
+
+import org.springframework.data.domain.Page;
+import project.fmo.app.projcetfmo.Model.Produkt;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface ProduktService {
+
+    Optional<Produkt> findById(Integer id);
+    List<Produkt> findAll();
+    Produkt save(String ime, String opis);
+    Produkt edit(Integer id,String ime, String opis);
+    void deleteById(Integer id);
+
+    List<Object> statistics1();
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/AuthServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/AuthServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/AuthServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,21 @@
-package project.fmo.app.projcetfmo.Service.impl;public class AuthServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+import project.fmo.app.projcetfmo.Repository.KorisnikRepository;
+import project.fmo.app.projcetfmo.Service.AuthService;
+
+@Service
+public class AuthServiceImpl implements AuthService {
+
+    private final KorisnikRepository korisnikRepository;
+
+    public AuthServiceImpl(KorisnikRepository korisnikRepository) {
+        this.korisnikRepository = korisnikRepository;
+    }
+
+    @Override
+    public Korisnik login(String username, String password) {
+        return korisnikRepository.findByImePrezimeAndPasswordKorisnik(username,password);
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/CenaServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/CenaServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/CenaServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,54 @@
-package project.fmo.app.projcetfmo.Service.impl;public class CenaServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import javax.transaction.Transactional;
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Cena;
+import project.fmo.app.projcetfmo.Model.CenaPK;
+import project.fmo.app.projcetfmo.Repository.CenaRepository;
+import project.fmo.app.projcetfmo.Service.CenaService;
+
+import java.sql.Date;
+import java.util.List;
+
+@Service
+public class CenaServiceImpl implements CenaService {
+
+    private final CenaRepository cenaRepository;
+
+    public CenaServiceImpl(CenaRepository cenaRepository) {
+        this.cenaRepository = cenaRepository;
+    }
+
+    @Override
+    public Cena save(Integer idProdukt, java.sql.Date cenaOd, java.sql.Date cenaDo, int iznos) {
+            Cena c = new Cena(idProdukt,cenaOd,cenaDo,iznos);
+            cenaRepository.save(c);
+        return c;
+    }
+
+    @Transactional
+    @Override
+    public Cena edit(Integer idProdukt, Date cenaOd, Date cenaDo, int iznos) {
+        Cena c = cenaRepository.findByIdProdukt(idProdukt);
+        cenaRepository.deleteByIdProdukt(c.getIdProdukt());
+        Cena c1 = new Cena(idProdukt,cenaOd,cenaDo,iznos);
+        cenaRepository.save(c1);
+        return c;
+    }
+
+    @Override
+    public List<Cena> findAll() {
+        return cenaRepository.findAll();
+    }
+
+    @Override
+    public Cena findByIdProdukt(int idProdukt) {
+        return cenaRepository.findByIdProdukt(idProdukt);
+    }
+
+    @Transactional
+    @Override
+    public void deleteByIdProdukt(int idProdukt) {
+        cenaRepository.deleteByIdProdukt(idProdukt);
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavaServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavaServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavaServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,33 @@
-package project.fmo.app.projcetfmo.Service.impl;public class DostavaServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Dostava;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+import project.fmo.app.projcetfmo.Repository.DostavaRepository;
+import project.fmo.app.projcetfmo.Service.DostavaService;
+
+import java.util.List;
+
+@Service
+public class DostavaServiceImpl implements DostavaService {
+
+    private final DostavaRepository dostavaRepository;
+
+    public DostavaServiceImpl(DostavaRepository dostavaRepository) {
+        this.dostavaRepository = dostavaRepository;
+    }
+
+    @Override
+    public List<Dostava> findByIdKorisnikAndStatus(Dostavuvac dostavuvac, String status) {
+        return dostavaRepository.findByDostavuvacAndStatus(dostavuvac,status);
+    }
+
+    @Override
+    public Dostava edit(Integer id) {
+        Dostava d = dostavaRepository.findById(id).orElse(null);
+        assert d != null;
+        d.setStatus("dostavena");
+        dostavaRepository.save(d);
+        return d;
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavuvacServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavuvacServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/DostavuvacServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,21 @@
-package project.fmo.app.projcetfmo.Service.impl;public class DostavuvacServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+import project.fmo.app.projcetfmo.Repository.DostavuvacRepository;
+import project.fmo.app.projcetfmo.Service.DostavuvaceService;
+
+@Service
+public class DostavuvacServiceImpl implements DostavuvaceService {
+
+    private final DostavuvacRepository dostavuvacRepository;
+
+    public DostavuvacServiceImpl(DostavuvacRepository dostavuvacRepository) {
+        this.dostavuvacRepository = dostavuvacRepository;
+    }
+
+    @Override
+    public Dostavuvac findById(Integer id) {
+        return dostavuvacRepository.findById(id).orElse(null);
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/KategorijaServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/KategorijaServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/KategorijaServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,39 @@
-package project.fmo.app.projcetfmo.Service.impl;public class KategorijaServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Kategorija;
+import project.fmo.app.projcetfmo.Repository.KategorijaRepository;
+import project.fmo.app.projcetfmo.Service.KategorijaService;
+
+import java.util.List;
+
+@Service
+public class KategorijaServiceImpl implements KategorijaService {
+
+    private final KategorijaRepository kategorijaRepository;
+
+    public KategorijaServiceImpl(KategorijaRepository kategorijaRepository) {
+        this.kategorijaRepository = kategorijaRepository;
+    }
+
+    @Override
+    public List<Kategorija> findAll() {
+        return kategorijaRepository.findAll();
+    }
+
+    @Override
+    public Kategorija save(String ime) {
+        Kategorija k = new Kategorija(ime);
+        kategorijaRepository.save(k);
+        return k;
+    }
+
+    @Override
+    public Kategorija edit(Integer id, String ime) {
+        Kategorija k = kategorijaRepository.findById(id).orElse(null);
+        assert k != null;
+        k.setIme(ime);
+        kategorijaRepository.save(k);
+        return k;
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/KorisnikServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/KorisnikServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/KorisnikServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,92 @@
-package project.fmo.app.projcetfmo.Service.impl;public class KorisnikServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.*;
+import project.fmo.app.projcetfmo.Repository.*;
+import project.fmo.app.projcetfmo.Service.KorisnikService;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Service
+public class KorisnikServiceImpl implements KorisnikService {
+
+    private final PasswordEncoder passwordEncoder;
+    private final AdminRepository adminRepository;
+    private final DostavuvacRepository dostavuvacRepository;
+
+    private final TelefnoskiBrojRepository telefnoskiBrojRepository;
+    private final KupuvacRepository kupuvacRepository;
+    private final KorisnikRepository korisnikRepository;
+
+    public KorisnikServiceImpl(PasswordEncoder passwordEncoder, AdminRepository adminRepository, DostavuvacRepository dostavuvacRepository, TelefnoskiBrojRepository telefnoskiBrojRepository, KupuvacRepository kupuvacRepository, KorisnikRepository korisnikRepository) {
+        this.passwordEncoder = passwordEncoder;
+        this.adminRepository = adminRepository;
+        this.dostavuvacRepository = dostavuvacRepository;
+        this.telefnoskiBrojRepository = telefnoskiBrojRepository;
+        this.kupuvacRepository = kupuvacRepository;
+        this.korisnikRepository = korisnikRepository;
+    }
+
+    @Override
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+        Korisnik korisnik = korisnikRepository.findByImePrezime(username);
+        for (AdminKorisnik a: adminRepository.findAll()) {
+            if (a.getIdKorisnik() == korisnik.getIdKorisnik()) {
+                return new User(korisnik.getImePrezime(), korisnik.getPasswordKorisnik(), Stream.of(new SimpleGrantedAuthority("ROLE_ADMIN")).collect(Collectors.toList()));
+            }
+        }
+        for (Dostavuvac a: dostavuvacRepository.findAll()) {
+            if (a.getIdKorisnik() == korisnik.getIdKorisnik()) {
+                return new User(korisnik.getImePrezime(), korisnik.getPasswordKorisnik(), Stream.of(new SimpleGrantedAuthority("ROLE_DELIVER")).collect(Collectors.toList()));
+            }
+        }
+        for (Kupuvac a: kupuvacRepository.findAll()){
+            if (a.getIdKorisnik() == korisnik.getIdKorisnik()){
+                return new User(korisnik.getImePrezime(),korisnik.getPasswordKorisnik(), Stream.of(new SimpleGrantedAuthority("ROLE_USER")).collect(Collectors.toList()) );
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Korisnik findbyImePrezime(String ime) {
+        return korisnikRepository.findByImePrezime(ime);
+    }
+
+    @Override
+    public Korisnik findById(Integer id) {
+        return korisnikRepository.findById(id).orElse(null);
+    }
+
+    @Override
+    public Korisnik register(String username, String password, String repeatPassword, String mail, String number) {
+        if (username==null || username.isEmpty()  || password==null || password.isEmpty())
+            throw new RuntimeException();
+        if (!password.equals(repeatPassword))
+            throw new RuntimeException();
+
+        Korisnik korisnik = new Korisnik(username,password, Timestamp.valueOf(LocalDateTime.now()));
+        korisnikRepository.save(korisnik);
+        Kupuvac k = new Kupuvac(korisnik.getIdKorisnik(), mail);
+        kupuvacRepository.save(k);
+        Telefonskibroj t = new Telefonskibroj(new TelefonskibrojPK(korisnik.getIdKorisnik(),number));
+        telefnoskiBrojRepository.save(t);
+        return korisnik;
+
+    }
+
+    @Override
+    public List<Object> statistics2() {
+        return korisnikRepository.statistics2();
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/KupuvacServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/KupuvacServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/KupuvacServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,21 @@
-package project.fmo.app.projcetfmo.Service.impl;public class KupuvacServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+import project.fmo.app.projcetfmo.Repository.KupuvacRepository;
+import project.fmo.app.projcetfmo.Service.KupuvacService;
+
+@Service
+public class KupuvacServiceImpl implements KupuvacService {
+
+    private final KupuvacRepository kupuvacRepository;
+
+    public KupuvacServiceImpl(KupuvacRepository kupuvacRepository) {
+        this.kupuvacRepository = kupuvacRepository;
+    }
+
+    @Override
+    public Kupuvac findById(Integer id) {
+        return kupuvacRepository.findById(id).orElse(null);
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,71 @@
-package project.fmo.app.projcetfmo.Service.impl;public class NarackaServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.Kupuvac;
+import project.fmo.app.projcetfmo.Model.Naracka;
+import project.fmo.app.projcetfmo.Model.Produkt;
+import project.fmo.app.projcetfmo.Repository.KupuvacRepository;
+import project.fmo.app.projcetfmo.Repository.NarackaRepository;
+import project.fmo.app.projcetfmo.Service.NarackaService;
+
+import java.sql.Date;
+import java.util.List;
+
+@Service
+public class NarackaServiceImpl implements NarackaService {
+
+    private final NarackaRepository narackaRepository;
+    private final KupuvacRepository kupuvacRepository;
+
+    public NarackaServiceImpl(NarackaRepository narackaRepository, KupuvacRepository kupuvacRepository) {
+        this.narackaRepository = narackaRepository;
+        this.kupuvacRepository = kupuvacRepository;
+    }
+
+    @Override
+    public List<Produkt> allProductsInOrder(Integer narackaId) {
+        return null;
+    }
+
+    @Override
+    public Naracka getActiveOrder(String username) {
+        return null;
+    }
+
+    @Override
+    public Naracka findByIdKorisniktAndStatus(Integer id, String s) {
+        Kupuvac k = kupuvacRepository.findById(id).orElse(null);
+        return narackaRepository.findByKupuvacAndStatus(k,s);
+    }
+
+    @Override
+    public Naracka save(int vkupnoSuma, Date date, String status, String adresa, Kupuvac k) {
+        return narackaRepository.save(new Naracka(vkupnoSuma,date,status,adresa,k));
+    }
+
+    @Override
+    public Naracka edit(int vkupnoSuma, String status, String adresa, Integer idK, Integer idN) {
+        Kupuvac k = kupuvacRepository.findById(idK).orElse(null);
+        Naracka n = narackaRepository.findByKupuvacAndIdNaracka(k,idN);
+        n.setVkupnoSuma(n.getVkupnoSuma()+vkupnoSuma);
+        n.setStatus(status);
+        n.setAdresa(adresa);
+        narackaRepository.save(n);
+        return n;
+    }
+
+    @Override
+    public Naracka findByKupuvac(Kupuvac k) {
+        return narackaRepository.findByKupuvac(k);
+    }
+
+    @Override
+    public Naracka findByIdNaracka(Integer id) {
+        return narackaRepository.findById(id).orElse(null);
+    }
+
+    @Override
+    public List<Naracka> findAll() {
+        return narackaRepository.findAll();
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaSodrziProduktServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaSodrziProduktServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaSodrziProduktServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,62 @@
-package project.fmo.app.projcetfmo.Service.impl;public class NarackaSodrziProduktServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.NarackaSodrziProdukt;
+import project.fmo.app.projcetfmo.Repository.NarackaSodrziProduktRepository;
+import project.fmo.app.projcetfmo.Service.NarackaSodrziProduktService;
+
+import java.util.List;
+
+@Service
+public class NarackaSodrziProduktServiceImpl implements NarackaSodrziProduktService {
+
+   private final NarackaSodrziProduktRepository narackaSodrziProduktRepository;
+
+    public NarackaSodrziProduktServiceImpl(NarackaSodrziProduktRepository narackaSodrziProduktRepository) {
+        this.narackaSodrziProduktRepository = narackaSodrziProduktRepository;
+    }
+
+    @Override
+    public NarackaSodrziProdukt findByIdProduktAndIdNaracka(Integer idP, Integer idN) {
+        return narackaSodrziProduktRepository.findByIdProduktAndIdNaracka(idP,idN);
+    }
+
+    @Override
+    public NarackaSodrziProdukt edit(Integer idP, Integer idN, Integer quantity, Integer price) {
+        NarackaSodrziProdukt n = narackaSodrziProduktRepository.findByIdProduktAndIdNaracka(idP,idN);
+        n.setCena(price);
+        n.setKolicina(n.getKolicina()+quantity);
+        narackaSodrziProduktRepository.save(n);
+        return n;
+    }
+
+    @Override
+    public NarackaSodrziProdukt save(Integer idP, Integer idN, Integer quantity, Integer price) {
+        NarackaSodrziProdukt n = new NarackaSodrziProdukt(idP,idN,quantity, price);
+        narackaSodrziProduktRepository.save(n);
+        return n;
+    }
+
+    @Override
+    public List<NarackaSodrziProdukt> findByIdNaracka(Integer id) {
+        return narackaSodrziProduktRepository.findByIdNaracka(id);
+    }
+
+    @Override
+    public void deleteProduct(Integer id) {
+        List<NarackaSodrziProdukt> narackaSodrziProdukts = narackaSodrziProduktRepository.findByIdProdukt(id);
+        narackaSodrziProduktRepository.deleteByIdProdukt(id);
+    }
+
+    @Override
+    public List<NarackaSodrziProdukt> findAll() {
+        return narackaSodrziProduktRepository.findAll();
+    }
+
+    @Override
+    public List<NarackaSodrziProdukt> findByIdProdukt(Integer id) {
+        return narackaSodrziProduktRepository.findByIdProdukt(id);
+    }
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktEOdKategorijaServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktEOdKategorijaServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktEOdKategorijaServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,63 @@
-package project.fmo.app.projcetfmo.Service.impl;public class ProduktEOdKategorijaServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import javax.transaction.Transactional;
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.ProduktEOdKategorija;
+import project.fmo.app.projcetfmo.Model.ProduktEOdKategorijaPK;
+import project.fmo.app.projcetfmo.Repository.ProduktEOdKategorijaRepository;
+import project.fmo.app.projcetfmo.Service.ProduktEOdKategorijaService;
+import project.fmo.app.projcetfmo.Service.ProduktService;
+
+import java.util.List;
+
+@Service
+public class ProduktEOdKategorijaServiceImpl implements ProduktEOdKategorijaService {
+
+    private final ProduktEOdKategorijaRepository produktEOdKategorijaRepository;
+
+    public ProduktEOdKategorijaServiceImpl(ProduktEOdKategorijaRepository produktEOdKategorijaRepository) {
+        this.produktEOdKategorijaRepository = produktEOdKategorijaRepository;
+    }
+
+    @Override
+    public ProduktEOdKategorija save(int idProdukt, int idKategorija) {
+        ProduktEOdKategorija produktEOdKategorija= new ProduktEOdKategorija(new ProduktEOdKategorijaPK(idProdukt, idKategorija));
+        produktEOdKategorijaRepository.save(produktEOdKategorija);
+        return produktEOdKategorija;
+    }
+
+    @Transactional
+    @Override
+    public ProduktEOdKategorija edit(int idProdukt, int idKategorija) {
+//        ProduktEOdKategorijaPK pk = new ProduktEOdKategorijaPK(idProdukt,idKategorija);
+        ProduktEOdKategorija peodkD = produktEOdKategorijaRepository.findByIdProdukt(idProdukt);
+        produktEOdKategorijaRepository.deleteByIdProdukt(peodkD.getIdProdukt());
+        ProduktEOdKategorijaPK pk = new ProduktEOdKategorijaPK(idProdukt, idKategorija);
+        ProduktEOdKategorija peodk = new ProduktEOdKategorija(pk);
+       produktEOdKategorijaRepository.save(peodk);
+
+        return peodk;
+    }
+
+    @Override
+    public List<ProduktEOdKategorija> findAll() {
+        return produktEOdKategorijaRepository.findAll();
+    }
+
+    @Override
+    public ProduktEOdKategorija findByIdProdukt(int idProdukt) {
+        return produktEOdKategorijaRepository.findByIdProdukt(idProdukt);
+    }
+
+    @Transactional
+    @Override
+    public void deleteByIdProdukt(int idProdukt) {
+
+        this.produktEOdKategorijaRepository.deleteByIdProdukt(idProdukt);
+    }
+
+    @Override
+    public ProduktEOdKategorija findByIdProduktAndIdKategorija(int idProdukt, int idKategorija) {
+        return produktEOdKategorijaRepository.findByIdProduktAndIdKategorija(idProdukt,idKategorija);
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktServiceImpl.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktServiceImpl.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Service/impl/ProduktServiceImpl.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,73 @@
-package project.fmo.app.projcetfmo.Service.impl;public class ProduktServiceImpl {
+package project.fmo.app.projcetfmo.Service.impl;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import project.fmo.app.projcetfmo.Model.AdminKorisnik;
+import project.fmo.app.projcetfmo.Model.Produkt;
+import project.fmo.app.projcetfmo.Repository.AdminRepository;
+import project.fmo.app.projcetfmo.Repository.ProduktRepository;
+import project.fmo.app.projcetfmo.Service.ProduktService;
+
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Random;
+
+@Service
+public class ProduktServiceImpl implements ProduktService {
+
+    private final ProduktRepository produktRepository;
+    private final AdminRepository adminRepository;
+
+    public ProduktServiceImpl(ProduktRepository produktRepository, AdminRepository adminRepository) {
+        this.produktRepository = produktRepository;
+        this.adminRepository = adminRepository;
+    }
+
+    @Override
+    public Optional<Produkt> findById(Integer id) {
+        return produktRepository.findById(id);
+    }
+
+    @Override
+    public List<Produkt> findAll() {
+        return produktRepository.findAll();
+    }
+
+    @Override
+    public Produkt save(String ime, String opis) {
+        List<AdminKorisnik> list = adminRepository.findAll();
+        Random rand = new Random();
+        int randomIndex = rand.nextInt(list.size());
+        AdminKorisnik a = list.get(randomIndex);
+        if (a == null){
+            throw new RuntimeException();
+        }
+        Produkt p = new Produkt(ime, opis, a);
+        produktRepository.save(p);
+        return p;
+    }
+
+    @Override
+    public Produkt edit(Integer id, String ime, String opis) {
+        Produkt p = produktRepository.findById(id).orElse(null);
+        if (p == null ){
+            throw new RuntimeException();
+        }
+        p.setIme(ime);
+        p.setOpis(opis);
+        produktRepository.save(p);
+        return p;
+    }
+
+    @Override
+    public void deleteById(Integer id) {
+        produktRepository.deleteById(id);
+    }
+
+    @Override
+    public List<Object> statistics1() {
+        return produktRepository.statistics1();
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/DostavaController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/DostavaController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/DostavaController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,56 @@
-package project.fmo.app.projcetfmo.Web;public class DostavaController {
+package project.fmo.app.projcetfmo.Web;
+
+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.RequestMapping;
+import project.fmo.app.projcetfmo.Model.Dostava;
+import project.fmo.app.projcetfmo.Model.Dostavuvac;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+import project.fmo.app.projcetfmo.Service.DostavaService;
+import project.fmo.app.projcetfmo.Service.DostavuvaceService;
+import project.fmo.app.projcetfmo.Service.KorisnikService;
+import project.fmo.app.projcetfmo.Service.NarackaService;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Controller
+@RequestMapping("/delivery")
+public class DostavaController {
+
+    private final DostavaService dostavaService;
+    private final DostavuvaceService dostavuvaceService;
+    private final KorisnikService korisnikService;
+    private final NarackaService narackaService;
+
+    public DostavaController(DostavaService dostavaService, DostavuvaceService dostavuvaceService, KorisnikService korisnikService, NarackaService narackaService) {
+        this.dostavaService = dostavaService;
+        this.dostavuvaceService = dostavuvaceService;
+        this.korisnikService = korisnikService;
+        this.narackaService = narackaService;
+    }
+
+
+    @GetMapping
+    public String getDelivery(Model model, HttpServletRequest req){
+        String username = req.getRemoteUser();
+        Korisnik korisnik = korisnikService.findbyImePrezime(username);
+        Dostavuvac dostavuvac = dostavuvaceService.findById(korisnik.getIdKorisnik());
+        List<Dostava> dostavaList = dostavaService.findByIdKorisnikAndStatus(dostavuvac, "za dostava");
+        model.addAttribute("user", korisnik);
+        model.addAttribute("orders", narackaService.findAll());
+        model.addAttribute("delivers", dostavaList);
+        model.addAttribute("bodyContent", "delivery");
+        return "master_template";
+    }
+
+    @PostMapping("/{id}")
+    public String OrderDelivered(@PathVariable Integer id){
+        dostavaService.edit(id);
+        return  "redirect:/delivery";
+    }
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/HomeController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/HomeController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/HomeController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -9,11 +9,19 @@
 @Controller
 @RequestMapping({"/","/home"})
-public class StoreController {
+public class HomeController {
 
 
     @GetMapping
-    public String getHomePage(){
-        return "home";
+    public String getHomePage(Model model){
+        model.addAttribute("bodyContent", "home");
+        return "master_template";
     }
 
+    @GetMapping("/access_denied")
+    public String getAccessDeniedPage(Model model) {
+        model.addAttribute("bodyContent", "access_denied");
+        return "master-template";
+    }
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/LoginController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/LoginController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/LoginController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,46 @@
-package project.fmo.app.projcetfmo.Web;public class LoginController {
+package project.fmo.app.projcetfmo.Web;
+
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+import project.fmo.app.projcetfmo.Model.exception.InvalidUserCredentialsException;
+import project.fmo.app.projcetfmo.Service.AuthService;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Controller
+@RequestMapping("/login")
+public class LoginController {
+
+    private final AuthService authService;
+
+    public LoginController(AuthService authService) {
+        this.authService = authService;
+    }
+
+    @GetMapping
+    public String getLoginPage(Model model) {
+        model.addAttribute("bodyContent","login");
+        return "master-template";
+    }
+
+    @PostMapping
+    public String login(HttpServletRequest request, Model model) {
+        Korisnik user = null;
+        try{
+            user = this.authService.login(request.getParameter("username"),
+                    request.getParameter("password"));
+            request.getSession().setAttribute("user", user);
+            return "redirect:/home";
+        }
+        catch (InvalidUserCredentialsException exception) {
+            model.addAttribute("hasError", true);
+            model.addAttribute("error", exception.getMessage());
+            return "login";
+        }
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/LogoutController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/LogoutController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/LogoutController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,18 @@
-package project.fmo.app.projcetfmo.Web;public class LogoutController {
+package project.fmo.app.projcetfmo.Web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Controller
+@RequestMapping("/logout")
+public class LogoutController {
+
+    @GetMapping
+    public String logout(HttpServletRequest request) {
+        request.getSession().invalidate();
+        return "redirect:/";
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/NarackaController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/NarackaController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/NarackaController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,76 @@
-package project.fmo.app.projcetfmo.Web;public class NarackaController {
+package project.fmo.app.projcetfmo.Web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import project.fmo.app.projcetfmo.Model.*;
+import project.fmo.app.projcetfmo.Service.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Controller
+@RequestMapping("/order")
+public class NarackaController {
+
+    private final NarackaService narackaService;
+    private final NarackaSodrziProduktService narackaSodrziProduktService;
+    private final KorisnikService korisnikService;
+    private final KupuvacService kupuvacService;
+    private final CenaService cenaService;
+
+    private final ProduktService produktService;
+
+    public NarackaController(NarackaService narackaService, NarackaSodrziProduktService narackaSodrziProduktService, KorisnikService korisnikService, KupuvacService kupuvacService, CenaService cenaService, ProduktService produktService) {
+        this.narackaService = narackaService;
+        this.narackaSodrziProduktService = narackaSodrziProduktService;
+        this.korisnikService = korisnikService;
+        this.kupuvacService = kupuvacService;
+        this.cenaService = cenaService;
+        this.produktService = produktService;
+    }
+
+    @GetMapping
+    public String getShoppingCartPage(@RequestParam(required = false) String error,
+                                      HttpServletRequest req,
+                                      Model model) {
+        if (error != null && !error.isEmpty()) {
+            model.addAttribute("hasError", true);
+            model.addAttribute("error", error);
+        }
+        String username = req.getRemoteUser();
+        Korisnik korisnik = korisnikService.findbyImePrezime(username);
+        Kupuvac kupuvac = kupuvacService.findById(korisnik.getIdKorisnik());
+        Naracka naracka = this.narackaService.findByIdKorisniktAndStatus(kupuvac.getIdKorisnik(),"aktivna");
+        if(naracka == null){
+            model.addAttribute("bodyContent", "home");
+            return "master_template";
+        }
+        List<NarackaSodrziProdukt> narackaSodrziProdukt = narackaSodrziProduktService.findByIdNaracka(naracka.getIdNaracka());
+        List<Produkt> produktList =  produktService.findAll();
+        model.addAttribute("order", naracka);
+        model.addAttribute("products", produktList);
+        model.addAttribute("po", narackaSodrziProdukt);
+        model.addAttribute("prices", cenaService.findAll());
+        model.addAttribute("bodyContent", "cart");
+        return "master_template";
+    }
+
+    @PostMapping("/{id}/success")
+    public String processOrder(@PathVariable Integer id,HttpServletRequest req,@RequestParam(required = false) String address){
+        Naracka n = narackaService.findByIdNaracka(id);
+        String username = req.getRemoteUser();
+        Korisnik korisnik = korisnikService.findbyImePrezime(username);
+        Kupuvac kupuvac = kupuvacService.findById(korisnik.getIdKorisnik());
+        if(address!=null) {
+            narackaService.edit(0, "se sprema", address, kupuvac.getIdKorisnik(), n.getIdNaracka());
+        }
+        else {
+            narackaService.edit(0, "se sprema", "/", kupuvac.getIdKorisnik(), n.getIdNaracka());
+        }
+        return "redirect:/products";
+    }
+
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/ProductController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/ProductController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/ProductController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,185 @@
-package project.fmo.app.projcetfmo.Web;public class ProductController {
+package project.fmo.app.projcetfmo.Web;
+
+
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import project.fmo.app.projcetfmo.Model.*;
+import project.fmo.app.projcetfmo.Service.*;
+
+
+import java.sql.Date;
+import java.text.ParseException;
+
+import java.time.LocalDate;
+import java.util.List;
+
+
+@Controller
+@RequestMapping("/products")
+public class ProductController {
+
+    private final ProduktService produktService;
+    private final KategorijaService kategorijaService;
+    private final ProduktEOdKategorijaService produktEOdKategorijaService;
+    private final CenaService cenaService;
+    private final NarackaService narackaService;
+    private final NarackaSodrziProduktService narackaSodrziProduktService;
+    private final KupuvacService kupuvacService;
+    private final KorisnikService korisnikService;
+
+    public ProductController(ProduktService produktService, KategorijaService kategorijaService, ProduktEOdKategorijaService produktEOdKategorijaService, CenaService cenaService, NarackaService narackaService, NarackaSodrziProduktService narackaSodrziProduktService, KupuvacService kupuvacService, KorisnikService korisnikService) {
+        this.produktService = produktService;
+        this.kategorijaService = kategorijaService;
+        this.produktEOdKategorijaService = produktEOdKategorijaService;
+        this.cenaService = cenaService;
+        this.narackaService = narackaService;
+        this.narackaSodrziProduktService = narackaSodrziProduktService;
+        this.kupuvacService = kupuvacService;
+        this.korisnikService = korisnikService;
+    }
+
+    @GetMapping
+    public String getProductPage(Model model) {
+        List<Produkt> products = this.produktService.findAll();
+        model.addAttribute("products", products);
+        model.addAttribute("kat", kategorijaService.findAll());
+        model.addAttribute("categories", produktEOdKategorijaService.findAll());
+        model.addAttribute("prices", cenaService.findAll());
+        model.addAttribute("bodyContent", "products");
+        return "master_template";
+    }
+
+    @GetMapping("/{id}")
+    public String getProductInfo(Model model, @PathVariable Integer id){
+        Produkt p = produktService.findById(id).orElse(null);
+        Cena c = cenaService.findByIdProdukt(id);
+        ProduktEOdKategorija pk = produktEOdKategorijaService.findByIdProdukt(id);
+        List<Kategorija> k = kategorijaService.findAll();
+        Kategorija kat = null;
+        for ( Kategorija kategorija : k){
+            if (kategorija.getIdKategorija() == pk.getIdKategorija()){
+                kat=kategorija;
+            }
+        }
+        model.addAttribute("product", p);
+        model.addAttribute("price", c);
+        model.addAttribute("category",pk);
+        if(kat != null) {
+            model.addAttribute("kat", kat);
+        }
+        model.addAttribute("bodyContent", "product_info");
+        return "master_template";
+    }
+
+    @PostMapping("{id}/add-to-cart")
+    public String addProductToCart(@PathVariable Integer id,
+                                   @RequestParam String idKorisnik,
+                                   @RequestParam int cena,
+                                   @RequestParam int quantity){
+        Korisnik kOrisnik = korisnikService.findbyImePrezime(idKorisnik);
+        Kupuvac k = kupuvacService.findById(kOrisnik.getIdKorisnik());
+        Naracka n = narackaService.findByIdKorisniktAndStatus(k.getIdKorisnik(),"aktivna");
+            if (n == null){
+                //Naracka narackaNova = new Naracka(cena*quantity, Date.valueOf(LocalDate.now()), "aktivna", "/", k);
+                Naracka narackaNova = narackaService.save(cena*quantity, Date.valueOf(LocalDate.now()), "aktivna", "/", k);
+                NarackaSodrziProdukt nsp = new NarackaSodrziProdukt(id,narackaNova.getIdNaracka(),quantity,cena);
+                narackaSodrziProduktService.save(id,narackaNova.getIdNaracka(),quantity,cena);
+
+                return "redirect:/products";
+            }
+            else {
+                narackaService.edit(cena*quantity,n.getStatus(),n.getAdresa(),k.getIdKorisnik(),n.getIdNaracka());
+                NarackaSodrziProdukt narackaSodrziProdukt = narackaSodrziProduktService.findByIdProduktAndIdNaracka(id,n.getIdNaracka());
+                if(narackaSodrziProdukt == null){
+                    NarackaSodrziProdukt nova = new NarackaSodrziProdukt(id,n.getIdNaracka(),quantity,cena);
+                    narackaSodrziProduktService.save(id,n.getIdNaracka(),quantity,cena);
+                }
+                else{
+                    narackaSodrziProduktService.edit(id,n.getIdNaracka(),quantity,cena);
+                }
+                return "redirect:/products";
+          }
+    }
+
+    @DeleteMapping("/delete/{id}")
+    public String deleteProduct(@PathVariable Integer id,Model model) {
+        if(narackaSodrziProduktService.findByIdProdukt(id).size() != 0){
+            model.addAttribute("bodyContent", "not_valid_delete");
+            return "master_template";
+        }
+        this.cenaService.deleteByIdProdukt(id);
+        this.produktEOdKategorijaService.deleteByIdProdukt(id);
+        this.produktService.deleteById(id);
+        return "redirect:/products";
+    }
+
+    @GetMapping("/edit-form/{id}")
+    public String editProductPage(@PathVariable Integer id, Model model) {
+        if (this.produktService.findById(id).isPresent()) {
+            Produkt product = this.produktService.findById(id).get();
+            Cena c = cenaService.findByIdProdukt(product.getIdProdukt());
+            ProduktEOdKategorija produktEOdKategorija = produktEOdKategorijaService.findByIdProdukt(product.getIdProdukt());
+            model.addAttribute("chosen", produktEOdKategorija);
+            model.addAttribute("price", c);
+            List<Kategorija> categories = this.kategorijaService.findAll();
+            model.addAttribute("categories", categories);
+            model.addAttribute("product", product);
+            model.addAttribute("bodyContent", "add_product");
+            return "master_template";
+        }
+        return "redirect:/products";
+    }
+
+    @GetMapping("/add-form")
+    public String addProductPage(Model model) {
+        List<Kategorija> categories = this.kategorijaService.findAll();
+        model.addAttribute("categories", categories);
+        model.addAttribute("bodyContent", "add_product");
+        return "master_template";
+    }
+
+    @PostMapping("/add")
+    public String saveProduct(
+            @RequestParam(required = false) Integer id,
+            @RequestParam String name,
+            @RequestParam(required = false) String description,
+            @RequestParam Integer category,
+            @RequestParam Date date,
+            @RequestParam(required = false)  String dateTo,
+            @RequestParam int price) throws ParseException {
+            if(dateTo.length() != 0) {
+                Date d = Date.valueOf(dateTo);
+
+                if (id != null) {
+                    this.produktService.edit(id, name, description);
+                    this.cenaService.edit(id, date, d, price);
+                    this.produktEOdKategorijaService.edit(id, category);
+
+                } else {
+                    Produkt p = this.produktService.save(name, description);
+                    this.cenaService.save(p.getIdProdukt(), date, d, price);
+                    this.produktEOdKategorijaService.save(p.getIdProdukt(), category);
+                }
+            }
+            else{
+                if (id != null) {
+                this.produktService.edit(id, name, description);
+                this.cenaService.edit(id, date, null, price);
+                this.produktEOdKategorijaService.edit(id, category);
+
+            } else {
+                Produkt p = this.produktService.save(name, description);
+                this.cenaService.save(p.getIdProdukt(), date, null, price);
+                this.produktEOdKategorijaService.save(p.getIdProdukt(), category);
+            }
+
+            }
+        return "redirect:/products";
+    }
+
+
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/RegisterController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/RegisterController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/RegisterController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,50 @@
-package project.fmo.app.projcetfmo.Web;public class RegisterController {
+package project.fmo.app.projcetfmo.Web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import project.fmo.app.projcetfmo.Service.KorisnikService;
+
+@Controller
+@RequestMapping("/register")
+public class RegisterController {
+
+    private final KorisnikService korisnikService;
+
+
+    public RegisterController(KorisnikService korisnikService) {
+        this.korisnikService = korisnikService;
+    }
+
+
+    @GetMapping
+    public String getRegisterPage(@RequestParam(required = false) String error, Model model) {
+        if(error != null && !error.isEmpty()) {
+            model.addAttribute("hasError", true);
+            model.addAttribute("error", error);
+        }
+        model.addAttribute("bodyContent","register");
+        return "master_template";
+    }
+
+    @PostMapping
+    public String register(@RequestParam String name_surname,
+                           @RequestParam String password,
+                           @RequestParam String repeatedPassword,
+                           @RequestParam String mail,
+                           @RequestParam String number) {
+        try{
+            if(korisnikService.findbyImePrezime(name_surname) != null) throw  new RuntimeException();
+            this.korisnikService.register(name_surname, password, repeatedPassword, mail, number);
+            return "redirect:/home";
+        } catch (RuntimeException r) {
+            return "redirect:/register?error=InvalidRegistration";
+        }
+    }
+
+
+
 }
Index: src/main/java/project/fmo/app/projcetfmo/Web/StatisticsController.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/Web/StatisticsController.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/Web/StatisticsController.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,47 @@
-package project.fmo.app.projcetfmo.Web;public class StatisticsController {
+package project.fmo.app.projcetfmo.Web;
+
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import project.fmo.app.projcetfmo.Model.Korisnik;
+import project.fmo.app.projcetfmo.Model.Produkt;
+import project.fmo.app.projcetfmo.Service.KorisnikService;
+import project.fmo.app.projcetfmo.Service.ProduktService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Controller
+@RequestMapping("/statistics")
+public class StatisticsController {
+    private final ProduktService produktService;
+    private final KorisnikService korisnikService;
+
+    public StatisticsController(ProduktService produktService, KorisnikService korisnikService) {
+        this.produktService = produktService;
+        this.korisnikService = korisnikService;
+    }
+
+    @GetMapping
+    public String getStatistics(Model model){
+        List<Object> korisnikList = korisnikService.statistics2();
+        List<String> ime = new ArrayList<>();
+        List<String> id = new ArrayList<>();
+        List<Integer> vkupno_naracki = new ArrayList<>();
+        List<Float> prosecna_suma_na_naracka_za_site_kupuvaci = new ArrayList<>();
+        List<Integer> vkupno_suma_od_site_naracki_na_kupuvacot = new ArrayList<>();
+        List<Integer> vkupno_naracki_nad_prosek_na_korisnikot = new ArrayList<>();
+        List<Integer> vkupno_suma_na_naracki_nad_prosek_za_korisnikot = new ArrayList<>();
+//        for(int i =0 ; i< korisnikList.size();i++) {
+//            ime.add(korisnikList.get(i)[0].toString());
+//        }
+        List<Object> produktList = produktService.statistics1();
+        model.addAttribute("products", produktList);
+        model.addAttribute("users", korisnikList);
+        model.addAttribute("bodyContent", "statistics");
+        return "master_template";
+
+    }
 }
Index: src/main/java/project/fmo/app/projcetfmo/config/CustomUsernamePasswordAuthenticationProvider.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/config/CustomUsernamePasswordAuthenticationProvider.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/config/CustomUsernamePasswordAuthenticationProvider.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,47 @@
-package project.fmo.app.projcetfmo.config;public class CustomUsernamePasswordAuthenticationProvider {
+package project.fmo.app.projcetfmo.config;
+
+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;
+import project.fmo.app.projcetfmo.Service.KorisnikService;
+
+@Component
+public class CustomUsernamePasswordAuthenticationProvider implements AuthenticationProvider {
+
+    private final KorisnikService korisnikService;
+    private final PasswordEncoder passwordEncoder;
+
+    public CustomUsernamePasswordAuthenticationProvider(KorisnikService korisnikService, PasswordEncoder passwordEncoder) {
+        this.korisnikService = korisnikService;
+        this.passwordEncoder = passwordEncoder;
+    }
+
+
+    @Override
+    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
+        String username = authentication.getName();
+        String password = authentication.getCredentials().toString();
+
+        if ("".equals(username) || "".equals(password)) {
+            throw new BadCredentialsException("Invalid Credentials");
+        }
+
+        UserDetails userDetails = this.korisnikService.loadUserByUsername(username);
+
+        if (!password.equals(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/project/fmo/app/projcetfmo/config/WebSecurityConfig.java
===================================================================
--- src/main/java/project/fmo/app/projcetfmo/config/WebSecurityConfig.java	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/java/project/fmo/app/projcetfmo/config/WebSecurityConfig.java	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,2 +1,56 @@
-package project.fmo.app.projcetfmo.config;public class WebSecurityConfig {
+package project.fmo.app.projcetfmo.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+
+
+    private final PasswordEncoder passwordEncoder;
+    private final CustomUsernamePasswordAuthenticationProvider authenticationProvider;
+
+    public WebSecurityConfig(PasswordEncoder passwordEncoder,
+                             CustomUsernamePasswordAuthenticationProvider authenticationProvider) {
+        this.passwordEncoder = passwordEncoder;
+        this.authenticationProvider = authenticationProvider;
+    }
+
+    @Override
+    protected void configure(HttpSecurity http) throws Exception {
+
+        http.csrf().disable()
+                .authorizeRequests()
+                .antMatchers("/","/**", "/home", "/register", "/products").permitAll()
+                .antMatchers("/admin/**").hasRole("ADMIN")
+                .anyRequest()
+                .authenticated()
+                .and()
+                .formLogin()
+                .permitAll()
+                .failureUrl("/login?error=BadCredentials")
+                .defaultSuccessUrl("/products", true)
+                .and()
+                .logout()
+                .clearAuthentication(true)
+                .invalidateHttpSession(true)
+                .deleteCookies("JSESSIONID")
+                .logoutSuccessUrl("/home")
+                .and()
+                .exceptionHandling().accessDeniedPage("/access_denied");
+
+    }
+
+    @Override
+    protected void configure(AuthenticationManagerBuilder auth) {
+        auth.authenticationProvider(authenticationProvider);
+    }
+
 }
Index: src/main/resources/application-prod.properties
===================================================================
--- src/main/resources/application-prod.properties	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/application-prod.properties	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -0,0 +1,14 @@
+
+spring.datasource.url=jdbc:postgresql://localhost:9999/db_202223z_va_prj_fmo
+spring.datasource.username=db_202223z_va_prj_fmo_owner
+spring.datasource.password=2d5e9a84d3a3
+
+
+spring.datasource.hikari.connectionTimeout=20000
+spring.datasource.hikari.maximumPoolSize=5
+
+spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect
+spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
+
+spring.jpa.hibernate.ddl-auto=validate
+spring.jpa.show-sql=true
Index: src/main/resources/templates/access_denied.html
===================================================================
--- src/main/resources/templates/access_denied.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/access_denied.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,11 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div class="container py-5">
+  <div class="row">
+    <div class="col-md-2 text-center">
+      <p><i class="fa fa-exclamation-triangle fa-5x"></i><br/>Status Code: 403</p>
+    </div>
+    <div class="col-md-10">
+      <p>Sorry, your access is refused.<br/>Please go back to the previous page to continue browsing.</p>
+      <a class="btn btn-danger" href="javascript:history.back()">Go Back</a>
+    </div>
+  </div>
+</div>
Index: src/main/resources/templates/add_product.html
===================================================================
--- src/main/resources/templates/add_product.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/add_product.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,86 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<th:block xmlns:th="http://www.thymeleaf.org">
+  <section class="jumbotron text-center">
+    <div class="container">
+      <h1 class="jumbotron-heading">FMO</h1>
+      <h2 class="jumbotron-heading">Food Market Online</h2>
+    </div>
+  </section>
+
+  <div class="container">
+    <div class="row">
+      <div class="col-md-5">
+        <form action="/products/add" method="POST">
+          <input id="id" type="hidden" name="id" th:value="(${product} != null ? ${product.getIdProdukt()} : '')">
+          <div class="form-group">
+            <label for="name">Product name</label>
+            <input type="text"
+                   class="form-control"
+                   id="name"
+                   name="name"
+                   th:value="(${product} != null ? ${product.getIme()} : '')"
+                   required
+                   placeholder="Enter product name">
+          </div>
+          <div class="form-group">
+            <label for="price">Price</label>
+            <input type="text"
+                   class="form-control"
+                   id="price"
+                   name="price"
+                   required
+                   th:value="(${price?.getIznos()} )"
+                   placeholder="Price">
+          </div>
+          <div class="form-group">
+            <label for="Description">Description</label>
+            <input type="text"
+                   class="form-control"
+                   id="description"
+                   name="description"
+                   th:value="(${product} != null ? ${product.getOpis()} : '')"
+                   placeholder="Description">
+          </div>
+          <div class="form-group">
+            <label>Category</label>
+            <select name="category" class="form-control">
+              <option th:if="${chosen} != null"
+                      th:selected="${chosen.getIdKategorija() != null &&
+                                chosen.getIdKategorija() == cat.getIdKategorija()}"
+                      th:each="cat : ${categories}"
+                      th:value="${cat.getIdKategorija()}"
+                      th:text="${cat.getIme()}">
+              </option>
+              <option th:if="${chosen} == null"
+                      th:each="cat : ${categories}"
+                      th:value="${cat.getIdKategorija()}"
+                      th:text="${cat.getIme()}">
+              </option>
+            </select>
+          </div>
+          <div class="form-group">
+            <label>Date from</label>
+           <input type="date"
+                           class="form-control"
+                           id="date"
+                           name="date"
+                           th:value="${price?.getCenaOd()} ?: null"
+                           required>
+          </div>
+          <div class="form-group">
+            <label>Date to</label>
+            <input type="date"
+                   class="form-control"
+                   id="dateTo"
+                   name="dateTo"
+                   th:value="${price?.getCenaDo() }">
+          </div>
+
+          <button id="submit" type="submit" class="btn btn-primary">Submit</button>
+          <a type="button" class="btn btn-primary" href="/products">Back</a>
+        </form>
+      </div>
+    </div>
+  </div>
+
+
+</th:block>
Index: src/main/resources/templates/cart.html
===================================================================
--- src/main/resources/templates/cart.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/cart.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,54 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<th:block xmlns:th="http://www.thymeleaf.org">
+    <section class="jumbotron text-center">
+        <div class="container">
+            <h3 class="jumbotron-heading">Shopping cart for
+                <th:block th:if="${#request.getRemoteUser() != null}" th:text="${#request.getRemoteUser()}"></th:block>
+            </h3>
+        </div>
+    </section>
+
+    <div th:if="${hasError}">
+        <h5 class="text-center text-danger" th:text="${error}"></h5>
+    </div>
+
+    <div class="container mb-4">
+        <div class="row">
+            <div class="col-12" th:if="${products.size() > 0}">
+                <div class="table-responsive">
+                    <table class="table table-striped">
+                        <thead>
+                        <tr>
+                            <th scope="col">Product</th>
+                            <th scope="col">Total Price for product</th>
+                            <th scope="col">Quantity</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <span th:each="p:${po}">
+                        <tr th:each="product : ${products}" th:if="${product.getIdProdukt()}  == ${p.getIdProdukt()}" class="cart-item">
+                            <td th:text="${product.getIme()}"></td>
+                            <td th:text="${p.getCena()}">Cena</td>
+                            <td th:text="${p.getKolicina()}"></td>
+                        </tr>
+                            </span>
+                        </tbody>
+                    </table>
+
+                    <div>
+                        <label>Total price </label>
+                    <span th:text="${order.getVkupnoSuma()}"></span></div>
+
+                    <form  th:action="@{'/order/{id}/success' (id=${order.getIdNaracka()})}" th:method="POST">
+                        <label>Adresa za dostava</label>
+                        <input type="text" name="address" id="address" placeholder="/">
+                        <button type="submit"
+                                class="btn btn-sm btn-primary cart-product">
+                            <i class="fa fa-trash">Order</i>
+                        </button>
+                    </form>
+                </div>
+            </div>
+        </div>
+    </div>
+</th:block>
+
Index: src/main/resources/templates/delivery.html
===================================================================
--- src/main/resources/templates/delivery.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/delivery.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,43 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div th:if="${delivers.size() == 0}"
+     xmlns:sec="http://www.w3.org/1999/xhtml">
+    <h1 style="text-align: center"> No orders to deliver!</h1>
+</div>
+
+<div class="container mb-4" >
+    <div class="row">
+        <div class="col-12" th:if="${delivers.size() > 0}">
+            <div class="table-responsive">
+                <table class="table table-striped">
+                    <thead>
+                    <tr>
+                        <th scope="col">Order ID</th>
+                        <th scope="col">Address</th>
+                        <th scope="col">Total price</th>
+                        <th scope="col">Date</th>
+
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="delivery : ${delivers} " class="product">
+                        <td th:text="${delivery.getIdNaracka()}" ></td>
+                        <td th:each="order : ${orders}" th:if="${order.getIdNaracka() == delivery.getIdNaracka()}"
+                        th:text="${order.getAdresa()}"></td>
+                        <td  th:each="order : ${orders}"  th:if="${order.getIdNaracka() == delivery.getIdNaracka()}"
+                            th:text="${order.getVkupnoSuma()}"></td>
+                        <td th:text="${delivery.getDatum()}"
+                        ></td>
+                        <td class="text-right">
+                            <form th:method="POST" th:action="@{'/delivery/{id}' (id=${delivery.getIdDostava()})}">
+                                <button type="submit"
+                                        class="btn btn-sm btn-primary cart-product" sec:authorize="hasRole('ROLE_DELIVER')">
+                                    <i class="fa fa-trash">Order delivered</i>
+                                </button>
+                            </form>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
Index: src/main/resources/templates/home.html
===================================================================
--- src/main/resources/templates/home.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/home.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,10 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<section class="jumbotron text-center" xmlns:th="http://www.thymeleaf.org">
+    <div class="container">
+        <h1 class="jumbotron-heading">FMO</h1>
+        <h2 class="jumbotron-heading">Food Market Online</h2>
+    </div>
+</section>
+
+
+
+
Index: src/main/resources/templates/login.html
===================================================================
--- src/main/resources/templates/login.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/login.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,19 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div class="container" xmlns:th="http://www.thymeleaf.org">
+  <form class="form-signin mt-xl-5" method="post" action="/login">
+    <h2 class="form-signin-heading">Sign in</h2>
+    <p>
+      <label for="username" class="sr-only">Username</label>
+      <input type="text" id="username" name="username" class="form-control" placeholder="Username" required=""
+             autofocus="">
+    </p>
+    <p>
+      <label for="password" class="sr-only">Password</label>
+      <input type="password" id="password" name="password" class="form-control" placeholder="Password"
+             required="">
+    </p>
+
+    <div th:text="${param.error}" class="text-danger"></div>
+
+    <button id="submit" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
+  </form>
+</div>
Index: src/main/resources/templates/master_template.html
===================================================================
--- src/main/resources/templates/master_template.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/master_template.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,4 +1,5 @@
 <!DOCTYPE html>
-<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
+      xmlns:sec="http://www.w3.org/1999/xhtml">
 <head>
     <meta charset="UTF-8">
@@ -12,32 +13,63 @@
 <body>
 
-<nav class="navbar navbar-inverse">
-  <div class="container-fluid">
+<header xmlns:th="http://www.thymeleaf.org">
+  <nav class="navbar navbar-expand-md navbar-dark bg-dark">
+    <div class="container">
+      <a class="navbar-brand" href="/">FMO</a>
+      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
+              aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
+        <span class="navbar-toggler-icon"></span>
+      </button>
 
-    <div class="collapse navbar-collapse" id="myNavbar">
-      <ul class="nav navbar-nav">
-        <li class="active"><a href="home.html">Home</a></li>
-        <li><a href="products.html">Products</a></li>
-        <li><a href="statistics.html">Statistics</a></li>
-        <li><a href="delivery.html">Delivery</a></li>
-      </ul>
-      <ul class="nav navbar-nav navbar-right">
-        <li><a href="register.html"><span class="glyphicon glyphicon-user"></span>Register</a></li>
-        <li><a href="/login"><span class="glyphicon glyphicon-user"></span>Login</a></li>
-        <li><a href="cart.html"><span class="glyphicon glyphicon-shopping-cart"></span> Cart</a></li>
-        <li><a href="/logout"><span class="glyphicon glyphicon-user"></span>Log out</a></li>
-      </ul>
+      <div class="collapse navbar-collapse justify-content-end" id="navbarsExampleDefault">
+        <ul class="navbar-nav m-auto">
+          <li class="nav-item m-auto">
+            <a class="nav-link active" href="/products">Products</a>
+          </li>
+          <li class="nav-item m-auto" sec:authorize="hasRole('ROLE_ADMIN')">
+            <a class="nav-link active" th:href="@{/statistics}" th:method="GET">Statistics</a>
+          </li>
+          <li class="nav-item m-auto" sec:authorize="hasRole('ROLE_DELIVER')">
+            <a class="nav-link active" th:href="@{/delivery}" th:method="GET">Delivery</a>
+          </li>
+        </ul>
+
+
+        <ul class="nav navbar-nav navbar-right">
+
+
+          <li class="nav-item" sec:authorize="hasRole('ROLE_USER')">
+            <a class="btn btn-success btn-sm ml-3" th:href="@{/order}" th:method="GET">
+              <i class="fa fa-shopping-cart"></i> Cart
+            </a>
+          </li>
+          <li class="nav-item" sec:authorize="isAuthenticated()">
+            <a class="btn btn-light btn-sm ml-3" href="/logout">
+              <i class="fa fa-shopping-cart"></i> Logout
+            </a>
+          <li class="nav-item">
+            <a class="btn btn-light btn-sm ml-3" sec:authorize="!isAuthenticated()" href="/register">
+              <i class="fa fa-shopping-cart"></i> Register
+            </a>
+          </li>
+          <li class="nav-item" sec:authorize="!isAuthenticated()">
+            <a class="btn btn-light btn-sm ml-3" href="/login">
+              <i class="fa fa-shopping-cart"></i> Login
+            </a>
+          </li>
+        </ul>
+      </div>
     </div>
-  </div>
-</nav>
+  </nav>
+</header>
 
 
 
-<section th:include="${bodyContent}">
+<section th:include="${bodyContent}"></section>
 
 
 
 
-<footer class="container-fluid text-center">
+<footer class="container-fluid text-center" style="padding-top: 100px">
   <p>FMO Store</p>
   <p>2023</p>
Index: src/main/resources/templates/not_valid_delete.html
===================================================================
--- src/main/resources/templates/not_valid_delete.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/not_valid_delete.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,5 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div>
+  <h2 style="text-align: center">Produktot se naogja vo edna ili povekje naracki i zatoa ne moze da bide izbrishen!</h2>
+  <a style="text-align: center; display: block" href="/products">Back to products</a>
+
+</div>
Index: src/main/resources/templates/product_info.html
===================================================================
--- src/main/resources/templates/product_info.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/product_info.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,24 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div xmlns:th="http://www.thymeleaf.org" >
+
+  <form class="block" th:method="post" th:action="@{'/products/{id}/add-to-cart' (id = ${product.getIdProdukt()})}">
+      <input type="hidden" name="idKorisnik" id="idKorisnik" th:value="${#request.getRemoteUser()}">
+      <input type="hidden" name="cena" id="cena" th:value="${price.getIznos()}">
+      <label style="margin: auto; text-align: center; display: block; padding-top: 20px">Product name</label>
+      <p style="margin: auto; text-align: center" id="name" name="name" th:value="${product.getIme()}" th:text="${product.getIme()}"></p>
+      <label style="margin: auto; text-align: center; display: block;  padding-top: 20px">Product description</label>
+      <p style="margin: auto; text-align: center" name="description" id="description"  th:value="${product.getOpis()}" th:text="${product.getOpis()}"></p>
+      <label style="margin: auto; text-align: center; display: block ; padding-top: 20px">price</label>
+      <p style="margin: auto; text-align: center" name="price" id="price" th:value="${price.getIznos()}" th:text="${price.getIznos()}"></p>
+      <label style="margin: auto; text-align: center; display: block;  padding-top: 20px">Category</label>
+      <p style="margin: auto; text-align: center;" name="category" id="category" th:value="${kat.getIme()}" th:text="${kat.getIme()}"></p>
+      <label style="margin: auto; text-align: center; display: block;  padding-top: 20px">Quantity</label>
+      <input type="number" name="quantity" id="quantity" style="margin: auto; text-align: center; display: block" required="required">
+
+
+      <button style="margin: auto; text-align: center; display: block;  padding-top: 20px" id="submit" type="submit" class="btn btn-primary">Submit</button>
+      <a style="margin: auto; text-align: center; display: block;  padding-top: 20px; width: 75px" type="button" class="btn btn-primary" href="/products">Back</a>
+
+  </form>
+
+
+</div>
Index: src/main/resources/templates/products.html
===================================================================
--- src/main/resources/templates/products.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/products.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,69 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div xmlns:th="http://www.thymeleaf.org" xmlns:sec="">
+    <section class="jumbotron text-center">
+        <div class="container">
+            <h1 class="jumbotron-heading">Food Market Online</h1>
+            <h3 class="jumbotron-heading">All products</h3>
+        </div>
+    </section>
+<!--//th:method="GET" th:action="@{/products}"-->
+    <div class="container mb-4" >
+        <div class="row">
+            <div class="col-12" th:if="${products.size() > 0}">
+                <div class="table-responsive">
+                    <table class="table table-striped">
+                        <thead>
+                        <tr>
+                            <th scope="col">Product name</th>
+                            <th scope="col">Price</th>
+                            <th scope="col">Category</th>
+
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr th:each="product : ${products} " class="product">
+                            <td th:text="${product.getIme()}" ></td>
+                            <td th:each="price: ${prices}" th:if="${price.getIdProdukt()} ==  ${product.getIdProdukt()}"
+                                th:text="${price.getIznos()}">Cena</td>
+                            <td th:each="category: ${categories}" th:if="${category.getIdProdukt()} ==  ${product.getIdProdukt()}"
+                                ><span th:each="k:${kat}" th:if="${k.getIdKategorija()} == ${category.getIdKategorija()}"
+                                th:text="${k.getIme()}"></span></td>
+                            <td class="text-right">
+                                <th:block sec:authorize="hasRole('ROLE_ADMIN')">
+                                    <form th:action="@{'/products/delete/{id}' (id=${product.getIdProdukt()})}"
+                                          th:method="DELETE">
+                                        <button type="submit"
+                                                class="btn btn-sm btn-danger delete-product">
+                                            <i class="fa fa-trash">Delete</i>
+                                        </button>
+                                    </form>
+                                </th:block>
+                                <th:block sec:authorize="hasRole('ROLE_ADMIN')">
+                                    <a th:href="@{'/products/edit-form/{id}' (id=${product.getIdProdukt()})}"
+                                       class="btn btn-sm btn-info edit-product">
+                                        <i class="fa fa-trash">Edit</i>
+                                    </a>
+                                </th:block>
+                                <form th:method="GET" th:action="@{'/products/{id}' (id=${product.getIdProdukt()})}">
+                                    <button type="submit"
+                                            class="btn btn-sm btn-primary cart-product" sec:authorize="hasRole('ROLE_USER')">
+                                        <i class="fa fa-trash">Add product to cart</i>
+                                    </button>
+                                </form>
+                            </td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+            <div class="col mb-3">
+                <div class="row">
+                    <div class="col-sm-12 col-md-12"  sec:authorize="hasRole('ROLE_ADMIN')">
+                        <a href="/products/add-form" class="btn btn-block btn-dark add-product-btn">
+                            Add new product
+                        </a>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
Index: src/main/resources/templates/register.html
===================================================================
--- src/main/resources/templates/register.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/register.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,35 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<div class="container">
+    <h1 th:if="${hasError}" th:text="${error}"></h1>
+</div>
+<div class="container">
+    <form class="form-signin mt-xl-5" method="post" action="/register">
+        <h2 class="form-signin-heading">Register</h2>
+        <p>
+            <label for="name_surname" class="sr-only">Name and Surname</label>
+            <input type="text" id="name_surname" name="name_surname" class="form-control" autocomplete="off" placeholder="name_surname" required=""
+                   autofocus="">
+        </p>
+        <p>
+            <label for="password" class="sr-only">Password</label>
+            <input type="password" id="password" name="password" class="form-control" placeholder="Password" autocomplete="off"
+                   required="">
+        </p>
+        <p>
+            <label for="repeatedPassword" class="sr-only">Repeat Password</label>
+            <input type="password" id="repeatedPassword" name="repeatedPassword" class="form-control" autocomplete="off"
+                   placeholder="Repeat Password" required="">
+        </p>
+        <p>
+            <label for="mail" class="sr-only">Mail</label>
+            <input type="text" id="mail" name="mail" class="form-control" placeholder="Mail" required="" autofocus="" autocomplete="off">
+        </p>
+        <p>
+            <label for="number" class="sr-only">Telephone number</label>
+            <input type="text" id="number" name="number" class="form-control" placeholder="number" required="" autocomplete="off"
+                   autofocus="">
+        </p>
+
+        <button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
+    </form>
+</div>
+
Index: src/main/resources/templates/statistics.html
===================================================================
--- src/main/resources/templates/statistics.html	(revision 1dd922639ddb0583e5e61efee73ed97f3f8aa165)
+++ src/main/resources/templates/statistics.html	(revision d14176d864a9e378a444b7d3a7c0e15a27d0113d)
@@ -1,10 +1,63 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <title>$Title$</title>
-</head>
-<body>
-$END$
-</body>
-</html>
+<th:block>
+    <h3 style="text-align: center;color: lightslategrey; margin: 50px">За секој корисник да се најде бројот на нарачки, да се прикаже просечна сума на сите нарачки за сите корисници, вкупна сума на нарачките на купувачот, колку негови нарачки се над глобалниот просек за сума на нарачка и колку е вкупната сума на неговите нарачки кои се над просекот</h3>
+<div class="container mb-4" >
+    <div class="row">
+        <div class="col-12">
+            <div class="table-responsive">
+                <table class="table table-striped">
+                    <thead>
+                    <tr>
+                        <th scope="col">ID</th>
+                        <th scope="col">Ime</th>
+                        <th scope="col">Vkupno naracki</th>
+                        <th scope="col">Prosecna suma na naracka za site kupuvaci</th>
+                        <th scope="col">Vkupna suma od site naracki na korisnikot</th>
+                        <th scope="col">Vkupno naracki nad prosek na korisnikot</th>
+                        <th scope="col">Vkupno suma na naracki nad prosek za korisnikot</th>
+
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="user : ${users} " class="product">
+                        <td th:each="u : ${user}" th:text="${u} ?: '0' " ></td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+
+    <h3 style="text-align: center;color: lightslategrey; margin: 50px">За секој продукт наоѓаме во последните три месеци во колку нарачки е присутен, колкава е количината на продуктот во тие нарачки, просечна сума на нарачката во која е присутен продуктот, број на нарачки на продуктот кои корисникот сам ги подигнал, количина продадена на продуктот која корисникот сам ја подигнал, број на нарачки на продукот кои му биле доставени на корисникот и количина на продуктот која му била доставена на корисникот</h3>
+    <div class="container mb-4" >
+        <div class="row">
+            <div class="col-12">
+                <div class="table-responsive">
+                    <table class="table table-striped">
+                        <thead>
+                        <tr>
+                            <th scope="col">ID</th>
+                            <th scope="col">Produkt ime</th>
+                            <th scope="col">Broj na naracki vo koi e prisuten produktot</th>
+                            <th scope="col">Kolicina prodadeno od produktot</th>
+                            <th scope="col">Prosecna suma na naracka vo koja se sodrzi produktot</th>
+                            <th scope="col">Broj na naracki na produktot koi korisnikot sam ke gi podigne</th>
+                            <th scope="col">Kolicina prodadena na produktot bez dostava</th>
+                            <th scope="col">Broj na naracki na produktot koi ke bidat dostaveni na korisnikot</th>
+                            <th scope="col">Kolicina prodadena na produktot preku dostava</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr th:each="product : ${products} " class="product">
+                            <td th:each="p : ${product}" th:text="${p} ?: '0' " ></td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+
+
+
+</th:block>
