Add Role, TimeRecord, TimetrackAccount and RecordType

Update User to have Roles and TimetrackAccounts
This commit is contained in:
Marcel Schwarz 2020-04-28 12:31:04 +02:00
parent 60f069b635
commit 92de6cc6f4
5 changed files with 85 additions and 6 deletions

View File

@ -0,0 +1,6 @@
package de.hft.geotime.entities;
public enum RecordType {
BREAK,
PAID
}

View File

@ -0,0 +1,24 @@
package de.hft.geotime.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
// TODO: Permission List
}

View File

@ -0,0 +1,27 @@
package de.hft.geotime.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.type.TimeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import java.time.Duration;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class TimeRecord {
@Id
private long id;
@OneToOne
private TimetrackAccount account;
private Date startdate;
private Date enddate;
private Duration time;
private RecordType type;
}

View File

@ -0,0 +1,22 @@
package de.hft.geotime.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class TimetrackAccount {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@OneToOne
private User user;
private double revenue;
private String name;
private String description;
}

View File

@ -4,10 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.*;
import javax.persistence.GeneratedValue; import java.util.List;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -21,7 +19,9 @@ public class User {
private String username; private String username;
private String firstname; private String firstname;
private String lastname; private String lastname;
//TODO: roleid(FK) @OneToMany
//TODO: timetrackaccounts[List] private List<Role> roles;
@OneToMany
private List<TimetrackAccount> timetrackAccounts;
} }