Changeset feffc2f for src/main


Ignore:
Timestamp:
01/03/23 19:29:20 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
60de3eb
Parents:
eaf0f1b
Message:

Added some views and functionalities

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  
    22
    33import com.example.autopartz.model.*;
     4import com.example.autopartz.model.views.*;
    45import com.example.autopartz.repository.*;
    56import com.example.autopartz.service.UserService;
     7import org.springframework.stereotype.Controller;
     8import org.springframework.ui.Model;
    69import org.springframework.web.bind.annotation.*;
    710
    811import java.util.List;
    912
    10 @RestController
     13@Controller
    1114@RequestMapping("/")
    1215public class UserController {
     
    3942    }
    4043    @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";
    4347    }
    4448    @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";
    4752    }
    4853    @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";
    5157    }
    5258}
  • src/main/java/com/example/autopartz/model/Part.java

    reaf0f1b rfeffc2f  
    1818public class Part {
    1919    @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;
    2326    @ManyToOne
    2427    @JoinColumn(name = "id_part_manufacturer")
    25     PartManufacturer partManufacturer;
     28    PartManufacturer manufacturer;
    2629    @ManyToMany
    2730    @JoinTable(name = "part_is_from_category", joinColumns =
     
    4851        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
    4952        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);
    5154    }
    5255
  • src/main/java/com/example/autopartz/model/PartManufacturer.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.model;
    22
     3import jakarta.persistence.Column;
    34import jakarta.persistence.Entity;
    45import jakarta.persistence.Id;
     
    1819    @Id
    1920    Long ID_part_manufacturer;
    20     String pm_name;
     21    @Column(name = "pm_name")
     22    String name;
    2123    String pm_location;
    2224
  • src/main/java/com/example/autopartz/model/RepairShop.java

    reaf0f1b rfeffc2f  
    1616public class RepairShop {
    1717    @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;
    2226    @ManyToMany
    2327    @JoinTable(name = "repair_shop_is_authorized_for_car_make", joinColumns =
     
    3236        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
    3337        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);
    3539    }
    3640
  • src/main/java/com/example/autopartz/model/User.java

    reaf0f1b rfeffc2f  
    2121    String email;
    2222    String name_user;
    23     String password_user;
     23    @Column(name = "password_user")
     24    String password;
    2425    LocalDateTime user_created_on;
    2526    String phone_number;
     
    2728    @JoinColumn(name = "id_administrator")
    2829    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    }
    2939
    3040    @Override
  • src/main/java/com/example/autopartz/model/views/OrdersForUser.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import jakarta.persistence.Entity;
     
    66import jakarta.persistence.Table;
    77import lombok.*;
    8 import org.hibernate.Hibernate;
    98import org.hibernate.annotations.Immutable;
    10 import org.hibernate.annotations.Subselect;
    119
    1210import java.io.Serial;
    1311import java.io.Serializable;
    14 import java.time.LocalDate;
    1512import java.time.LocalDateTime;
    16 import java.util.Objects;
    1713
    1814// извештај за сите сервиси и за сите број на reviews и avg рејтинг
  • src/main/java/com/example/autopartz/model/views/OrdersForUserId.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import lombok.Data;
  • src/main/java/com/example/autopartz/model/views/PartsForCarTypeAndCategory.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import jakarta.persistence.Entity;
  • src/main/java/com/example/autopartz/model/views/RepairShopReviewsSummary.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import jakarta.persistence.Entity;
     
    77import org.hibernate.Hibernate;
    88import org.hibernate.annotations.Immutable;
    9 import org.hibernate.annotations.Subselect;
    109
    1110import java.io.Serial;
  • src/main/java/com/example/autopartz/model/views/RepairsForUser.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import jakarta.persistence.Entity;
     
    55import jakarta.persistence.IdClass;
    66import jakarta.persistence.Table;
    7 import lombok.*;
    8 import org.hibernate.Hibernate;
     7import lombok.Getter;
     8import lombok.RequiredArgsConstructor;
     9import lombok.Setter;
     10import lombok.ToString;
    911import org.hibernate.annotations.Immutable;
    10 import org.hibernate.annotations.Subselect;
    1112
    1213import java.io.Serial;
    1314import java.io.Serializable;
    14 import java.time.LocalDate;
    1515import java.time.LocalDateTime;
    16 import java.util.Objects;
    1716
    1817// извештај за сите сервиси и за сите број на reviews и avg рејтинг
  • src/main/java/com/example/autopartz/model/views/ReviewsForUser.java

    reaf0f1b rfeffc2f  
    1 package com.example.autopartz.model;
     1package com.example.autopartz.model.views;
    22
    33import jakarta.persistence.Entity;
    44import jakarta.persistence.Id;
    5 import jakarta.persistence.IdClass;
    65import jakarta.persistence.Table;
    7 import lombok.*;
    8 import org.hibernate.Hibernate;
     6import lombok.Getter;
     7import lombok.RequiredArgsConstructor;
     8import lombok.Setter;
     9import lombok.ToString;
    910import org.hibernate.annotations.Immutable;
    10 import org.hibernate.annotations.Subselect;
    1111
    1212import java.io.Serial;
    1313import java.io.Serializable;
    14 import java.time.LocalDate;
    15 import java.time.LocalDateTime;
    16 import java.util.Objects;
    1714
    1815// извештај за сите сервиси и за сите број на reviews и avg рејтинг
  • src/main/java/com/example/autopartz/repository/OrdersForUserRepository.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.repository;
    22
    3 import com.example.autopartz.model.OrdersForUser;
    4 import com.example.autopartz.model.OrdersForUserId;
     3import com.example.autopartz.model.views.OrdersForUser;
     4import com.example.autopartz.model.views.OrdersForUserId;
    55import jakarta.transaction.Transactional;
    66import org.springframework.data.jpa.repository.JpaRepository;
  • src/main/java/com/example/autopartz/repository/PartsForCarTypeAndCategoryRepository.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.repository;
    22
    3 import com.example.autopartz.model.PartsForCarTypeAndCategory;
     3import com.example.autopartz.model.views.PartsForCarTypeAndCategory;
    44import jakarta.transaction.Transactional;
    55import org.springframework.data.jpa.repository.JpaRepository;
  • src/main/java/com/example/autopartz/repository/RepairShopReviewSummaryRepository.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.repository;
    22
    3 import com.example.autopartz.model.RepairShopReviewsSummary;
     3import com.example.autopartz.model.views.RepairShopReviewsSummary;
    44import jakarta.transaction.Transactional;
    55import org.springframework.data.jpa.repository.JpaRepository;
    66import org.springframework.stereotype.Repository;
    7 
    8 import java.util.List;
    97
    108// извештај за сите сервиси и за сите број на reviews и avg рејтинг
     
    1210@Transactional
    1311public interface RepairShopReviewSummaryRepository extends JpaRepository<RepairShopReviewsSummary,Long> {
    14     List<RepairShopReviewsSummary> findAllByRsid(Long rsid);
     12    // List<RepairShopReviewsSummary> findAllByRsid(Long rsid);
    1513}
  • src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.repository;
    22
    3 import com.example.autopartz.model.OrdersForUserId;
    4 import com.example.autopartz.model.RepairsForUser;
     3import com.example.autopartz.model.views.OrdersForUserId;
     4import com.example.autopartz.model.views.RepairsForUser;
    55import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.stereotype.Repository;
    67
    78import java.util.List;
    89
     10@Repository
    911public interface RepairsForUserRepository extends JpaRepository<RepairsForUser, OrdersForUserId> {
    1012    List<RepairsForUser> findAllByUserid(Long userid);
  • src/main/java/com/example/autopartz/repository/ReviewsForUserRepository.java

    reaf0f1b rfeffc2f  
    11package com.example.autopartz.repository;
    22
    3 import com.example.autopartz.model.ReviewsForUser;
     3import com.example.autopartz.model.views.ReviewsForUser;
    44import org.springframework.data.jpa.repository.JpaRepository;
     5import org.springframework.stereotype.Repository;
    56
    67import java.util.List;
    78
     9@Repository
    810public interface ReviewsForUserRepository extends JpaRepository<ReviewsForUser,Long> {
    911    List<ReviewsForUser> findAllByUserid(Long id);
  • src/main/java/com/example/autopartz/repository/UserRepository.java

    reaf0f1b rfeffc2f  
    55import org.springframework.stereotype.Repository;
    66
     7import java.util.List;
     8
    79// import java.util.List;
    810
    911@Repository
    1012public 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);
    1215}
Note: See TracChangeset for help on using the changeset viewer.