Ignore:
Timestamp:
01/04/23 02:49:26 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
ab952ab
Parents:
6832924
Message:

Configured spring security, changed spring version

Location:
src/main/java/com/example/autopartz
Files:
3 added
45 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/autopartz/AutoPartzApplication.java

    r6832924 rae042f4  
    33import org.springframework.boot.SpringApplication;
    44import org.springframework.boot.autoconfigure.SpringBootApplication;
     5import org.springframework.context.annotation.Bean;
     6import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
     7import org.springframework.security.crypto.password.PasswordEncoder;
    58
    69@SpringBootApplication
     
    1013        SpringApplication.run(AutoPartzApplication.class, args);
    1114    }
     15    @Bean
     16    PasswordEncoder passwordEncoder() {
     17        return new BCryptPasswordEncoder(10);
     18    }
     19
    1220
    1321}
  • src/main/java/com/example/autopartz/controller/HomeController.java

    r6832924 rae042f4  
    1414import org.springframework.web.bind.annotation.RequestMapping;
    1515import org.springframework.web.bind.annotation.RequestParam;
     16
     17import javax.servlet.http.HttpServletRequest;
    1618
    1719@Controller
     
    3537
    3638    @GetMapping()
    37     public String getHomePage(Model model){
     39    public String getHomePage(Model model, HttpServletRequest request){
    3840        model.addAttribute("bodyContent","home");
     41        model.addAttribute("user",request.getRemoteUser());
    3942        return "master-template";
    4043    }
  • src/main/java/com/example/autopartz/controller/PartController.java

    r6832924 rae042f4  
    55import com.example.autopartz.service.PriceService;
    66import com.example.autopartz.service.RepairShopService;
    7 import jakarta.servlet.http.HttpServletResponse;
    87import org.springframework.stereotype.Controller;
    98import org.springframework.ui.Model;
    109import org.springframework.web.bind.annotation.*;
    1110
     11import javax.servlet.http.HttpServletResponse;
    1212import java.io.IOException;
    1313
     
    2424    }
    2525    @GetMapping("/{id}")
    26     public String getPartPage(@PathVariable Long id, Model model){
     26    public String getPartPage(@PathVariable Integer id, Model model){
    2727        Part temp = partService.findById(id);
    2828        Integer amount = priceService.findPriceForPart(temp).stream().findFirst().orElseThrow(RuntimeException::new).getAmount();
     
    3333    }
    3434    @GetMapping("/delivery/{id}")
    35     public String getDeliveryPage(@PathVariable Long id, Model model){
     35    public String getDeliveryPage(@PathVariable Integer id, Model model){
    3636        model.addAttribute("repairShops",repairShopService.findAll());
    3737        model.addAttribute("partId",id);
  • src/main/java/com/example/autopartz/controller/UserController.java

    r6832924 rae042f4  
    11package com.example.autopartz.controller;
    22
    3 import com.example.autopartz.model.*;
    4 import com.example.autopartz.model.views.*;
    5 import com.example.autopartz.repository.*;
    6 import com.example.autopartz.service.UserService;
     3import com.example.autopartz.repository.OrdersForUserRepository;
     4import com.example.autopartz.repository.RepairsForUserRepository;
     5import com.example.autopartz.repository.ReviewsForUserRepository;
    76import org.springframework.stereotype.Controller;
    87import org.springframework.ui.Model;
    9 import org.springframework.web.bind.annotation.*;
    10 
    11 import java.util.List;
     8import org.springframework.web.bind.annotation.GetMapping;
     9import org.springframework.web.bind.annotation.PathVariable;
     10import org.springframework.web.bind.annotation.RequestMapping;
    1211
    1312@Controller
    1413@RequestMapping("/")
    1514public class UserController {
    16     private final UserService userService;
    1715    private final OrdersForUserRepository ordersForUserRepository;
    1816    private final RepairsForUserRepository repairsForUserRepository;
    1917    private final ReviewsForUserRepository reviewsForUserRepository;
    20     public UserController(UserService userService, OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) {
    21         this.userService = userService;
     18    public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) {
    2219        this.ordersForUserRepository = ordersForUserRepository;
    2320        this.repairsForUserRepository = repairsForUserRepository;
    2421        this.reviewsForUserRepository = reviewsForUserRepository;
    2522    }
    26     @GetMapping("usersTest")
    27     public List<User> getAllUsers(){
    28         return userService.findAllUsers();
    29     }
    3023    @GetMapping("orders/{id}")
    31     public String getOrdersForUser(@PathVariable Long id, Model model){
     24    public String getOrdersForUser(@PathVariable Integer id, Model model){
    3225        model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id));
    3326        model.addAttribute("bodyContent","ordersForUser");
     
    3528    }
    3629    @GetMapping("repairs/{id}")
    37     public String getRepairsForUser(@PathVariable Long id,Model model){
     30    public String getRepairsForUser(@PathVariable Integer id,Model model){
    3831        model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id));
    3932        model.addAttribute("bodyContent","repairsForUser");
     
    4134    }
    4235    @GetMapping("reviews/{id}")
    43     public String getReviewsForUser(@PathVariable Long id, Model model){
     36    public String getReviewsForUser(@PathVariable Integer id, Model model){
    4437        model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id));
    4538        model.addAttribute("bodyContent","reviewsForUser");
  • src/main/java/com/example/autopartz/model/Administrator.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.Setter;
     5import lombok.ToString;
    56import org.hibernate.Hibernate;
     7import org.springframework.security.core.GrantedAuthority;
    68
     9import javax.persistence.Entity;
    710import java.time.LocalDate;
     11import java.util.Collection;
     12import java.util.Collections;
    813import java.util.Objects;
    914
     
    2934        return getClass().hashCode();
    3035    }
     36
     37    @Override
     38    public Collection<? extends GrantedAuthority> getAuthorities() {
     39        return Collections.singletonList(Role.ROLE_ADMIN);
     40    }
    3141}
  • src/main/java/com/example/autopartz/model/Car.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.util.Objects;
    811
     
    1518public class Car {
    1619    @Id
    17     Long ID_car;
     20    Integer ID_car;
    1821    Integer in_production_since;
    1922    Integer in_production_till;
  • src/main/java/com/example/autopartz/model/CarManufacturer.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.Table;
    6 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    77import org.hibernate.Hibernate;
    88
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.Table;
    912import java.util.Objects;
    1013
     
    1720public class CarManufacturer {
    1821    @Id
    19     Long ID_car_manufacturer;
     22    Integer ID_car_manufacturer;
    2023    String cm_name;
    2124    String cm_country;
  • src/main/java/com/example/autopartz/model/CarSample.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.util.Objects;
    811
  • src/main/java/com/example/autopartz/model/Category.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.util.Objects;
    811
     
    1417public class Category {
    1518    @Id
    16     Long ID_category;
     19    Integer ID_category;
    1720    @Column(name = "category_name")
    1821    String cname;
  • src/main/java/com/example/autopartz/model/Client.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
     8import org.springframework.security.core.GrantedAuthority;
    69
     10import javax.persistence.Entity;
     11import java.util.Collection;
     12import java.util.Collections;
    713import java.util.Objects;
    814
     
    2531        return getClass().hashCode();
    2632    }
     33    @Override
     34    public Collection<? extends GrantedAuthority> getAuthorities() {
     35        return Collections.singletonList(Role.ROLE_CLIENT);
     36    }
    2737}
  • src/main/java/com/example/autopartz/model/Delivery.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.util.Objects;
    811
     
    1417public class Delivery {
    1518    @Id
    16     Long ID_delivery;
     19    Integer ID_delivery;
    1720    String delivery_status;
    1821    String delivery_address;
  • src/main/java/com/example/autopartz/model/Deliveryman.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Table;
    5 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    67import org.hibernate.Hibernate;
     8import org.springframework.security.core.GrantedAuthority;
    79
     10import javax.persistence.Entity;
     11import javax.persistence.Table;
    812import java.time.LocalDate;
     13import java.util.Collection;
     14import java.util.Collections;
    915import java.util.Objects;
    1016
     
    3036        return getClass().hashCode();
    3137    }
     38    @Override
     39    public Collection<? extends GrantedAuthority> getAuthorities() {
     40        return Collections.singletonList(Role.ROLE_DELIVERYMAN);
     41    }
    3242}
  • src/main/java/com/example/autopartz/model/Order.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.time.LocalDateTime;
    811import java.util.List;
     
    1720public class Order {
    1821    @Id
    19     Long ID_order;
     22    Integer ID_order;
    2023    String order_status;
    2124    LocalDateTime order_date;
  • src/main/java/com/example/autopartz/model/Part.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    43import lombok.Getter;
    54import lombok.RequiredArgsConstructor;
     
    87import org.hibernate.Hibernate;
    98
     9import javax.persistence.*;
    1010import java.util.List;
    1111import java.util.Objects;
     
    1919    @Id
    2020    @Column(name = "ID_part")
    21     Long id;
     21    Integer id;
    2222    @Column(name = "part_name")
    2323    String name;
  • src/main/java/com/example/autopartz/model/PartManufacturer.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
    7 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    87import org.hibernate.Hibernate;
    98
     9import javax.persistence.Column;
     10import javax.persistence.Entity;
     11import javax.persistence.Id;
     12import javax.persistence.Table;
    1013import java.util.Objects;
    1114
     
    1821public class PartManufacturer {
    1922    @Id
    20     Long ID_part_manufacturer;
     23    Integer ID_part_manufacturer;
    2124    @Column(name = "pm_name")
    2225    String name;
  • src/main/java/com/example/autopartz/model/Price.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.JoinColumn;
    6 import jakarta.persistence.ManyToOne;
    7 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    87import org.hibernate.Hibernate;
    98
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.JoinColumn;
     12import javax.persistence.ManyToOne;
    1013import java.time.LocalDate;
    1114import java.util.Objects;
     
    1821public class Price {
    1922    @Id
    20     Long ID_price;
     23    Integer ID_price;
    2124    Integer amount;
    2225    LocalDate price_from;
  • src/main/java/com/example/autopartz/model/Repair.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.JoinColumn;
    6 import jakarta.persistence.ManyToOne;
    7 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    87import org.hibernate.Hibernate;
    98
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.JoinColumn;
     12import javax.persistence.ManyToOne;
    1013import java.util.Objects;
    1114
     
    1720public class Repair {
    1821    @Id
    19     Long ID_repair;
     22    Integer ID_repair;
    2023    @ManyToOne
    2124    @JoinColumn(name = "vin")
  • src/main/java/com/example/autopartz/model/RepairShop.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.util.List;
    811import java.util.Objects;
     
    1720    @Id
    1821    @Column(name = "ID_repair_shop")
    19     Long id;
     22    Integer id;
    2023    @Column(name = "rs_name")
    2124    String name;
  • src/main/java/com/example/autopartz/model/Review.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.JoinColumn;
    6 import jakarta.persistence.ManyToOne;
    7 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    87import org.hibernate.Hibernate;
    98
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.JoinColumn;
     12import javax.persistence.ManyToOne;
    1013import java.util.Objects;
    1114
     
    1720public class Review {
    1821    @Id
    19     Long ID_review;
     22    Integer ID_review;
    2023    Integer review_rating;
    2124    String review_comment;
  • src/main/java/com/example/autopartz/model/ServiceBook.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
    68
     9import javax.persistence.*;
    710import java.time.LocalDateTime;
    811import java.util.Objects;
     
    1619public class ServiceBook {
    1720    @Id
    18     Long ID_service_book;
     21    Integer ID_service_book;
    1922    LocalDateTime sb_created_on;
    2023    @OneToOne
  • src/main/java/com/example/autopartz/model/User.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.*;
    4 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    57import org.hibernate.Hibernate;
     8import org.springframework.security.core.GrantedAuthority;
     9import org.springframework.security.core.userdetails.UserDetails;
    610
     11import javax.persistence.*;
    712import java.time.LocalDateTime;
     13import java.util.Collection;
     14import java.util.Collections;
    815import java.util.Objects;
    916
     
    1522@Table(name = "users_table")
    1623@Inheritance(strategy = InheritanceType.JOINED)
    17 public class User {
     24public class User implements UserDetails {
    1825    @Id
    19     Long ID_user;
     26    Integer ID_user;
    2027    String username;
    2128    String email;
     
    5057        return getClass().hashCode();
    5158    }
     59
     60
     61    @Override
     62    public Collection<? extends GrantedAuthority> getAuthorities() {
     63        return Collections.singletonList(Role.ROLE_USER);
     64    }
     65
     66    @Override
     67    public boolean isAccountNonExpired() {
     68        return true;
     69    }
     70
     71    @Override
     72    public boolean isAccountNonLocked() {
     73        return true;
     74    }
     75
     76    @Override
     77    public boolean isCredentialsNonExpired() {
     78        return true;
     79    }
     80
     81    @Override
     82    public boolean isEnabled() {
     83        return true;
     84    }
    5285}
  • src/main/java/com/example/autopartz/model/Warehouse.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    67import org.hibernate.Hibernate;
    78
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
    811import java.util.Objects;
    912
     
    1518public class Warehouse {
    1619    @Id
    17     Long ID_warehouse;
     20    Integer ID_warehouse;
    1821    String warehouse_location;
    1922
  • src/main/java/com/example/autopartz/model/Warehouseman.java

    r6832924 rae042f4  
    11package com.example.autopartz.model;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.JoinColumn;
    5 import jakarta.persistence.ManyToOne;
    6 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    77import org.hibernate.Hibernate;
     8import org.springframework.security.core.GrantedAuthority;
    89
     10import javax.persistence.Entity;
     11import javax.persistence.JoinColumn;
     12import javax.persistence.ManyToOne;
    913import java.time.LocalDate;
     14import java.util.Collection;
     15import java.util.Collections;
    1016import java.util.Objects;
    1117
     
    3339        return getClass().hashCode();
    3440    }
     41    @Override
     42    public Collection<? extends GrantedAuthority> getAuthorities() {
     43        return Collections.singletonList(Role.ROLE_WAREHOUSEMAN);
     44    }
    3545}
  • src/main/java/com/example/autopartz/model/views/OrdersForUser.java

    r6832924 rae042f4  
    11package com.example.autopartz.model.views;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.IdClass;
    6 import jakarta.persistence.Table;
    7 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    87import org.hibernate.annotations.Immutable;
    98
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.IdClass;
     12import javax.persistence.Table;
    1013import java.io.Serial;
    1114import java.io.Serializable;
     
    2528    private static final long serialVersionUID = 1L;
    2629    @Id
    27     Long userid;
     30    Integer userid;
    2831    @Id
    2932    LocalDateTime orderdate;
  • src/main/java/com/example/autopartz/model/views/OrdersForUserId.java

    r6832924 rae042f4  
    88@Data
    99public class OrdersForUserId implements Serializable {
    10     Long userid;
     10    Integer userid;
    1111    LocalDateTime orderdate;
    1212    String partname;
  • src/main/java/com/example/autopartz/model/views/PartsForCarTypeAndCategory.java

    r6832924 rae042f4  
    11package com.example.autopartz.model.views;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.Table;
    6 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    77import org.hibernate.annotations.Immutable;
    88
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.Table;
    912import java.io.Serial;
    1013import java.io.Serializable;
     
    2124    private static final long serialVersionUID = 1L;
    2225    @Id
    23     Long partid;
     26    Integer partid;
    2427    String partname;
    2528    String cartype;
  • src/main/java/com/example/autopartz/model/views/RepairShopReviewsSummary.java

    r6832924 rae042f4  
    11package com.example.autopartz.model.views;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.Table;
    6 import lombok.*;
     3import lombok.Getter;
     4import lombok.RequiredArgsConstructor;
     5import lombok.Setter;
     6import lombok.ToString;
    77import org.hibernate.Hibernate;
    88import org.hibernate.annotations.Immutable;
    99
     10import javax.persistence.Entity;
     11import javax.persistence.Id;
     12import javax.persistence.Table;
    1013import java.io.Serial;
    1114import java.io.Serializable;
     
    2427    private static final long serialVersionUID = 1L;
    2528    @Id
    26     Long rsid;
     29    Integer rsid;
    2730    String rsname;
    28     Integer reviewcount;
     31    Long reviewcount;
    2932    Float reviewaverage;
    3033
  • src/main/java/com/example/autopartz/model/views/RepairsForUser.java

    r6832924 rae042f4  
    11package com.example.autopartz.model.views;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.IdClass;
    6 import jakarta.persistence.Table;
    73import lombok.Getter;
    84import lombok.RequiredArgsConstructor;
     
    117import org.hibernate.annotations.Immutable;
    128
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.IdClass;
     12import javax.persistence.Table;
    1313import java.io.Serial;
    1414import java.io.Serializable;
     
    2828    private static final long serialVersionUID = 1L;
    2929    @Id
    30     Long userid;
     30    Integer userid;
    3131    @Id
    3232    LocalDateTime orderdate;
  • src/main/java/com/example/autopartz/model/views/ReviewsForUser.java

    r6832924 rae042f4  
    11package com.example.autopartz.model.views;
    22
    3 import jakarta.persistence.Entity;
    4 import jakarta.persistence.Id;
    5 import jakarta.persistence.Table;
    63import lombok.Getter;
    74import lombok.RequiredArgsConstructor;
     
    107import org.hibernate.annotations.Immutable;
    118
     9import javax.persistence.Entity;
     10import javax.persistence.Id;
     11import javax.persistence.Table;
    1212import java.io.Serial;
    1313import java.io.Serializable;
     
    2525    private static final long serialVersionUID = 1L;
    2626    @Id
    27     Long repairid;
    28     Long userid;
     27    Integer repairid;
     28    Integer userid;
    2929    Integer rating;
    3030    String rcomment;
  • src/main/java/com/example/autopartz/repository/CarRepository.java

    r6832924 rae042f4  
    66
    77@Repository
    8 public interface CarRepository extends JpaRepository<Car,Long> {
     8public interface CarRepository extends JpaRepository<Car,Integer> {
    99}
  • src/main/java/com/example/autopartz/repository/CategoryRepository.java

    r6832924 rae042f4  
    66
    77@Repository
    8 public interface CategoryRepository extends JpaRepository<Category,Long> {
     8public interface CategoryRepository extends JpaRepository<Category,Integer> {
    99}
  • src/main/java/com/example/autopartz/repository/OrdersForUserRepository.java

    r6832924 rae042f4  
    33import com.example.autopartz.model.views.OrdersForUser;
    44import com.example.autopartz.model.views.OrdersForUserId;
    5 import jakarta.transaction.Transactional;
    65import org.springframework.data.jpa.repository.JpaRepository;
    76import org.springframework.stereotype.Repository;
    87
     8import javax.transaction.Transactional;
    99import java.util.List;
    1010
     
    1212@Transactional
    1313public interface OrdersForUserRepository extends JpaRepository<OrdersForUser, OrdersForUserId> {
    14     List<OrdersForUser> findAllByUserid(Long userid);
     14    List<OrdersForUser> findAllByUserid(Integer userid);
    1515}
  • src/main/java/com/example/autopartz/repository/PartRepository.java

    r6832924 rae042f4  
    66
    77@Repository
    8 public interface PartRepository extends JpaRepository<Part,Long> {
     8public interface PartRepository extends JpaRepository<Part,Integer> {
    99}
  • src/main/java/com/example/autopartz/repository/PartsForCarTypeAndCategoryRepository.java

    r6832924 rae042f4  
    22
    33import com.example.autopartz.model.views.PartsForCarTypeAndCategory;
    4 import jakarta.transaction.Transactional;
    54import org.springframework.data.jpa.repository.JpaRepository;
    65import org.springframework.stereotype.Repository;
    76
     7import javax.transaction.Transactional;
    88import java.util.List;
    99
    1010@Repository
    1111@Transactional
    12 public interface PartsForCarTypeAndCategoryRepository extends JpaRepository<PartsForCarTypeAndCategory,Long> {
     12public interface PartsForCarTypeAndCategoryRepository extends JpaRepository<PartsForCarTypeAndCategory,Integer> {
    1313    List<PartsForCarTypeAndCategory> findAllByCartypeAndCategory(String cartype, String category);
    1414}
  • src/main/java/com/example/autopartz/repository/PriceRepository.java

    r6832924 rae042f4  
    77import java.util.List;
    88
    9 public interface PriceRepository extends JpaRepository<Price,Long> {
     9public interface PriceRepository extends JpaRepository<Price,Integer> {
    1010    List<Price> findAllByPart(Part part);
    1111}
  • src/main/java/com/example/autopartz/repository/RepairShopRepository.java

    r6832924 rae042f4  
    66
    77@Repository
    8 public interface RepairShopRepository extends JpaRepository<RepairShop,Long> {
     8public interface RepairShopRepository extends JpaRepository<RepairShop,Integer> {
    99
    1010}
  • src/main/java/com/example/autopartz/repository/RepairShopReviewSummaryRepository.java

    r6832924 rae042f4  
    22
    33import com.example.autopartz.model.views.RepairShopReviewsSummary;
    4 import jakarta.transaction.Transactional;
    54import org.springframework.data.jpa.repository.JpaRepository;
    65import org.springframework.stereotype.Repository;
     6
     7import javax.transaction.Transactional;
    78
    89// извештај за сите сервиси и за сите број на reviews и avg рејтинг
    910@Repository
    1011@Transactional
    11 public interface RepairShopReviewSummaryRepository extends JpaRepository<RepairShopReviewsSummary,Long> {
    12     // List<RepairShopReviewsSummary> findAllByRsid(Long rsid);
     12public interface RepairShopReviewSummaryRepository extends JpaRepository<RepairShopReviewsSummary,Integer> {
     13    // List<RepairShopReviewsSummary> findAllByRsid(Integer rsid);
    1314}
  • src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java

    r6832924 rae042f4  
    1010@Repository
    1111public interface RepairsForUserRepository extends JpaRepository<RepairsForUser, OrdersForUserId> {
    12     List<RepairsForUser> findAllByUserid(Long userid);
     12    List<RepairsForUser> findAllByUserid(Integer userid);
    1313}
  • src/main/java/com/example/autopartz/repository/ReviewsForUserRepository.java

    r6832924 rae042f4  
    88
    99@Repository
    10 public interface ReviewsForUserRepository extends JpaRepository<ReviewsForUser,Long> {
    11     List<ReviewsForUser> findAllByUserid(Long id);
     10public interface ReviewsForUserRepository extends JpaRepository<ReviewsForUser,Integer> {
     11    List<ReviewsForUser> findAllByUserid(Integer id);
    1212}
  • src/main/java/com/example/autopartz/repository/UserRepository.java

    r6832924 rae042f4  
    1010
    1111@Repository
    12 public interface UserRepository extends JpaRepository<User,Long> {
    13      // List<User> findAllByUsername(String username);
     12public interface UserRepository extends JpaRepository<User,Integer> {
     13     List<User> findAllByUsername(String username);
    1414     List<User> findAllByUsernameAndPassword(String username, String password);
    1515}
  • src/main/java/com/example/autopartz/service/LoginService.java

    r6832924 rae042f4  
    66    User register(String name, String username, String email, String number, String password);
    77    User login(String username, String password);
    8     // User findByUsername(String username);
    9 
    108}
  • src/main/java/com/example/autopartz/service/PartService.java

    r6832924 rae042f4  
    77public interface PartService {
    88    List<Part> findAll();
    9     Part findById(Long id);
     9    Part findById(Integer id);
    1010}
  • src/main/java/com/example/autopartz/service/UserService.java

    r6832924 rae042f4  
    77public interface UserService {
    88    List<User> findAllUsers();
     9    User findByUsername(String username);
     10
    911}
  • src/main/java/com/example/autopartz/service/impl/PartServiceImpl.java

    r6832924 rae042f4  
    2222
    2323    @Override
    24     public Part findById(Long id) {
     24    public Part findById(Integer id) {
    2525        return partRepository.findById(id).orElseThrow(RuntimeException::new);
    2626    }
  • src/main/java/com/example/autopartz/service/impl/UserServiceImpl.java

    r6832924 rae042f4  
    2020        return userRepository.findAll();
    2121    }
     22
     23    @Override
     24    public User findByUsername(String username) {
     25        return userRepository.findAllByUsername(username).stream().findFirst().orElseThrow(RuntimeException::new);
     26    }
    2227}
Note: See TracChangeset for help on using the changeset viewer.