Merge branch '69-take-part-conf' into 'dev'
Resolve "Принять участие в конференции пользователю" Closes #69 See merge request romanov73/ng-tracker!56
This commit is contained in:
commit
2d0f2aeecd
@ -5,20 +5,20 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.conference.service.ConferenceService;
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -47,13 +47,9 @@ public class ConferenceController {
|
|||||||
@GetMapping("/conference")
|
@GetMapping("/conference")
|
||||||
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||||
if (id != null && id > 0) {
|
if (id != null && id > 0) {
|
||||||
ConferenceDto conferenceDto = conferenceService.findOneDto(id);
|
modelMap.put("conferenceDto", conferenceService.getExistConferenceById(id));
|
||||||
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
|
||||||
modelMap.put("conferenceDto", conferenceDto);
|
|
||||||
} else {
|
} else {
|
||||||
ConferenceDto conferenceDto = new ConferenceDto();
|
modelMap.put("conferenceDto", conferenceService.getNewConference());
|
||||||
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
|
|
||||||
modelMap.put("conferenceDto", conferenceDto);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +100,23 @@ public class ConferenceController {
|
|||||||
return CONFERENCE_PAGE;
|
return CONFERENCE_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
|
@PostMapping(value = "/conference", params = "takePart")
|
||||||
return conferenceService.getConferencePapers(paperIds);
|
public String takePart(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.takePart(conferenceDto);
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allParticipation")
|
||||||
|
public List<ConferenceUser.Participation> getAllParticipation() {
|
||||||
|
return conferenceService.getAllParticipations();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allDeposit")
|
||||||
|
public List<ConferenceUser.Deposit> getAllDeposit() {
|
||||||
|
return conferenceService.getAllDeposit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
|
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
|
||||||
|
@ -7,7 +7,6 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.user.model.User;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -23,9 +22,7 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "conference")
|
@Table(name = "conference")
|
||||||
@ -62,11 +59,10 @@ public class Conference extends BaseEntity {
|
|||||||
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
||||||
private List<Paper> papers = new ArrayList<>();
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "users_conference",
|
@JoinColumn(name = "conference_id", unique = true)
|
||||||
joinColumns = {@JoinColumn(name = "conference_id")},
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
inverseJoinColumns = {@JoinColumn(name = "users_id")})
|
private List<ConferenceUser> users = new ArrayList<>();
|
||||||
private Set<User> users = new HashSet<>();
|
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
@ -132,11 +128,11 @@ public class Conference extends BaseEntity {
|
|||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<User> getUsers() {
|
public List<ConferenceUser> getUsers() {
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsers(Set<User> users) {
|
public void setUsers(List<ConferenceUser> users) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,13 @@ import org.hibernate.validator.constraints.NotEmpty;
|
|||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.user.model.UserDto;
|
|
||||||
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
@ -38,14 +35,12 @@ public class ConferenceDto {
|
|||||||
private Date endDate = new Date();
|
private Date endDate = new Date();
|
||||||
private List<Deadline> deadlines = new ArrayList<>();
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||||
private Set<Integer> userIds = new HashSet<>();
|
private List<Integer> userIds = new ArrayList<>();
|
||||||
private List<Integer> paperIds = new ArrayList<>();
|
private List<Integer> paperIds = new ArrayList<>();
|
||||||
private List<Paper> papers = new ArrayList<>();
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
private List<Paper> notSelectedPapers = new ArrayList<>();
|
private List<Paper> notSelectedPapers = new ArrayList<>();
|
||||||
private Set<UserDto> users = new HashSet<>();
|
private List<ConferenceUser> users = new ArrayList<>();
|
||||||
private Integer filterUserId;
|
private boolean disabledTakePart = false;
|
||||||
|
|
||||||
public ConferenceDto() {
|
public ConferenceDto() {
|
||||||
}
|
}
|
||||||
@ -59,11 +54,12 @@ public class ConferenceDto {
|
|||||||
@JsonProperty("beginDate") Date beginDate,
|
@JsonProperty("beginDate") Date beginDate,
|
||||||
@JsonProperty("endDate") Date endDate,
|
@JsonProperty("endDate") Date endDate,
|
||||||
@JsonProperty("deadlines") List<Deadline> deadlines,
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
@JsonProperty("userIds") Set<Integer> userIds,
|
@JsonProperty("userIds") List<Integer> userIds,
|
||||||
@JsonProperty("paperIds") List<Integer> paperIds,
|
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||||
@JsonProperty("users") Set<UserDto> users,
|
@JsonProperty("users") List<ConferenceUser> users,
|
||||||
@JsonProperty("papers") List<Paper> papers,
|
@JsonProperty("papers") List<Paper> papers,
|
||||||
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers) {
|
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers,
|
||||||
|
@JsonProperty("notSelectedPapers") Boolean disabledTakePart) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -77,6 +73,7 @@ public class ConferenceDto {
|
|||||||
this.users = users;
|
this.users = users;
|
||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
this.notSelectedPapers = notSelectedPapers;
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
|
this.disabledTakePart = disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceDto(Conference conference) {
|
public ConferenceDto(Conference conference) {
|
||||||
@ -90,9 +87,8 @@ public class ConferenceDto {
|
|||||||
this.deadlines = conference.getDeadlines();
|
this.deadlines = conference.getDeadlines();
|
||||||
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
||||||
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
||||||
this.users = convert(conference.getUsers(), UserDto::new);
|
this.users = conference.getUsers();
|
||||||
this.papers = conference.getPapers();
|
this.papers = conference.getPapers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
@ -159,11 +155,11 @@ public class ConferenceDto {
|
|||||||
this.deadlines = deadlines;
|
this.deadlines = deadlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getUserIds() {
|
public List<Integer> getUserIds() {
|
||||||
return userIds;
|
return userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserIds(Set<Integer> userIds) {
|
public void setUserIds(List<Integer> userIds) {
|
||||||
this.userIds = userIds;
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,20 +179,20 @@ public class ConferenceDto {
|
|||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UserDto> getUsers() {
|
public List<ConferenceUser> getUsers() {
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsers(Set<UserDto> users) {
|
public void setUsers(List<ConferenceUser> users) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFilterUserId() {
|
public boolean isDisabledTakePart() {
|
||||||
return filterUserId;
|
return disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterUserId(Integer filterUserId) {
|
public void setDisabledTakePart(boolean disabledTakePart) {
|
||||||
this.filterUserId = filterUserId;
|
this.disabledTakePart = disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getRemovedDeadlineIds() {
|
public List<Integer> getRemovedDeadlineIds() {
|
||||||
|
110
src/main/java/ru/ulstu/conference/model/ConferenceUser.java
Normal file
110
src/main/java/ru/ulstu/conference/model/ConferenceUser.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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> {
|
||||||
|
}
|
@ -5,12 +5,16 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
@ -21,17 +25,37 @@ public class ConferenceService {
|
|||||||
private final static int MAX_DISPLAY_SIZE = 40;
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
|
||||||
private final ConferenceRepository conferenceRepository;
|
private final ConferenceRepository conferenceRepository;
|
||||||
|
private final ConferenceUserService conferenceUserService;
|
||||||
private final DeadlineService deadlineService;
|
private final DeadlineService deadlineService;
|
||||||
private final PaperService paperService;
|
private final PaperService paperService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||||
|
ConferenceUserService conferenceUserService,
|
||||||
DeadlineService deadlineService,
|
DeadlineService deadlineService,
|
||||||
PaperService paperService) {
|
PaperService paperService,
|
||||||
|
UserService userService) {
|
||||||
this.conferenceRepository = conferenceRepository;
|
this.conferenceRepository = conferenceRepository;
|
||||||
|
this.conferenceUserService = conferenceUserService;
|
||||||
this.deadlineService = deadlineService;
|
this.deadlineService = deadlineService;
|
||||||
this.paperService = paperService;
|
this.paperService = paperService;
|
||||||
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConferenceDto getExistConferenceById(Integer id) {
|
||||||
|
ConferenceDto conferenceDto = findOneDto(id);
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
||||||
|
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
|
||||||
|
return conferenceDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto getNewConference() {
|
||||||
|
ConferenceDto conferenceDto = new ConferenceDto();
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
|
||||||
|
return conferenceDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Conference> findAll() {
|
public List<Conference> findAll() {
|
||||||
return conferenceRepository.findAll();
|
return conferenceRepository.findAll();
|
||||||
}
|
}
|
||||||
@ -88,10 +112,23 @@ public class ConferenceService {
|
|||||||
conferenceDto.getNotSelectedPapers().add(removedPaper);
|
conferenceDto.getNotSelectedPapers().add(removedPaper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Paper> getConferencePapers(List<Integer> paperIds) {
|
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
||||||
|
conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
|
||||||
|
conferenceDto.setDisabledTakePart(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
|
||||||
return paperService.findAllNotSelect(paperIds);
|
return paperService.findAllNotSelect(paperIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser.Participation> getAllParticipations() {
|
||||||
|
return Arrays.asList(ConferenceUser.Participation.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser.Deposit> getAllDeposit() {
|
||||||
|
return Arrays.asList(ConferenceUser.Deposit.values());
|
||||||
|
}
|
||||||
|
|
||||||
private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
||||||
conference.setTitle(conferenceDto.getTitle());
|
conference.setTitle(conferenceDto.getTitle());
|
||||||
conference.setDescription(conferenceDto.getDescription());
|
conference.setDescription(conferenceDto.getDescription());
|
||||||
@ -101,6 +138,7 @@ public class ConferenceService {
|
|||||||
conference.setEndDate(conferenceDto.getEndDate());
|
conference.setEndDate(conferenceDto.getEndDate());
|
||||||
conference.setPapers(conferenceDto.getPapers());
|
conference.setPapers(conferenceDto.getPapers());
|
||||||
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
||||||
|
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
|
||||||
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
||||||
conferenceDto.getPaperIds().forEach(paperId ->
|
conferenceDto.getPaperIds().forEach(paperId ->
|
||||||
conference.getPapers().add(paperService.findEntityById(paperId)));
|
conference.getPapers().add(paperService.findEntityById(paperId)));
|
||||||
@ -109,4 +147,7 @@ public class ConferenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCurrentUserParticipant(List<ConferenceUser> conferenceUsers) {
|
||||||
|
return conferenceUsers.stream().anyMatch(participant -> participant.getUser().equals(userService.getCurrentUser()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
14
src/main/resources/db/changelog-20190417_000000-schema.xml
Normal file
14
src/main/resources/db/changelog-20190417_000000-schema.xml
Normal 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>
|
@ -24,6 +24,7 @@
|
|||||||
<include file="db/changelog-20190331_000000-schema.xml"/>
|
<include file="db/changelog-20190331_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190331_000010-schema.xml"/>
|
<include file="db/changelog-20190331_000010-schema.xml"/>
|
||||||
<include file="db/changelog-20190410_000000-schema.xml"/>
|
<include file="db/changelog-20190410_000000-schema.xml"/>
|
||||||
|
<include file="db/changelog-20190417_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190418_000000-schema.xml"/>
|
<include file="db/changelog-20190418_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190323_000001-schema.xml"/>
|
<include file="db/changelog-20190323_000001-schema.xml"/>
|
||||||
<include file="db/common/changelog-20190312_130000-schema.xml"/>
|
<include file="db/common/changelog-20190312_130000-schema.xml"/>
|
||||||
|
@ -43,7 +43,44 @@ body {
|
|||||||
|
|
||||||
.member {
|
.member {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
height: 40px;
|
||||||
|
max-height: 40px;
|
||||||
}
|
}
|
||||||
|
.member select {
|
||||||
|
appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
padding: 0.5rem 1.75em 0.5rem 0.5em;
|
||||||
|
display: inline-block;
|
||||||
|
background: transparent url("https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-16.png") no-repeat right 7px center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.member select:nth-child(4) {
|
||||||
|
border-right: 1px solid #ced4da;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.member-name {
|
||||||
|
padding: .75rem 1.25rem;
|
||||||
|
cursor: default;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-right: 1px solid #ced4da;
|
||||||
|
}
|
||||||
|
|
||||||
|
#take-part[disabled=disabled] {
|
||||||
|
background-color: #ced4da;
|
||||||
|
border-color: #c2c5c7;
|
||||||
|
}
|
||||||
|
|
||||||
|
#take-part[disabled=disabled]:hover {
|
||||||
|
background-color: #737475 !important;
|
||||||
|
border-color: #5d5e5f !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.paper-list {
|
.paper-list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
|
@ -97,38 +97,35 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="members">Участники:</label>
|
<label for="members">Участники:</label>
|
||||||
<div class="member-list form-control list-group" id="members">
|
<div class="member-list form-control list-group" id="members">
|
||||||
<div class="member d-flex list-group-item justify-content-between p-1">
|
<div class="member d-flex list-group-item p-0"
|
||||||
<div class="member-name">
|
th:each="user, rowStat : *{users}">
|
||||||
Пользователь 1
|
<input type="hidden" th:field="*{users[__${rowStat.index}__].id}"/>
|
||||||
</div>
|
<input type="hidden" th:field="*{users[__${rowStat.index}__].user}"/>
|
||||||
<div class="member-participation">
|
<input class="member-name w-100" readonly="true"
|
||||||
очная
|
th:field="*{users[__${rowStat.index}__].user.lastName}"/>
|
||||||
</div>
|
<select class="member-participation w-auto"
|
||||||
<div class="member-deposit">
|
th:field="*{users[__${rowStat.index}__].participation}">
|
||||||
статья
|
<option th:each="participation : ${allParticipation}"
|
||||||
</div>
|
th:value="${participation}"
|
||||||
</div>
|
th:text="${participation.participation}">Participation
|
||||||
|
</option>
|
||||||
|
|
||||||
<div class="member d-flex list-group-item justify-content-between p-1">
|
</select>
|
||||||
<div class="member-name">
|
<select class="member-deposit w-auto"
|
||||||
Пользователь 1
|
th:field="*{users[__${rowStat.index}__].deposit}">
|
||||||
|
<option th:each="deposit : ${allDeposit}" th:value="${deposit}"
|
||||||
|
th:text="${deposit.deposit}">Deposit
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="member-participation">
|
|
||||||
очная
|
|
||||||
</div>
|
|
||||||
<div class="member-deposit">
|
|
||||||
доклад
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group d-flex justify-content-end">
|
<div class="form-group d-flex justify-content-end">
|
||||||
<button id="take-part" class="btn btn-primary"
|
<input type="hidden" th:value="*{disabledTakePart}" th:name="disabledTakePart"/>
|
||||||
type="button">
|
<input id="take-part" class="btn btn-primary"
|
||||||
Принять участие
|
type="submit" name="takePart" value="Принять участие"
|
||||||
</button>
|
th:disabled="*{disabledTakePart}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -202,6 +202,7 @@
|
|||||||
});
|
});
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function updateAuthors() {
|
function updateAuthors() {
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
});
|
});
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user