#68 added class structure

This commit is contained in:
Nightblade73 2019-04-24 17:41:19 +04:00
parent 5bff419dbd
commit b16b3ed2e3
4 changed files with 81 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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<Ping, Integer> {
}

View File

@ -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;
}
}

View File

@ -10,15 +10,15 @@
<column name="date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="user_id" type="integer">
<column name="users_id" type="integer">
<constraints nullable="false"/>
</column>
<column name="conference_id" type="integer"/>
<column name="version" type="integer"/>
</createTable>
<addPrimaryKey columnNames="id" constraintName="pk_ping" tableName="ping"/>
<addForeignKeyConstraint baseTableName="ping" baseColumnNames="user_id"
constraintName="fk_ping_user_id" referencedTableName="users"
<addForeignKeyConstraint baseTableName="ping" baseColumnNames="users_id"
constraintName="fk_ping_users_id" referencedTableName="users"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="ping" baseColumnNames="conference_id"
constraintName="fk_ping_conference_id" referencedTableName="conference"