From b16b3ed2e3ab3f20dc4096179bea5ca0c76f0cf4 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Wed, 24 Apr 2019 17:41:19 +0400 Subject: [PATCH] #68 added class structure --- src/main/java/ru/ulstu/ping/model/Ping.java | 58 +++++++++++++++++++ .../ulstu/ping/repository/PingRepository.java | 7 +++ .../ru/ulstu/ping/service/PingService.java | 13 +++++ .../db/changelog-20190424_000000-schema.xml | 6 +- 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/main/java/ru/ulstu/ping/model/Ping.java create mode 100644 src/main/java/ru/ulstu/ping/repository/PingRepository.java create mode 100644 src/main/java/ru/ulstu/ping/service/PingService.java diff --git a/src/main/java/ru/ulstu/ping/model/Ping.java b/src/main/java/ru/ulstu/ping/model/Ping.java new file mode 100644 index 0000000..d3fea2b --- /dev/null +++ b/src/main/java/ru/ulstu/ping/model/Ping.java @@ -0,0 +1,58 @@ +package ru.ulstu.ping.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.format.annotation.DateTimeFormat; +import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.user.model.User; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; + +@Entity +@Table(name = "ping") +public class Ping extends BaseEntity { + @Temporal(value = TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date date; + + @ManyToOne(optional = false) + @JoinColumn(name = "users_id") + private User user; + + public Ping() { + } + + public Ping(Date date, User user) { + this.date = date; + this.user = user; + } + + public Ping(@JsonProperty("id") Integer id, + @JsonProperty("date") Date date, + @JsonProperty("user") User user) { + setId(id); + this.date = date; + this.user = user; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } +} diff --git a/src/main/java/ru/ulstu/ping/repository/PingRepository.java b/src/main/java/ru/ulstu/ping/repository/PingRepository.java new file mode 100644 index 0000000..ebafc0c --- /dev/null +++ b/src/main/java/ru/ulstu/ping/repository/PingRepository.java @@ -0,0 +1,7 @@ +package ru.ulstu.ping.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import ru.ulstu.ping.model.Ping; + +public interface PingRepository extends JpaRepository { +} diff --git a/src/main/java/ru/ulstu/ping/service/PingService.java b/src/main/java/ru/ulstu/ping/service/PingService.java new file mode 100644 index 0000000..07f108a --- /dev/null +++ b/src/main/java/ru/ulstu/ping/service/PingService.java @@ -0,0 +1,13 @@ +package ru.ulstu.ping.service; + +import org.springframework.stereotype.Service; +import ru.ulstu.ping.repository.PingRepository; + +@Service +public class PingService { + private final PingRepository pingRepository; + + public PingService(PingRepository pingRepository) { + this.pingRepository = pingRepository; + } +} diff --git a/src/main/resources/db/changelog-20190424_000000-schema.xml b/src/main/resources/db/changelog-20190424_000000-schema.xml index 50c53f8..d61b38a 100644 --- a/src/main/resources/db/changelog-20190424_000000-schema.xml +++ b/src/main/resources/db/changelog-20190424_000000-schema.xml @@ -10,15 +10,15 @@ - + -