#107 merge with dev
commit
6df1a87367
@ -0,0 +1,110 @@
|
|||||||
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "users_conference")
|
||||||
|
public class ConferenceUser extends BaseEntity {
|
||||||
|
|
||||||
|
public enum Participation {
|
||||||
|
INTRAMURAL("Очная"),
|
||||||
|
EXTRAMURAL("Заочная");
|
||||||
|
|
||||||
|
private String participationName;
|
||||||
|
|
||||||
|
Participation(String name) {
|
||||||
|
this.participationName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParticipation() {
|
||||||
|
return participationName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Deposit {
|
||||||
|
ARTICLE("Статья"),
|
||||||
|
REPORT("Доклад"),
|
||||||
|
PRESENTATION("Презентация");
|
||||||
|
|
||||||
|
private String depositName;
|
||||||
|
|
||||||
|
Deposit(String name) {
|
||||||
|
this.depositName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeposit() {
|
||||||
|
return depositName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "participation", nullable = false)
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private Participation participation = Participation.INTRAMURAL;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "deposit", nullable = false)
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private Deposit deposit = Deposit.ARTICLE;
|
||||||
|
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "users_id")
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public ConferenceUser() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public ConferenceUser(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("deposit") Participation participation,
|
||||||
|
@JsonProperty("deposit") Deposit deposit,
|
||||||
|
@JsonProperty("user") User user) {
|
||||||
|
this.setId(id);
|
||||||
|
this.participation = participation;
|
||||||
|
this.deposit = deposit;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Participation getParticipation() {
|
||||||
|
return participation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticipation(Participation participation) {
|
||||||
|
this.participation = participation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Deposit getDeposit() {
|
||||||
|
return deposit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeposit(Deposit deposit) {
|
||||||
|
this.deposit = deposit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,19 @@
|
|||||||
package ru.ulstu.conference.repository;
|
package ru.ulstu.conference.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
||||||
|
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||||
|
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||||
|
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||||
|
List<Conference> findAllActive(@Param("date") Date date);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.conference.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
|
|
||||||
|
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
|
import ru.ulstu.conference.repository.ConferenceUserRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ConferenceUserService {
|
||||||
|
|
||||||
|
private final ConferenceUserRepository conferenceUserRepository;
|
||||||
|
|
||||||
|
public ConferenceUserService(ConferenceUserRepository conferenceUserRepository) {
|
||||||
|
this.conferenceUserRepository = conferenceUserRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser> saveOrCreate(List<ConferenceUser> users) {
|
||||||
|
return users
|
||||||
|
.stream()
|
||||||
|
.map(user -> {
|
||||||
|
return user.getId() != null ? update(user) : create(user);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ConferenceUser update(ConferenceUser user) {
|
||||||
|
ConferenceUser updateUser = conferenceUserRepository.findOne(user.getId());
|
||||||
|
updateUser.setDeposit(user.getDeposit());
|
||||||
|
updateUser.setParticipation(user.getParticipation());
|
||||||
|
conferenceUserRepository.save(updateUser);
|
||||||
|
return updateUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ConferenceUser create(ConferenceUser user) {
|
||||||
|
ConferenceUser newUser = new ConferenceUser();
|
||||||
|
newUser.setDeposit(user.getDeposit());
|
||||||
|
newUser.setParticipation(user.getParticipation());
|
||||||
|
newUser.setUser(user.getUser());
|
||||||
|
newUser = conferenceUserRepository.save(newUser);
|
||||||
|
return newUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?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="masha" id="20190421_000000-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="type" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="masha" id="20190421_000000-2">
|
||||||
|
<update tableName="paper">
|
||||||
|
<column name="type" value="OTHER"/>
|
||||||
|
</update>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?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="anton" id="20190418_000000-1">
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="file_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="project" baseColumnNames="file_id"
|
||||||
|
constraintName="fk_project_file_id" referencedTableName="file"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="applicationFileName" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:fragment="headerfiles">
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="projectDashboard (project)" class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3 dashboard-card">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2">
|
||||||
|
<span th:replace="projects/fragments/projectStatusFragment :: projectStatus(projectStatus=${project.status})"/>
|
||||||
|
</div>
|
||||||
|
<div class="col col-10 text-right">
|
||||||
|
<h7 class="service-heading" th:text="${project.title}"> title</h7>
|
||||||
|
<p class="text-muted" th:text="${project.status.statusName}"> status</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue