Add location implementation
This commit is contained in:
parent
d47733cc6f
commit
89ba108078
@ -8,6 +8,7 @@
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.12/48e4e5d60309ebd833bc528dcf77668eab3cd72c/lombok-1.18.12.jar" />
|
||||
</processorPath>
|
||||
<module name="geotime.test" />
|
||||
<module name="geotime.main" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
|
27
backend/src/main/java/de/hft/geotime/entities/Location.java
Normal file
27
backend/src/main/java/de/hft/geotime/entities/Location.java
Normal file
@ -0,0 +1,27 @@
|
||||
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 Location {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
|
||||
private int radius;
|
||||
|
||||
}
|
@ -34,4 +34,7 @@ public class TimetrackUser {
|
||||
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
private List<TimetrackAccount> accounts;
|
||||
|
||||
@ManyToOne
|
||||
private Location location;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package de.hft.geotime.entities.projections;
|
||||
|
||||
import de.hft.geotime.entities.TimetrackUser;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
@Projection(name = "onlyLocation", types = TimetrackUser.class)
|
||||
public interface UserOnlyLocation {
|
||||
|
||||
@Value("#{target.location.longitude}")
|
||||
double getLongitude();
|
||||
|
||||
@Value("#{target.location.latitude}")
|
||||
double getLatitude();
|
||||
|
||||
@Value("#{target.location.radius}")
|
||||
int getRadius();
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hft.geotime.repositories;
|
||||
|
||||
import de.hft.geotime.entities.Location;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
||||
@RepositoryRestResource(
|
||||
path = "locations",
|
||||
itemResourceRel = "locations",
|
||||
collectionResourceRel = "locations"
|
||||
)
|
||||
public interface LocationRepository extends PagingAndSortingRepository<Location, Long> {
|
||||
}
|
@ -6,14 +6,17 @@ DELETE FROM role;
|
||||
INSERT INTO role (id, `name`) VALUES
|
||||
(1, 'Admin');
|
||||
|
||||
INSERT INTO location (id, latitude, longitude, radius) VALUES
|
||||
(1, 48.804372, 9.521177, 50);
|
||||
|
||||
/* password is the firstname in lowercase e.g. marcel or tobias
|
||||
https://bcrypt-generator.com/ with 10 rounds
|
||||
*/
|
||||
INSERT INTO timetrack_user (id, firstname, lastname, password, username, role_id) VALUES
|
||||
(1, 'Marcel', 'Schwarz' ,'$2y$10$pDBv7dEaAiNs5Kr1.8g4XuTFx48zGxJu77rei4TlO.sDOF2yHWxo.', 'scma', 1),
|
||||
(2, 'Tobias', 'Wieck' ,'$2y$10$Fxj5cGrZblGKjIExvS/MquEE0lgyYo1ILxPgPR2vSiaaLKkqJ.C.u', 'wito', 1),
|
||||
(3, 'Tim', 'Zieger' ,'$2y$10$pYGHZhoaelceImO7aIN4nOkWJBp.oqNGFYaRAonHkYF4u9ljqPelC', 'ziti', 1),
|
||||
(4, 'Simon', 'Kellner' ,'$2y$10$Puzm/Nr/Dyq3nQxlkXGIfubS5JPtXJSOf2e6mrQ6HhVYQN9YiQQsC', 'kesi', 1);
|
||||
INSERT INTO timetrack_user (id, firstname, lastname, password, username, role_id, location_id) VALUES
|
||||
(1, 'Marcel', 'Schwarz' ,'$2y$10$pDBv7dEaAiNs5Kr1.8g4XuTFx48zGxJu77rei4TlO.sDOF2yHWxo.', 'scma', 1, 1),
|
||||
(2, 'Tobias', 'Wieck' ,'$2y$10$Fxj5cGrZblGKjIExvS/MquEE0lgyYo1ILxPgPR2vSiaaLKkqJ.C.u', 'wito', 1, 1),
|
||||
(3, 'Tim', 'Zieger' ,'$2y$10$pYGHZhoaelceImO7aIN4nOkWJBp.oqNGFYaRAonHkYF4u9ljqPelC', 'ziti', 1, 1),
|
||||
(4, 'Simon', 'Kellner' ,'$2y$10$Puzm/Nr/Dyq3nQxlkXGIfubS5JPtXJSOf2e6mrQ6HhVYQN9YiQQsC', 'kesi', 1, 1);
|
||||
|
||||
INSERT INTO timetrack_account (description, `name`, revenue, user_id) VALUES
|
||||
('Gleitzeit Marcel', 'Primary Marcel', 16.0, 1),
|
||||
|
Loading…
Reference in New Issue
Block a user