Changeset feffc2f
- Timestamp:
- 01/03/23 19:29:20 (23 months ago)
- Branches:
- main
- Children:
- 60de3eb
- Parents:
- eaf0f1b
- Location:
- src/main
- Files:
-
- 21 added
- 11 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/UserController.java
reaf0f1b rfeffc2f 2 2 3 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.model.views.*; 4 5 import com.example.autopartz.repository.*; 5 6 import com.example.autopartz.service.UserService; 7 import org.springframework.stereotype.Controller; 8 import org.springframework.ui.Model; 6 9 import org.springframework.web.bind.annotation.*; 7 10 8 11 import java.util.List; 9 12 10 @ RestController13 @Controller 11 14 @RequestMapping("/") 12 15 public class UserController { … … 39 42 } 40 43 @GetMapping("orders/{id}") 41 public List<OrdersForUser> getOrdersForUser(@PathVariable Long id){ 42 return ordersForUserRepository.findAllByUserid(id); 44 public String getOrdersForUser(@PathVariable Long id, Model model){ 45 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 46 return "ordersForUser"; 43 47 } 44 48 @GetMapping("repairs/{id}") 45 public List<RepairsForUser> getRepairsForUser(@PathVariable Long id){ 46 return repairsForUserRepository.findAllByUserid(id); 49 public String getRepairsForUser(@PathVariable Long id,Model model){ 50 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 51 return "repairsForUser"; 47 52 } 48 53 @GetMapping("reviews/{id}") 49 public List<ReviewsForUser> getReviewsForUser(@PathVariable Long id){ 50 return reviewsForUserRepository.findAllByUserid(id); 54 public String getReviewsForUser(@PathVariable Long id, Model model){ 55 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 56 return "reviewsForUser"; 51 57 } 52 58 } -
src/main/java/com/example/autopartz/model/Part.java
reaf0f1b rfeffc2f 18 18 public class Part { 19 19 @Id 20 Long ID_part; 21 String part_name; 22 String part_description; 20 @Column(name = "ID_part") 21 Long id; 22 @Column(name = "part_name") 23 String name; 24 @Column(name = "part_description") 25 String description; 23 26 @ManyToOne 24 27 @JoinColumn(name = "id_part_manufacturer") 25 PartManufacturer partManufacturer;28 PartManufacturer manufacturer; 26 29 @ManyToMany 27 30 @JoinTable(name = "part_is_from_category", joinColumns = … … 48 51 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 49 52 Part part = (Part) o; 50 return ID_part != null && Objects.equals(ID_part, part.ID_part);53 return id != null && Objects.equals(id, part.id); 51 54 } 52 55 -
src/main/java/com/example/autopartz/model/PartManufacturer.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.model; 2 2 3 import jakarta.persistence.Column; 3 4 import jakarta.persistence.Entity; 4 5 import jakarta.persistence.Id; … … 18 19 @Id 19 20 Long ID_part_manufacturer; 20 String pm_name; 21 @Column(name = "pm_name") 22 String name; 21 23 String pm_location; 22 24 -
src/main/java/com/example/autopartz/model/RepairShop.java
reaf0f1b rfeffc2f 16 16 public class RepairShop { 17 17 @Id 18 Long ID_repair_shop; 19 String rs_name; 20 String rs_location; 21 String rs_phone_number; 18 @Column(name = "ID_repair_shop") 19 Long id; 20 @Column(name = "rs_name") 21 String name; 22 @Column(name = "rs_location") 23 String location; 24 @Column(name = "rs_phone_number") 25 String number; 22 26 @ManyToMany 23 27 @JoinTable(name = "repair_shop_is_authorized_for_car_make", joinColumns = … … 32 36 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; 33 37 RepairShop that = (RepairShop) o; 34 return ID_repair_shop != null && Objects.equals(ID_repair_shop, that.ID_repair_shop);38 return id != null && Objects.equals(id, that.id); 35 39 } 36 40 -
src/main/java/com/example/autopartz/model/User.java
reaf0f1b rfeffc2f 21 21 String email; 22 22 String name_user; 23 String password_user; 23 @Column(name = "password_user") 24 String password; 24 25 LocalDateTime user_created_on; 25 26 String phone_number; … … 27 28 @JoinColumn(name = "id_administrator") 28 29 Administrator administrator; 30 31 public User(String username, String name, String email, String password, String number) { 32 this.username = username; 33 this.name_user = name; 34 this.email = email; 35 this.password = password; 36 this.phone_number = number; 37 this.user_created_on = LocalDateTime.now(); 38 } 29 39 30 40 @Override -
src/main/java/com/example/autopartz/model/views/OrdersForUser.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import jakarta.persistence.Entity; … … 6 6 import jakarta.persistence.Table; 7 7 import lombok.*; 8 import org.hibernate.Hibernate;9 8 import org.hibernate.annotations.Immutable; 10 import org.hibernate.annotations.Subselect;11 9 12 10 import java.io.Serial; 13 11 import java.io.Serializable; 14 import java.time.LocalDate;15 12 import java.time.LocalDateTime; 16 import java.util.Objects;17 13 18 14 // извештај за сите сервиси и за сите број на reviews и avg рејтинг -
src/main/java/com/example/autopartz/model/views/OrdersForUserId.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import lombok.Data; -
src/main/java/com/example/autopartz/model/views/PartsForCarTypeAndCategory.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import jakarta.persistence.Entity; -
src/main/java/com/example/autopartz/model/views/RepairShopReviewsSummary.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import jakarta.persistence.Entity; … … 7 7 import org.hibernate.Hibernate; 8 8 import org.hibernate.annotations.Immutable; 9 import org.hibernate.annotations.Subselect;10 9 11 10 import java.io.Serial; -
src/main/java/com/example/autopartz/model/views/RepairsForUser.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import jakarta.persistence.Entity; … … 5 5 import jakarta.persistence.IdClass; 6 6 import jakarta.persistence.Table; 7 import lombok.*; 8 import org.hibernate.Hibernate; 7 import lombok.Getter; 8 import lombok.RequiredArgsConstructor; 9 import lombok.Setter; 10 import lombok.ToString; 9 11 import org.hibernate.annotations.Immutable; 10 import org.hibernate.annotations.Subselect;11 12 12 13 import java.io.Serial; 13 14 import java.io.Serializable; 14 import java.time.LocalDate;15 15 import java.time.LocalDateTime; 16 import java.util.Objects;17 16 18 17 // извештај за сите сервиси и за сите број на reviews и avg рејтинг -
src/main/java/com/example/autopartz/model/views/ReviewsForUser.java
reaf0f1b rfeffc2f 1 package com.example.autopartz.model ;1 package com.example.autopartz.model.views; 2 2 3 3 import jakarta.persistence.Entity; 4 4 import jakarta.persistence.Id; 5 import jakarta.persistence.IdClass;6 5 import jakarta.persistence.Table; 7 import lombok.*; 8 import org.hibernate.Hibernate; 6 import lombok.Getter; 7 import lombok.RequiredArgsConstructor; 8 import lombok.Setter; 9 import lombok.ToString; 9 10 import org.hibernate.annotations.Immutable; 10 import org.hibernate.annotations.Subselect;11 11 12 12 import java.io.Serial; 13 13 import java.io.Serializable; 14 import java.time.LocalDate;15 import java.time.LocalDateTime;16 import java.util.Objects;17 14 18 15 // извештај за сите сервиси и за сите број на reviews и avg рејтинг -
src/main/java/com/example/autopartz/repository/OrdersForUserRepository.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.repository; 2 2 3 import com.example.autopartz.model. OrdersForUser;4 import com.example.autopartz.model. OrdersForUserId;3 import com.example.autopartz.model.views.OrdersForUser; 4 import com.example.autopartz.model.views.OrdersForUserId; 5 5 import jakarta.transaction.Transactional; 6 6 import org.springframework.data.jpa.repository.JpaRepository; -
src/main/java/com/example/autopartz/repository/PartsForCarTypeAndCategoryRepository.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.repository; 2 2 3 import com.example.autopartz.model. PartsForCarTypeAndCategory;3 import com.example.autopartz.model.views.PartsForCarTypeAndCategory; 4 4 import jakarta.transaction.Transactional; 5 5 import org.springframework.data.jpa.repository.JpaRepository; -
src/main/java/com/example/autopartz/repository/RepairShopReviewSummaryRepository.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.repository; 2 2 3 import com.example.autopartz.model. RepairShopReviewsSummary;3 import com.example.autopartz.model.views.RepairShopReviewsSummary; 4 4 import jakarta.transaction.Transactional; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 6 import org.springframework.stereotype.Repository; 7 8 import java.util.List;9 7 10 8 // извештај за сите сервиси и за сите број на reviews и avg рејтинг … … 12 10 @Transactional 13 11 public interface RepairShopReviewSummaryRepository extends JpaRepository<RepairShopReviewsSummary,Long> { 14 List<RepairShopReviewsSummary> findAllByRsid(Long rsid);12 // List<RepairShopReviewsSummary> findAllByRsid(Long rsid); 15 13 } -
src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.repository; 2 2 3 import com.example.autopartz.model. OrdersForUserId;4 import com.example.autopartz.model. RepairsForUser;3 import com.example.autopartz.model.views.OrdersForUserId; 4 import com.example.autopartz.model.views.RepairsForUser; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.stereotype.Repository; 6 7 7 8 import java.util.List; 8 9 10 @Repository 9 11 public interface RepairsForUserRepository extends JpaRepository<RepairsForUser, OrdersForUserId> { 10 12 List<RepairsForUser> findAllByUserid(Long userid); -
src/main/java/com/example/autopartz/repository/ReviewsForUserRepository.java
reaf0f1b rfeffc2f 1 1 package com.example.autopartz.repository; 2 2 3 import com.example.autopartz.model. ReviewsForUser;3 import com.example.autopartz.model.views.ReviewsForUser; 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 import org.springframework.stereotype.Repository; 5 6 6 7 import java.util.List; 7 8 9 @Repository 8 10 public interface ReviewsForUserRepository extends JpaRepository<ReviewsForUser,Long> { 9 11 List<ReviewsForUser> findAllByUserid(Long id); -
src/main/java/com/example/autopartz/repository/UserRepository.java
reaf0f1b rfeffc2f 5 5 import org.springframework.stereotype.Repository; 6 6 7 import java.util.List; 8 7 9 // import java.util.List; 8 10 9 11 @Repository 10 12 public interface UserRepository extends JpaRepository<User,Long> { 11 // List<User> findAllByUsername(String username); 13 // List<User> findAllByUsername(String username); 14 List<User> findAllByUsernameAndPassword(String username, String password); 12 15 }
Note:
See TracChangeset
for help on using the changeset viewer.