Commit 3f49670c by Vuk Lazovic

SLIKE/DODAVANJE/OVONO

parent e773eee7
...@@ -5,11 +5,30 @@ ...@@ -5,11 +5,30 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="6e82c7f1-3949-40e2-bc26-7eb50b36f993" name="Default Changelist" comment="UPLOAD sada radi"> <list default="true" id="6e82c7f1-3949-40e2-bc26-7eb50b36f993" name="Default Changelist" comment="UPLOAD sada radi">
<change afterPath="$PROJECT_DIR$/unknown.png" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/main/java/app/rep/DodajRep.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/app/usluga/DodajUsluga.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/app/usluga/ImplementacijaDodaj.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/app/usluga/web/DodajKontrol.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/app/vuk.jpg.lnk" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/20554052.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/2446195060_e0018b9214_m.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/4.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/81355b64-5a23-4e90-a98e-25db5dfe414f.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/big-112921447_60589928c5c824-51097158big-112681991_6.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/download.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/macka.jpg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__18_26__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__18_26__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__20_08__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__20_08__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_19_9_2022__15_07__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_19_9_2022__15_07__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/Implementacija.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/usluga/Implementacija.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/static/images/uploads/viber_image_2022-05-26_11-52-21-814.jpg" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/web/OglasController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/web/RegKontroler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/usluga/web/RegKontroler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/property.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/property.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unknown.png" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -170,6 +189,14 @@ ...@@ -170,6 +189,14 @@
&quot;spring.configuration.checksum&quot;: &quot;bb9bda38566c870d6f3a70881ab7a768&quot; &quot;spring.configuration.checksum&quot;: &quot;bb9bda38566c870d6f3a70881ab7a768&quot;
} }
}</component> }</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="app.usluga" />
<recent name="app.usluga.web" />
<recent name="app.usluga.web.transfer" />
<recent name="app.rep" />
</key>
</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Aplikacija" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> <configuration name="Aplikacija" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="registration-login-spring-boot-security-thymeleaf" /> <module name="registration-login-spring-boot-security-thymeleaf" />
...@@ -199,6 +226,7 @@ ...@@ -199,6 +226,7 @@
<workItem from="1663594548080" duration="456000" /> <workItem from="1663594548080" duration="456000" />
<workItem from="1663598082766" duration="1751000" /> <workItem from="1663598082766" duration="1751000" />
<workItem from="1663600055785" duration="984000" /> <workItem from="1663600055785" duration="984000" />
<workItem from="1663675731268" duration="8728000" />
</task> </task>
<task id="LOCAL-00001" summary="dodata ulogovana verzija"> <task id="LOCAL-00001" summary="dodata ulogovana verzija">
<created>1663501497955</created> <created>1663501497955</created>
......
package app.rep;
import app.model.Korisnik;
import app.model.Oglas;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface DodajRep extends JpaRepository<Oglas, Long>{
}
package app.usluga;
import app.model.Oglas;
import org.springframework.security.core.userdetails.UserDetailsService;
import app.model.Korisnik;
import app.usluga.web.transfer.Registracija;
public interface DodajUsluga extends UserDetailsService{
Oglas save(Oglas o);
}
...@@ -7,6 +7,7 @@ import java.util.stream.Collectors; ...@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
...@@ -37,7 +38,8 @@ public class Implementacija implements KorisnickaUsluga{ ...@@ -37,7 +38,8 @@ public class Implementacija implements KorisnickaUsluga{
enkoder.encode(r.getPassword()), Arrays.asList(new Uloga("KORISNIK"))); enkoder.encode(r.getPassword()), Arrays.asList(new Uloga("KORISNIK")));
Korisnik k2=kr.findByEmail(k.getEmail()); Korisnik k2=kr.findByEmail(k.getEmail());
if(k2!=null) { if(k2!=null) {
throw new UsernameNotFoundException("Invalid Username or password"); throw new UsernameNotFoundException("InKKKKKKKKKKKKKord");
} }
return kr.save(k); return kr.save(k);
...@@ -46,6 +48,7 @@ public class Implementacija implements KorisnickaUsluga{ ...@@ -46,6 +48,7 @@ public class Implementacija implements KorisnickaUsluga{
@Override @Override
public UserDetails loadUserByUsername(String ime) throws UsernameNotFoundException { public UserDetails loadUserByUsername(String ime) throws UsernameNotFoundException {
Korisnik k = kr.findByEmail(ime); Korisnik k = kr.findByEmail(ime);
if(k == null) { if(k == null) {
throw new UsernameNotFoundException("Invalid username or password."); throw new UsernameNotFoundException("Invalid username or password.");
......
package app.usluga;
import app.model.Korisnik;
import app.model.Oglas;
import app.model.Uloga;
import app.rep.DodajRep;
import app.rep.KorisnickiRep;
import app.usluga.web.transfer.Registracija;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
@Service
public class ImplementacijaDodaj implements DodajUsluga{
private DodajRep kr;
public ImplementacijaDodaj(DodajRep kr) {
super();
this.kr=kr;
}
@Override
public Oglas save(Oglas r) {
return kr.save(r);
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return null;
}
}
package app.usluga.web;
import app.model.Oglas;
import app.usluga.DodajUsluga;
import app.usluga.KorisnickaUsluga;
import app.usluga.OglasUsluga;
import app.usluga.web.transfer.Registracija;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@Controller
@RequestMapping("/dodaj")
public class DodajKontrol {
private DodajUsluga ku;
public DodajKontrol(DodajUsluga ku) {
super();
this.ku = ku;
}
@ModelAttribute("user")
public Oglas registracija() {
return new Oglas();
}
@GetMapping
public String prikaziRegFormu() {
return "dodaj";
}
@PostMapping
public String registruj(@ModelAttribute("user") Oglas o) {
System.out.println();
o.setVlasnik_id(SecurityContextHolder.getContext().getAuthentication().getPrincipal().hashCode());
ku.save(o);
return "redirect:/";
}
}
...@@ -24,9 +24,9 @@ public class MainKontroler { ...@@ -24,9 +24,9 @@ public class MainKontroler {
{ {
String fileName=file.getOriginalFilename(); String fileName=file.getOriginalFilename();
try { try {
String putanja=System.getProperty("user.dir");
file.transferTo(new File(putanja+"\\src\\main\\resources\\static\\images\\uploads\\"+fileName));
file.transferTo(new File("C:\\xampp\\htdocs\\"+fileName));
} catch (IOException e) { } catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
...@@ -45,10 +45,7 @@ public class MainKontroler { ...@@ -45,10 +45,7 @@ public class MainKontroler {
} }
@GetMapping("/dodaj")
public String prikazidodaj() {
return "dodaj";
}
......
package app.usluga.web;
import app.model.Oglas;
import app.rep.OglasRep;
import app.usluga.OglasUsluga;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@Controller
@RequestMapping("/oglasi")
public class OglasController
{
@Autowired
private OglasUsluga oglasUsluga;
@RequestMapping("/getAll")
public String getAll(Model model)
{
List<Oglas> oglasi = oglasUsluga.getAll();
model.addAttribute("oglasi",oglasi);
return "oglasi";
}
}
package app.usluga.web; package app.usluga.web;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -33,7 +34,11 @@ public class RegKontroler { ...@@ -33,7 +34,11 @@ public class RegKontroler {
@PostMapping @PostMapping
public String registruj(@ModelAttribute("user") Registracija r) { public String registruj(@ModelAttribute("user") Registracija r) {
ku.save(r); ku.save(r);
return "redirect:/registration?success"; //int a=SecurityContextHolder.getContext().getAuthentication().getPrincipal().hashCode();
return "redirect:/";
} }
} }
...@@ -45,8 +45,10 @@ ...@@ -45,8 +45,10 @@
</div> </div>
<div class="col d-flex justify-content-end"> <div class="col d-flex justify-content-end">
<div th:text="${#authentication.name}"> <div th:text="${#authentication.name}">
The value of the "name" property of the authentication object should appear here. The value of the "name" property of the authentication object should appear here.
</div> </div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
{ {
s="<div class=\"col-md-4 ftco-animate\">" + s="<div class=\"col-md-4 ftco-animate\">" +
"<div class=\"properties\">" + "<div class=\"properties\">" +
"<a href=\"property-single.html\" class=\"img img-2 d-flex justify-content-center align-items-center\" style=\"background-image: url(images/properties-5.jpg);\">" + "<a href=\"property-single.html\" class=\"img img-2 d-flex justify-content-center align-items-center\" style=\"background-image: url(http://localhost/"+oglasi[i].slika+");\">" +
"<div class=\"icon d-flex justify-content-center align-items-center\">" + "<div class=\"icon d-flex justify-content-center align-items-center\">" +
"<span class=\"icon-search2\"></span>" + "<span class=\"icon-search2\"></span>" +
"</div>" + "</div>" +
......
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