Ignore:
Timestamp:
01/05/23 01:31:58 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
676144b
Parents:
ab952ab
Message:

Added functionalities

Location:
src/main/java/com/example/autopartz/model
Files:
2 added
9 edited

Legend:

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

    rab952ab r7d43957  
    1919@Entity
    2020public class Client extends User{
     21    public Client(String username, String name, String email, String password, String number) {
     22        super(username, name, email, password, number);
     23    }
     24
    2125    @Override
    2226    public boolean equals(Object o) {
  • src/main/java/com/example/autopartz/model/Deliveryman.java

    rab952ab r7d43957  
    2323public class Deliveryman extends User{
    2424    LocalDate employed_from;
     25    public static final LocalDate defaultEmployedFrom = LocalDate.of(2020,1,1);
     26
     27    public Deliveryman(String username, String name, String email, String password, String number) {
     28        super(username, name, email, password, number);
     29        this.employed_from = defaultEmployedFrom;
     30    }
    2531
    2632    @Override
     
    3844    @Override
    3945    public Collection<? extends GrantedAuthority> getAuthorities() {
    40         return Collections.singletonList(Role.ROLE_DELIVERYMAN);
     46        if(Objects.equals(employed_from, defaultEmployedFrom))
     47            return Collections.singletonList(Role.ROLE_PENDING_DELIVERYMAN);
     48        else
     49            return Collections.singletonList(Role.ROLE_DELIVERYMAN);
    4150    }
    4251}
  • src/main/java/com/example/autopartz/model/Order.java

    rab952ab r7d43957  
    2020public class Order {
    2121    @Id
     22    @GeneratedValue(strategy = GenerationType.IDENTITY)
    2223    Integer ID_order;
    2324    String order_status;
     
    3233    @ToString.Exclude
    3334    List<Part> partList;
     35
     36    public Order(Client user) {
     37        this.order_status = "created";
     38        this.user = user;
     39        this.order_date = LocalDateTime.now();
     40    }
    3441
    3542    @Override
  • src/main/java/com/example/autopartz/model/Repair.java

    rab952ab r7d43957  
    77import org.hibernate.Hibernate;
    88
    9 import javax.persistence.Entity;
    10 import javax.persistence.Id;
    11 import javax.persistence.JoinColumn;
    12 import javax.persistence.ManyToOne;
     9import javax.persistence.*;
    1310import java.util.Objects;
    1411
     
    2118    @Id
    2219    Integer ID_repair;
    23     @ManyToOne
    24     @JoinColumn(name = "vin")
    25     CarSample carSample;
     20    @OneToOne
     21    @JoinColumn(name = "id_order")
     22    Order order;
    2623    @ManyToOne
    2724    @JoinColumn(name = "id_repair_shop")
  • src/main/java/com/example/autopartz/model/Role.java

    rab952ab r7d43957  
    66public enum Role implements GrantedAuthority {
    77
    8     ROLE_USER,ROLE_CLIENT, ROLE_ADMIN, ROLE_WAREHOUSEMAN, ROLE_DELIVERYMAN;
     8    ROLE_USER,ROLE_CLIENT, ROLE_ADMIN, ROLE_WAREHOUSEMAN, ROLE_DELIVERYMAN, ROLE_PENDING_WAREHOUSEMAN,ROLE_PENDING_DELIVERYMAN;
    99
    1010    @Override
  • src/main/java/com/example/autopartz/model/User.java

    rab952ab r7d43957  
    2424public class User implements UserDetails {
    2525    @Id
     26    @GeneratedValue(strategy = GenerationType.IDENTITY)
    2627    Integer ID_user;
    2728    String username;
  • src/main/java/com/example/autopartz/model/Warehouse.java

    rab952ab r7d43957  
    77import org.hibernate.Hibernate;
    88
     9import javax.persistence.Column;
    910import javax.persistence.Entity;
    1011import javax.persistence.Id;
     
    1920    @Id
    2021    Integer ID_warehouse;
    21     String warehouse_location;
     22    @Column(name = "warehouse_location")
     23    String location;
    2224
    2325    @Override
  • src/main/java/com/example/autopartz/model/Warehouseman.java

    rab952ab r7d43957  
    2323public class Warehouseman extends User{
    2424    LocalDate employed_from;
     25    public static final LocalDate defaultEmployedFrom = LocalDate.of(2020,1,1);
    2526    @ManyToOne
    2627    @JoinColumn(name = "id_warehouse")
    2728    Warehouse warehouse;
     29
     30    public Warehouseman(String username, String name, String email, String password, String number, Warehouse warehouse) {
     31        super(username, name, email, password, number);
     32        this.employed_from=defaultEmployedFrom;
     33        this.warehouse= warehouse;
     34    }
    2835
    2936    @Override
     
    4148    @Override
    4249    public Collection<? extends GrantedAuthority> getAuthorities() {
    43         return Collections.singletonList(Role.ROLE_WAREHOUSEMAN);
     50        if(employed_from==defaultEmployedFrom)
     51            return Collections.singletonList(Role.ROLE_PENDING_WAREHOUSEMAN);
     52        else
     53            return Collections.singletonList(Role.ROLE_WAREHOUSEMAN);
    4454    }
    4555}
  • src/main/java/com/example/autopartz/model/views/RepairsForUser.java

    rab952ab r7d43957  
    3333    @Id
    3434    String partname;
    35     Integer vin;
     35    Integer orderid;
    3636    String rsname;
    3737}
Note: See TracChangeset for help on using the changeset viewer.