diff --git a/backend/build.gradle b/backend/build.gradle index 7811350..4ea0a22 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -14,7 +14,6 @@ repositories { } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-rest' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-actuator' diff --git a/backend/src/main/java/de/hft/geotime/record/RecordRepository.java b/backend/src/main/java/de/hft/geotime/record/RecordRepository.java new file mode 100644 index 0000000..22b7906 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/record/RecordRepository.java @@ -0,0 +1,7 @@ +package de.hft.geotime.record; + +import org.springframework.data.repository.CrudRepository; + +public interface RecordRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/de/hft/geotime/record/RecordType.java b/backend/src/main/java/de/hft/geotime/record/RecordType.java new file mode 100644 index 0000000..0adab48 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/record/RecordType.java @@ -0,0 +1,8 @@ +package de.hft.geotime.record; + +public enum RecordType { + + BREAK, + PAID + +} diff --git a/backend/src/main/java/de/hft/geotime/record/TimeRecord.java b/backend/src/main/java/de/hft/geotime/record/TimeRecord.java new file mode 100644 index 0000000..3280d37 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/record/TimeRecord.java @@ -0,0 +1,29 @@ +package de.hft.geotime.record; + +import de.hft.geotime.timetrackaccount.TimetrackAccount; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +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; + +} diff --git a/backend/src/main/java/de/hft/geotime/role/Role.java b/backend/src/main/java/de/hft/geotime/role/Role.java new file mode 100644 index 0000000..7b319b7 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/role/Role.java @@ -0,0 +1,24 @@ +package de.hft.geotime.role; + +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 + +} diff --git a/backend/src/main/java/de/hft/geotime/role/RoleRepository.java b/backend/src/main/java/de/hft/geotime/role/RoleRepository.java new file mode 100644 index 0000000..7e26fa7 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/role/RoleRepository.java @@ -0,0 +1,7 @@ +package de.hft.geotime.role; + +import org.springframework.data.repository.CrudRepository; + +public interface RoleRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccount.java b/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccount.java new file mode 100644 index 0000000..f44e6c8 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccount.java @@ -0,0 +1,25 @@ +package de.hft.geotime.timetrackaccount; + +import de.hft.geotime.user.User; +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; + +} diff --git a/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccountRepository.java b/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccountRepository.java new file mode 100644 index 0000000..38bbc91 --- /dev/null +++ b/backend/src/main/java/de/hft/geotime/timetrackaccount/TimetrackAccountRepository.java @@ -0,0 +1,7 @@ +package de.hft.geotime.timetrackaccount; + +import org.springframework.data.repository.CrudRepository; + +public interface TimetrackAccountRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/de/hft/geotime/user/User.java b/backend/src/main/java/de/hft/geotime/user/User.java index f697365..70c1b6e 100644 --- a/backend/src/main/java/de/hft/geotime/user/User.java +++ b/backend/src/main/java/de/hft/geotime/user/User.java @@ -1,13 +1,17 @@ package de.hft.geotime.user; +import de.hft.geotime.role.Role; +import de.hft.geotime.timetrackaccount.TimetrackAccount; +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; +import javax.persistence.*; +import java.util.List; @Data +@NoArgsConstructor +@AllArgsConstructor @Entity public class User { @@ -17,14 +21,9 @@ public class User { private String username; private String firstname; private String lastname; - //TODO: roleid(FK) - //TODO: timetrackaccounts[List] + @OneToMany + private List roles; + @OneToMany + private List timetrackAccounts; - protected User() { - } - - public User(String firstname, String lastname) { - this.firstname = firstname; - this.lastname = lastname; - } } diff --git a/backend/src/main/java/de/hft/geotime/user/UserRepository.java b/backend/src/main/java/de/hft/geotime/user/UserRepository.java index 9b303ba..2755da1 100644 --- a/backend/src/main/java/de/hft/geotime/user/UserRepository.java +++ b/backend/src/main/java/de/hft/geotime/user/UserRepository.java @@ -1,13 +1,11 @@ package de.hft.geotime.user; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.repository.CrudRepository; import javax.websocket.server.PathParam; import java.util.List; -@RepositoryRestResource -public interface UserRepository extends PagingAndSortingRepository { +public interface UserRepository extends CrudRepository { List findByUsername(@PathParam("username") String username); diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties index e69de29..4497ed1 100644 --- a/backend/src/main/resources/application-dev.properties +++ b/backend/src/main/resources/application-dev.properties @@ -0,0 +1,7 @@ +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console \ No newline at end of file diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 1cf2a4f..cae4ac3 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,5 +1,4 @@ server.port=80 -spring.data.rest.basePath=/api spring.datasource.hikari.initialization-fail-timeout=0 spring.datasource.hikari.max-lifetime=300000 spring.profiles.active=prod \ No newline at end of file