Merge branch '28-create-all-entities' into 'master'
Resolve "Create all Entities" Closes #28 See merge request marcel.schwarz/2020ss-qbc-geofence-timetracking!24
This commit is contained in:
commit
b90b018196
@ -14,7 +14,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.hft.geotime.record;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
public interface RecordRepository extends CrudRepository<TimeRecord, Long> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package de.hft.geotime.record;
|
||||||
|
|
||||||
|
public enum RecordType {
|
||||||
|
|
||||||
|
BREAK,
|
||||||
|
PAID
|
||||||
|
|
||||||
|
}
|
29
backend/src/main/java/de/hft/geotime/record/TimeRecord.java
Normal file
29
backend/src/main/java/de/hft/geotime/record/TimeRecord.java
Normal file
@ -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;
|
||||||
|
|
||||||
|
}
|
24
backend/src/main/java/de/hft/geotime/role/Role.java
Normal file
24
backend/src/main/java/de/hft/geotime/role/Role.java
Normal file
@ -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
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.hft.geotime.role;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
public interface RoleRepository extends CrudRepository<Role, Long> {
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.hft.geotime.timetrackaccount;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
public interface TimetrackAccountRepository extends CrudRepository<TimetrackAccount, Long> {
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,17 @@
|
|||||||
package de.hft.geotime.user;
|
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.Data;
|
||||||
|
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
|
||||||
|
@AllArgsConstructor
|
||||||
@Entity
|
@Entity
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
@ -17,14 +21,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;
|
||||||
|
|
||||||
protected User() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(String firstname, String lastname) {
|
|
||||||
this.firstname = firstname;
|
|
||||||
this.lastname = lastname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package de.hft.geotime.user;
|
package de.hft.geotime.user;
|
||||||
|
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
|
||||||
|
|
||||||
import javax.websocket.server.PathParam;
|
import javax.websocket.server.PathParam;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RepositoryRestResource
|
public interface UserRepository extends CrudRepository<User, Long> {
|
||||||
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
|
|
||||||
|
|
||||||
List<User> findByUsername(@PathParam("username") String username);
|
List<User> findByUsername(@PathParam("username") String username);
|
||||||
|
|
||||||
|
@ -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
|
@ -1,5 +1,4 @@
|
|||||||
server.port=80
|
server.port=80
|
||||||
spring.data.rest.basePath=/api
|
|
||||||
spring.datasource.hikari.initialization-fail-timeout=0
|
spring.datasource.hikari.initialization-fail-timeout=0
|
||||||
spring.datasource.hikari.max-lifetime=300000
|
spring.datasource.hikari.max-lifetime=300000
|
||||||
spring.profiles.active=prod
|
spring.profiles.active=prod
|
Loading…
Reference in New Issue
Block a user