#69 managed to create a connection through a new entity

This commit is contained in:
Nightblade73 2019-04-17 13:00:48 +04:00
parent 14c28050c7
commit 8564f2cf34
5 changed files with 53 additions and 12 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.user.model.User;
import ru.ulstu.user.model.UserConference;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -66,7 +66,7 @@ public class Conference extends BaseEntity {
@JoinTable(name = "users_conference",
joinColumns = {@JoinColumn(name = "conference_id")},
inverseJoinColumns = {@JoinColumn(name = "users_id")})
private Set<User> users = new HashSet<>();
private Set<UserConference> users = new HashSet<>();
public String getTitle() {
return title;
@ -132,11 +132,11 @@ public class Conference extends BaseEntity {
this.papers = papers;
}
public Set<User> getUsers() {
public Set<UserConference> getUsers() {
return users;
}
public void setUsers(Set<User> users) {
public void setUsers(Set<UserConference> users) {
this.users = users;
}
}

View File

@ -6,7 +6,7 @@ import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.user.model.UserDto;
import ru.ulstu.user.model.UserConference;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -41,10 +41,8 @@ public class ConferenceDto {
private Set<Integer> userIds = new HashSet<>();
private List<Integer> paperIds = new ArrayList<>();
private List<Paper> papers = new ArrayList<>();
private List<Paper> notSelectedPapers = new ArrayList<>();
private Set<UserDto> users = new HashSet<>();
private Set<UserConference> users = new HashSet<>();
private Integer filterUserId;
public ConferenceDto() {
@ -61,7 +59,7 @@ public class ConferenceDto {
@JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("userIds") Set<Integer> userIds,
@JsonProperty("paperIds") List<Integer> paperIds,
@JsonProperty("users") Set<UserDto> users,
@JsonProperty("users") Set<UserConference> users,
@JsonProperty("papers") List<Paper> papers,
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers) {
this.id = id;
@ -90,7 +88,7 @@ public class ConferenceDto {
this.deadlines = conference.getDeadlines();
this.userIds = convert(conference.getUsers(), user -> user.getId());
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
this.users = convert(conference.getUsers(), UserDto::new);
this.users = conference.getUsers();
this.papers = conference.getPapers();
}
@ -183,11 +181,11 @@ public class ConferenceDto {
this.papers = papers;
}
public Set<UserDto> getUsers() {
public Set<UserConference> getUsers() {
return users;
}
public void setUsers(Set<UserDto> users) {
public void setUsers(Set<UserConference> users) {
this.users = users;
}

View File

@ -0,0 +1,28 @@
package ru.ulstu.user.model;
import ru.ulstu.core.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
@Entity
@Table(name = "users_conference")
public class UserConference extends BaseEntity {
@NotNull
@Column(name = "participation", nullable = false)
private String participation;
@NotNull
@Column(name = "deposit", nullable = false)
private String deposit;
@ManyToOne(optional = false)
@JoinColumn(name = "users_id")
private User user;
}

View File

@ -0,0 +1,14 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="vova" id="20190417_000000-1">
<addColumn tableName="users_conference">
<column name="id" type="integer"></column>
<column name="version" type="integer"></column>
</addColumn>
<addPrimaryKey columnNames="id" constraintName="pk_users_conference" tableName="users_conference"/>
<modifyDataType tableName="users_conference" columnName="participation" newDataType="varchar(255)"/>
</changeSet>
</databaseChangeLog>

View File

@ -24,5 +24,6 @@
<include file="db/changelog-20190331_000000-schema.xml"/>
<include file="db/changelog-20190331_000010-schema.xml"/>
<include file="db/changelog-20190410_000000-schema.xml"/>
<include file="db/changelog-20190417_000000-schema.xml"/>
<include file="db/common/changelog-20190312_130000-schema.xml"/>
</databaseChangeLog>