Commit 7e14575a by Bogdan Andjelkovic

LajkController i Lajk

parent 37501b21
package com.example.SkuciSe.controller;
import com.example.SkuciSe.model.korisnik.KorisnikDetails;
import org.springframework.boot.Banner;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class LajkController
{
/*
@Autowired
LajkRepository lajkRepo;
*/
@PostMapping("/lista-oglasa/{oglasId}/lajkuj-oglas")
public String postLajkujOglas(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser, @PathVariable("oglasId") int oglasId)
{
//lajkRepo.update( oglasId, loggedUser.getKorisnik().getKorisnikId());
return "redirect:/lista-oglasa/" + oglasId;
}
}
......@@ -37,6 +37,10 @@ public class OglasController
@Autowired
KomentarRepository komentarRepository;
/*
@Autowired
LajkRepository lajkRepo;
*/
@GetMapping("/novi-oglas")
public String getNoviOglas(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
......@@ -105,7 +109,6 @@ public class OglasController
korisnici.add( kRepo.findById( zahtev.getKorisnikId()));
model.addAttribute("zahtevi", zahtevi);
model.addAttribute("korisnici", korisnici);
}
List<Komentar> komentari = komentarRepository.findAllByOglasID( oglasId);
List<Korisnik> korisniciKomentari = new ArrayList<Korisnik>();
......@@ -115,6 +118,10 @@ public class OglasController
korisniciKomentari.add( kRepo.findById( komentar.getKorisnikId()));
}
model.addAttribute("korisniciKomentari", korisniciKomentari);
/*
model.addAttribute("liked", lajkRepo.isLiked( oglasId, loggedUser.getKorisnik().getKorisnikId()));
model.addAttribute("likesCount", lajkRepo.countLajks( oglasId));
*/
return("oglas");
}
@GetMapping("/profile/moji-oglasi")
......
package com.example.SkuciSe.model.komentar;
import lombok.*;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class Lajk
{
private int korisnikId;
private int oglasId;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment