Changeset 087ce2b for cimeri-main/src
- Timestamp:
- 07/10/23 17:50:01 (17 months ago)
- Branches:
- master
- Parents:
- bc30bce
- Location:
- cimeri-main/src/main
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
cimeri-main/src/main/java/com/example/cimeri/model/Apartment.java
rbc30bce r087ce2b 16 16 private Long buildingid; 17 17 private Long ownerid; 18 private String apartment _adress;19 private int apartment _size;18 private String apartmentfloorandroomnumber; 19 private int apartmentsize; 20 20 21 21 public Apartment() { … … 25 25 this.buildingid=buildingid; 26 26 this.ownerid=ownerid; 27 this.apartment _adress=apartment_adress;28 this.apartment _size=apartment_size;27 this.apartmentfloorandroomnumber =apartment_adress; 28 this.apartmentsize =apartment_size; 29 29 } 30 30 } -
cimeri-main/src/main/java/com/example/cimeri/model/Building.java
rbc30bce r087ce2b 14 14 private Long buildingid; 15 15 16 private String cityname;17 private String building _adress;16 private Long cityid; 17 private String buildingaddress; 18 18 19 19 public Building() { 20 20 } 21 21 22 public Building( String cityname, String building_adress) {23 this.city name=cityname;24 this.building _adress=building_adress;22 public Building(Long cityid, String building_adress) { 23 this.cityid=cityid; 24 this.buildingaddress =building_adress; 25 25 } 26 26 } -
cimeri-main/src/main/java/com/example/cimeri/model/City.java
rbc30bce r087ce2b 10 10 public class City { 11 11 @Id 12 @GeneratedValue(strategy = GenerationType.IDENTITY) 13 private Long cityid; 14 12 15 private String cityname; 13 16 -
cimeri-main/src/main/java/com/example/cimeri/model/Faculty.java
rbc30bce r087ce2b 15 15 16 16 private String facultyname; 17 private String cityname;17 private Long cityid; 18 18 19 19 public Faculty() { 20 20 } 21 21 22 public Faculty(Long facultyid, String facultyname, String cityname) {22 public Faculty(Long facultyid, String facultyname, Long cityid) { 23 23 this.facultyid=facultyid; 24 24 this.facultyname=facultyname; 25 this.city name=cityname;25 this.cityid=cityid; 26 26 } 27 27 } -
cimeri-main/src/main/java/com/example/cimeri/model/OwnerPost.java
rbc30bce r087ce2b 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 6 import java.time.LocalDateTime;7 5 8 6 … … 12 10 public class OwnerPost { 13 11 @Id 14 private Long owner _postid;12 private Long ownerpostid; 15 13 private Long apartmentid; 16 14 private Long ownerid; … … 23 21 24 22 public OwnerPost(Long owner_postid,Long apartmentid,Long ownerid) { 25 this.owner _postid=owner_postid;23 this.ownerpostid =owner_postid; 26 24 this.apartmentid=apartmentid; 27 25 this.ownerid=ownerid; -
cimeri-main/src/main/java/com/example/cimeri/model/Post.java
rbc30bce r087ce2b 14 14 @GeneratedValue(strategy = GenerationType.IDENTITY) 15 15 private Long postid; 16 private String cityname;17 private int number _of_roommates;16 private Long cityid; 17 private int numberofroommates; 18 18 private int price; 19 private LocalDateTime date _posted;19 private LocalDateTime dateposted; 20 20 private String description; 21 21 … … 24 24 } 25 25 26 public Post( String cityname, int number_of_roommates, int price, LocalDateTime date_posted, String description) {27 this.city name=cityname;28 this.number _of_roommates=number_of_roommates;26 public Post(Long cityid, int number_of_roommates, int price, LocalDateTime date_posted, String description) { 27 this.cityid=cityid; 28 this.numberofroommates =number_of_roommates; 29 29 this.price=price; 30 this.date _posted=date_posted;30 this.dateposted =date_posted; 31 31 this.description=description; 32 32 } -
cimeri-main/src/main/java/com/example/cimeri/model/StudentPost.java
rbc30bce r087ce2b 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 6 import java.time.LocalDateTime;7 5 8 6 … … 12 10 public class StudentPost { 13 11 @Id 14 private Long student _postid;12 private Long studentpostid; 15 13 private Long studentid; 16 14 … … 21 19 22 20 public StudentPost(Long student_postid,Long studentid) { 23 this.student _postid=student_postid;21 this.studentpostid =student_postid; 24 22 this.studentid=studentid; 25 23 -
cimeri-main/src/main/java/com/example/cimeri/repository/ApartmentRepository.java
rbc30bce r087ce2b 20 20 21 21 22 @Query("select u.ime,u.prezime,u.phone_number,u.email_address,a.apartment _size,a.apartment_adress,b.building_adress,p.price,photos.photosurl from Building b,User u, Apartment a,Post p,OwnerPost op, Owner o, Photos photos WHERE u.userid=a.ownerid and op.owner_postid=p.postid and op.ownerid=u.userid and o.ownerid=u.userid and o.ownerid=a.ownerid and b.buildingid=a.buildingid and a.apartmentid=op.apartmentid and photos.postid=p.postid and photos.postid=op.owner_postid and p.number_of_roommates=:number_of_roommates and p.price<=:budget and p.cityname=:cityname")23 List filteredapartments(@Param("city name")String cityname, @Param("number_of_roommates") int number_of_roommates, @Param("budget") int budget);22 @Query("select u.ime,u.prezime,u.phone_number,u.email_address,a.apartmentsize,a.apartmentfloorandroomnumber,b.buildingaddress,p.price,photos.photosurl from Building b,User u, Apartment a,Post p,OwnerPost op, Owner o, Photos photos WHERE u.userid=a.ownerid and op.ownerpostid=p.postid and op.ownerid=u.userid and o.ownerid=u.userid and o.ownerid=a.ownerid and b.buildingid=a.buildingid and a.apartmentid=op.apartmentid and photos.postid=p.postid and photos.postid=op.ownerpostid and p.numberofroommates=:number_of_roommates and p.price<=:budget and p.cityid=:cityid") 23 List filteredapartments(@Param("cityid")Long cityid, @Param("number_of_roommates") int number_of_roommates, @Param("budget") int budget); 24 24 25 @Query("select u.ime,u.prezime,u.phone_number,u.email_address,a.apartment _size,a.apartment_adress,b.building_adress,p.price,photos.photosurl from Building b,User u, Apartment a,Post p,OwnerPost op, Owner o, Photos photos WHERE u.userid=a.ownerid and op.owner_postid=p.postid and op.ownerid=u.userid and o.ownerid=u.userid and o.ownerid=a.ownerid and b.buildingid=a.buildingid and a.apartmentid=op.apartmentid and photos.postid=p.postid and photos.postid=op.owner_postid")25 @Query("select u.ime,u.prezime,u.phone_number,u.email_address,a.apartmentsize,a.apartmentfloorandroomnumber,b.buildingaddress,p.price,photos.photosurl from Building b,User u, Apartment a,Post p,OwnerPost op, Owner o, Photos photos WHERE u.userid=a.ownerid and op.ownerpostid=p.postid and op.ownerid=u.userid and o.ownerid=u.userid and o.ownerid=a.ownerid and b.buildingid=a.buildingid and a.apartmentid=op.apartmentid and photos.postid=p.postid and photos.postid=op.ownerpostid") 26 26 List allapartments(); 27 27 } -
cimeri-main/src/main/java/com/example/cimeri/repository/CityRepository.java
rbc30bce r087ce2b 2 2 3 3 import com.example.cimeri.model.City; 4 import com.example.cimeri.model.User; 4 5 import org.springframework.data.jpa.repository.JpaRepository; 5 6 import org.springframework.data.jpa.repository.Query; 7 import org.springframework.data.repository.query.Param; 6 8 import org.springframework.stereotype.Repository; 7 9 … … 13 15 14 16 15 17 @Query("select c.cityname from City c WHERE c.cityid=:cityid") 18 String findCityByCityId(@Param("cityid")Long cityid); 16 19 } -
cimeri-main/src/main/java/com/example/cimeri/repository/OwnerPostRepository.java
rbc30bce r087ce2b 15 15 public interface OwnerPostRepository extends JpaRepository<OwnerPost,Long> { 16 16 17 @Query("select Max(owner _postid) from OwnerPost")17 @Query("select Max(ownerpostid) from OwnerPost") 18 18 Long findMaxOwnerPostID(); 19 19 -
cimeri-main/src/main/java/com/example/cimeri/repository/UserRepository.java
rbc30bce r087ce2b 22 22 23 23 24 @Query("select u from User u,Student s,StudentPost sp,Post p WHERE u.userid=s.studentid and u.userid=sp.studentid and sp.student _postid=p.postid and p.number_of_roommates=:number_of_roommates and p.price<=:budget and p.cityname=:citynameand s.studentid!=:currentid")25 List<User> findAllStudentsThatHavePosted(@Param("city name")String cityname, @Param("number_of_roommates") int number_of_roommates, @Param("budget") int budget, @Param("currentid") Long currentid);24 @Query("select u from User u,Student s,StudentPost sp,Post p WHERE u.userid=s.studentid and u.userid=sp.studentid and sp.studentpostid=p.postid and p.numberofroommates=:number_of_roommates and p.price<=:budget and p.cityid=:cityid and s.studentid!=:currentid") 25 List<User> findAllStudentsThatHavePosted(@Param("cityid")Long cityid, @Param("number_of_roommates") int number_of_roommates, @Param("budget") int budget, @Param("currentid") Long currentid); 26 26 27 27 -
cimeri-main/src/main/java/com/example/cimeri/service/Implementation/UserServiceImplementation.java
rbc30bce r087ce2b 27 27 28 28 @Override 29 public List<User> filteredUsers( String cityname, int budget, int number_of_roommates, Long currentid) {30 List<User> users=userRepository.findAllStudentsThatHavePosted(city name,budget,number_of_roommates,currentid);29 public List<User> filteredUsers(Long cityid, int budget, int number_of_roommates, Long currentid) { 30 List<User> users=userRepository.findAllStudentsThatHavePosted(cityid,budget,number_of_roommates,currentid); 31 31 32 32 -
cimeri-main/src/main/java/com/example/cimeri/service/UserService.java
rbc30bce r087ce2b 1 1 package com.example.cimeri.service; 2 2 3 import com.example.cimeri.model.Faculty;4 3 import com.example.cimeri.model.User; 5 4 … … 9 8 Long findMaxUserID(); 10 9 List<User> listAll(); 11 List<User> filteredUsers( String cityname, int budget, int number_of_roommates,Long currentid);10 List<User> filteredUsers(Long cityname, int budget, int number_of_roommates, Long currentid); 12 11 13 12 -
cimeri-main/src/main/java/com/example/cimeri/web/controller/ListApartmentsController.java
rbc30bce r087ce2b 1 1 package com.example.cimeri.web.controller; 2 2 3 import com.example.cimeri.model.User;4 3 import com.example.cimeri.repository.ApartmentRepository; 4 import com.example.cimeri.repository.CityRepository; 5 5 import jakarta.servlet.http.HttpSession; 6 6 import org.springframework.stereotype.Controller; … … 20 20 21 21 private final ApartmentRepository apartmentRepository; 22 private final CityRepository cityRepository; 22 23 23 public ListApartmentsController(ApartmentRepository apartmentRepository ) {24 public ListApartmentsController(ApartmentRepository apartmentRepository, CityRepository cityRepository) { 24 25 this.apartmentRepository = apartmentRepository; 26 this.cityRepository = cityRepository; 25 27 } 26 28 … … 32 34 int number_of_roommates= (int) httpSession.getAttribute("number_of_roommates"); 33 35 int budget= (int) httpSession.getAttribute("budget"); 36 Long cityid= (Long) httpSession.getAttribute("cityid"); 34 37 35 38 … … 37 40 httpSession.removeAttribute("number_of_roommates"); 38 41 httpSession.removeAttribute("budget"); 42 httpSession.removeAttribute("cityid"); 39 43 40 List filteredapartments=apartmentRepository.filteredapartments(city name,number_of_roommates,budget);44 List filteredapartments=apartmentRepository.filteredapartments(cityid,number_of_roommates,budget); 41 45 model.addAttribute("filteredapartments",filteredapartments); 42 46 … … 45 49 46 50 @PostMapping 47 public String listneededapartments(@RequestParam int number_of_roommates, @RequestParam String cityname, @RequestParam int budget51 public String listneededapartments(@RequestParam int number_of_roommates, @RequestParam Long cityid, @RequestParam int budget 48 52 , HttpSession httpSession, Model model) 49 53 { 50 54 55 String cityname= cityRepository.findCityByCityId(cityid); 51 56 httpSession.setAttribute("number_of_roommates",number_of_roommates); 52 57 httpSession.setAttribute("cityname",cityname); 58 httpSession.setAttribute("cityid",cityid); 53 59 httpSession.setAttribute("budget",budget); 54 60 -
cimeri-main/src/main/java/com/example/cimeri/web/controller/ListStudentsController.java
rbc30bce r087ce2b 4 4 import com.example.cimeri.model.StudentPost; 5 5 import com.example.cimeri.model.User; 6 import com.example.cimeri.repository.CityRepository; 6 7 import com.example.cimeri.repository.PostRepository; 7 8 import com.example.cimeri.repository.StudentPostRepository; … … 31 32 private final FacultyService facultyService; 32 33 private final UserService userService; 34 private final CityRepository cityRepository; 33 35 34 public ListStudentsController(PostRepository postRepository, StudentPostRepository studentPostRepository, UserRepository userRepository, FacultyService facultyService, UserService userService ) {36 public ListStudentsController(PostRepository postRepository, StudentPostRepository studentPostRepository, UserRepository userRepository, FacultyService facultyService, UserService userService, CityRepository cityRepository) { 35 37 this.postRepository = postRepository; 36 38 this.studentPostRepository = studentPostRepository; … … 38 40 this.facultyService = facultyService; 39 41 this.userService = userService; 42 this.cityRepository = cityRepository; 40 43 } 41 44 … … 43 46 public String getPage(HttpSession httpSession,Model model) throws IOException { 44 47 45 String cityname= (String) httpSession.getAttribute("cityname"); 48 46 49 int number_of_roommates= (int) httpSession.getAttribute("number_of_roommates"); 47 50 int budget= (int) httpSession.getAttribute("budget"); 48 51 Long currentid= (Long) httpSession.getAttribute("currentid"); 52 Long cityid= (Long) httpSession.getAttribute("cityid"); 53 String cityname= (String) httpSession.getAttribute("cityname"); 49 54 50 55 httpSession.removeAttribute("cityname"); 56 httpSession.removeAttribute("cityid"); 51 57 httpSession.removeAttribute("number_of_roommates"); 52 58 httpSession.removeAttribute("budget"); 53 59 httpSession.removeAttribute("currentid"); 54 60 55 List<User> similarusers=userService.filteredUsers(city name,number_of_roommates,budget,currentid);61 List<User> similarusers=userService.filteredUsers(cityid,number_of_roommates,budget,currentid); 56 62 model.addAttribute("similarusers",similarusers); 57 63 return "liststudents"; … … 60 66 61 67 @PostMapping(value = "/createpost") 62 public String createpost(@RequestParam int number_of_roommates, @RequestParam String cityname, @RequestParam int budget68 public String createpost(@RequestParam int number_of_roommates, @RequestParam Long cityid, @RequestParam int budget 63 69 , HttpSession httpSession, Model model) 64 70 { 65 Post post=new Post(city name,number_of_roommates,budget, LocalDateTime.now(), "baram cimeri");71 Post post=new Post(cityid,number_of_roommates,budget, LocalDateTime.now(), "baram cimeri"); 66 72 postRepository.save(post); 67 73 Long maxPostID=postRepository.findMaxPostID(); … … 73 79 //do ovde se kreira studentpost 74 80 81 82 String cityname= cityRepository.findCityByCityId(cityid); 75 83 httpSession.setAttribute("number_of_roommates",number_of_roommates); 76 84 httpSession.setAttribute("cityname",cityname); 77 85 httpSession.setAttribute("budget",budget); 86 httpSession.setAttribute("cityid",cityid); 78 87 79 88 -
cimeri-main/src/main/java/com/example/cimeri/web/controller/PostApartmentController.java
rbc30bce r087ce2b 46 46 47 47 @PostMapping(value = "/createpost") 48 public String createpost(@RequestParam int number_of_roommates, @RequestParam String cityname, @RequestParam int price48 public String createpost(@RequestParam int number_of_roommates, @RequestParam Long cityid, @RequestParam int price 49 49 , HttpSession httpSession, @RequestParam String building_adress, @RequestParam String apartment_adress, @RequestParam int apartment_size, 50 50 @RequestParam String photosurl, Model model) 51 51 { 52 Post post=new Post(cityname,number_of_roommates,price, LocalDateTime.now(), "izdavam stan"); 52 53 54 Post post=new Post(cityid,number_of_roommates,price, LocalDateTime.now(), "izdavam stan"); 53 55 postRepository.save(post); 54 56 Long maxPostID=postRepository.findMaxPostID(); … … 57 59 httpSession.setAttribute("currentid",ownerID); 58 60 59 Building building=new Building(cityname,building_adress); 61 62 Building building=new Building(cityid,building_adress); 60 63 buildingRepository.save(building); 61 64 Long maxBuildingID=buildingRepository.findMaxBuildingID(); -
cimeri-main/src/main/resources/templates/findapartments.html
rbc30bce r087ce2b 61 61 <span class="findapartments-text06">CITY</span> 62 62 63 <select class="findapartments-textinput1 input" name="city name" id="cityname">64 <option th:each="city : ${cities}" th:value="${city.city name}" th:name="city" th:text="${city.cityname}">63 <select class="findapartments-textinput1 input" name="cityid" id="cityid"> 64 <option th:each="city : ${cities}" th:value="${city.cityid}" th:name="city" th:text="${city.cityname}"> 65 65 </option> 66 66 </select> -
cimeri-main/src/main/resources/templates/findroommates.html
rbc30bce r087ce2b 61 61 <span class="findroommates-text06">CITY</span> 62 62 63 <select class="findroommates-textinput1 input" name="city name" id="cityname">64 <option th:each="city : ${cities}" th:value="${city.city name}" th:name="city" th:text="${city.cityname}">63 <select class="findroommates-textinput1 input" name="cityid" id="cityid"> 64 <option th:each="city : ${cities}" th:value="${city.cityid}" th:name="city" th:text="${city.cityname}"> 65 65 </option> 66 66 </select> -
cimeri-main/src/main/resources/templates/postapartment.html
rbc30bce r087ce2b 99 99 <br /> 100 100 </span> 101 <select class="postapartment-textinput2 input" name="city name" id="cityname">102 <option th:each="city : ${cities}" th:value="${city.city name}" th:name="city" th:text="${city.cityname}">101 <select class="postapartment-textinput2 input" name="cityid" id="cityid"> 102 <option th:each="city : ${cities}" th:value="${city.cityid}" th:name="city" th:text="${city.cityname}"> 103 103 </option> 104 104 </select>
Note:
See TracChangeset
for help on using the changeset viewer.