paper model optimize
This commit is contained in:
parent
f89928ce3d
commit
b99a5e9f06
@ -12,9 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
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.AutoCompleteData;
|
import ru.ulstu.paper.model.AutoCompleteData;
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperListDto;
|
import ru.ulstu.paper.model.PaperFilterListDto;
|
||||||
import ru.ulstu.paper.model.ReferenceDto;
|
import ru.ulstu.paper.model.ReferenceDto;
|
||||||
import ru.ulstu.paper.service.LatexService;
|
import ru.ulstu.paper.service.LatexService;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
@ -48,21 +47,21 @@ public class PaperController {
|
|||||||
|
|
||||||
@GetMapping("/papers")
|
@GetMapping("/papers")
|
||||||
public void getPapers(ModelMap modelMap) {
|
public void getPapers(ModelMap modelMap) {
|
||||||
modelMap.put("filteredPapers", new PaperListDto(paperService.findAllDto(), null, null));
|
modelMap.put("filteredPapers", new PaperFilterListDto(paperService.findAllDto(), null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/papers")
|
@PostMapping("/papers")
|
||||||
public void listPapers(@Valid PaperListDto paperListDto, ModelMap modelMap) {
|
public void listPapers(@Valid PaperFilterListDto paperFilterListDto, ModelMap modelMap) {
|
||||||
if (paperListDto.getPaperDeleteId() != null) {
|
if (paperFilterListDto.getPaperDeleteId() != null) {
|
||||||
if (conferenceService.isAttachedToConference(paperListDto.getPaperDeleteId())) {
|
if (conferenceService.isAttachedToConference(paperFilterListDto.getPaperDeleteId())) {
|
||||||
modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции");
|
modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции");
|
||||||
} else {
|
} else {
|
||||||
paperService.delete(paperListDto.getPaperDeleteId());
|
paperService.delete(paperFilterListDto.getPaperDeleteId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelMap.put("filteredPapers", new PaperListDto(paperService.filter(paperListDto),
|
modelMap.put("filteredPapers", new PaperFilterListDto(paperService.filter(paperFilterListDto),
|
||||||
paperListDto.getFilterAuthorId(),
|
paperFilterListDto.getFilterAuthorId(),
|
||||||
paperListDto.getYear()));
|
paperFilterListDto.getYear()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dashboard")
|
@GetMapping("/dashboard")
|
||||||
|
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
|
import ru.ulstu.paper.model.PaperDashboardDto;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperListDto;
|
import ru.ulstu.paper.model.PaperListDto;
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
import ru.ulstu.paper.model.PaperStatusDto;
|
||||||
@ -37,12 +38,12 @@ public class PaperRestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Response<List<PaperDto>> getPapers() {
|
public Response<List<PaperListDto>> getPapers() {
|
||||||
return new Response<>(paperService.findAllDto());
|
return new Response<>(paperService.findAllDto());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dashboard")
|
@GetMapping("/dashboard")
|
||||||
public Response<List<PaperDto>> getDashboard() {
|
public Response<List<PaperDashboardDto>> getDashboard() {
|
||||||
return new Response<>(paperService.findAllActiveDto());
|
return new Response<>(paperService.findAllActiveDto());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +68,6 @@ public class PaperRestController {
|
|||||||
return new Response<>(Boolean.TRUE);
|
return new Response<>(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/filter")
|
|
||||||
public Response<List<PaperDto>> filter(@RequestBody @Valid PaperListDto paperListDto) throws IOException {
|
|
||||||
return new Response<>(paperService.filter(paperListDto));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("formatted-list")
|
@GetMapping("formatted-list")
|
||||||
public Response<List<String>> getFormattedPaperList() {
|
public Response<List<String>> getFormattedPaperList() {
|
||||||
return new Response<>(paperService.getFormattedPaperList());
|
return new Response<>(paperService.getFormattedPaperList());
|
||||||
|
@ -93,7 +93,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date updateDate = new Date();
|
private Date updateDate = new Date();
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "paper_id", unique = true)
|
@JoinColumn(name = "paper_id", unique = true)
|
||||||
@Fetch(FetchMode.SUBSELECT)
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
@OrderBy("date")
|
@OrderBy("date")
|
||||||
@ -109,12 +109,12 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
@JoinColumn(name = "paper_id")
|
@JoinColumn(name = "paper_id")
|
||||||
private List<Event> events = new ArrayList<>();
|
private List<Event> events = new ArrayList<>();
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "paper_id", unique = true)
|
@JoinColumn(name = "paper_id", unique = true)
|
||||||
@Fetch(FetchMode.SUBSELECT)
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
private List<FileData> files = new ArrayList<>();
|
private List<FileData> files = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
private Set<User> authors = new HashSet<>();
|
private Set<User> authors = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "latex_text")
|
@Column(name = "latex_text")
|
||||||
@ -126,7 +126,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
@ManyToMany(mappedBy = "papers")
|
@ManyToMany(mappedBy = "papers")
|
||||||
private List<Grant> grants;
|
private List<Grant> grants;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "paper_id", unique = true)
|
@JoinColumn(name = "paper_id", unique = true)
|
||||||
@Fetch(FetchMode.SUBSELECT)
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
private List<Reference> references = new ArrayList<>();
|
private List<Reference> references = new ArrayList<>();
|
||||||
|
64
src/main/java/ru/ulstu/paper/model/PaperDashboardDto.java
Normal file
64
src/main/java/ru/ulstu/paper/model/PaperDashboardDto.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
|
public class PaperDashboardDto {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String title;
|
||||||
|
private Paper.PaperStatus status;
|
||||||
|
private Set<UserDto> authors;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public PaperDashboardDto(Paper paper) {
|
||||||
|
this.id = paper.getId();
|
||||||
|
this.title = paper.getTitle();
|
||||||
|
this.status = paper.getStatus();
|
||||||
|
this.authors = convert(paper.getAuthors(), UserDto::new);
|
||||||
|
this.url = paper.getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Paper.PaperStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Paper.PaperStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<UserDto> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(Set<UserDto> authors) {
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
51
src/main/java/ru/ulstu/paper/model/PaperFilterListDto.java
Normal file
51
src/main/java/ru/ulstu/paper/model/PaperFilterListDto.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PaperFilterListDto {
|
||||||
|
private List<PaperListDto> papers;
|
||||||
|
private Integer filterAuthorId;
|
||||||
|
private Integer paperDeleteId;
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
|
public PaperFilterListDto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaperFilterListDto(List<PaperListDto> paperDtos, Integer filterAuthorId, Integer year) {
|
||||||
|
this.papers = paperDtos;
|
||||||
|
this.filterAuthorId = filterAuthorId;
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PaperListDto> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapers(List<PaperListDto> papers) {
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFilterAuthorId() {
|
||||||
|
return filterAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterAuthorId(Integer filterAuthorId) {
|
||||||
|
this.filterAuthorId = filterAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(Integer year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPaperDeleteId() {
|
||||||
|
return paperDeleteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaperDeleteId(Integer paperDeleteId) {
|
||||||
|
this.paperDeleteId = paperDeleteId;
|
||||||
|
}
|
||||||
|
}
|
@ -1,51 +1,54 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
import java.util.List;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class PaperListDto {
|
public class PaperListDto {
|
||||||
private List<PaperDto> papers;
|
|
||||||
private Integer filterAuthorId;
|
|
||||||
private Integer paperDeleteId;
|
|
||||||
private Integer year;
|
|
||||||
|
|
||||||
public PaperListDto() {
|
private Integer id;
|
||||||
|
private String title;
|
||||||
|
private Paper.PaperStatus status;
|
||||||
|
private Set<UserDto> authors;
|
||||||
|
|
||||||
|
public PaperListDto(Paper paper) {
|
||||||
|
this.id = paper.getId();
|
||||||
|
this.title = paper.getTitle();
|
||||||
|
this.status = paper.getStatus();
|
||||||
|
this.authors = convert(paper.getAuthors(), UserDto::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaperListDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) {
|
public Integer getId() {
|
||||||
this.papers = paperDtos;
|
return id;
|
||||||
this.filterAuthorId = filterAuthorId;
|
|
||||||
this.year = year;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> getPapers() {
|
public void setId(Integer id) {
|
||||||
return papers;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPapers(List<PaperDto> papers) {
|
public String getTitle() {
|
||||||
this.papers = papers;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFilterAuthorId() {
|
public void setTitle(String title) {
|
||||||
return filterAuthorId;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterAuthorId(Integer filterAuthorId) {
|
public Paper.PaperStatus getStatus() {
|
||||||
this.filterAuthorId = filterAuthorId;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getYear() {
|
public void setStatus(Paper.PaperStatus status) {
|
||||||
return year;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYear(Integer year) {
|
public Set<UserDto> getAuthors() {
|
||||||
this.year = year;
|
return authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPaperDeleteId() {
|
public void setAuthors(Set<UserDto> authors) {
|
||||||
return paperDeleteId;
|
this.authors = authors;
|
||||||
}
|
|
||||||
|
|
||||||
public void setPaperDeleteId(Integer paperDeleteId) {
|
|
||||||
this.paperDeleteId = paperDeleteId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@ import ru.ulstu.file.model.FileDataDto;
|
|||||||
import ru.ulstu.file.service.FileService;
|
import ru.ulstu.file.service.FileService;
|
||||||
import ru.ulstu.paper.model.AutoCompleteData;
|
import ru.ulstu.paper.model.AutoCompleteData;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
import ru.ulstu.paper.model.PaperDashboardDto;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
|
import ru.ulstu.paper.model.PaperFilterListDto;
|
||||||
import ru.ulstu.paper.model.PaperListDto;
|
import ru.ulstu.paper.model.PaperListDto;
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
import ru.ulstu.paper.model.PaperStatusDto;
|
||||||
import ru.ulstu.paper.model.PaperTypeDto;
|
import ru.ulstu.paper.model.PaperTypeDto;
|
||||||
@ -81,10 +83,8 @@ public class PaperService {
|
|||||||
return sortPapers(paperRepository.findAll());
|
return sortPapers(paperRepository.findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> findAllDto() {
|
public List<PaperListDto> findAllDto() {
|
||||||
List<PaperDto> papers = convert(findAll(), PaperDto::new);
|
return convert(findAll(), PaperListDto::new);
|
||||||
papers.forEach(paperDto -> paperDto.setTitle(StringUtils.abbreviate(paperDto.getTitle(), MAX_DISPLAY_SIZE)));
|
|
||||||
return papers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Paper> findAllActive() {
|
private List<Paper> findAllActive() {
|
||||||
@ -94,8 +94,8 @@ public class PaperService {
|
|||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> findAllActiveDto() {
|
public List<PaperDashboardDto> findAllActiveDto() {
|
||||||
return convert(findAllActive(), PaperDto::new);
|
return convert(findAllActive(), PaperDashboardDto::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaperDto findOneDto(Integer id) {
|
public PaperDto findOneDto(Integer id) {
|
||||||
@ -248,10 +248,10 @@ public class PaperService {
|
|||||||
return paper;
|
return paper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> filter(PaperListDto filterDto) {
|
public List<PaperListDto> filter(PaperFilterListDto filterDto) {
|
||||||
return convert(sortPapers(paperRepository.filter(
|
return convert(sortPapers(paperRepository.filter(
|
||||||
filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()),
|
filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()),
|
||||||
filterDto.getYear())), PaperDto::new);
|
filterDto.getYear())), PaperListDto::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Paper> sortPapers(List<Paper> papers) {
|
private List<Paper> sortPapers(List<Paper> papers) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<paper-navigation>
|
<paper-navigation>
|
||||||
</paper-navigation>
|
</paper-navigation>
|
||||||
<div class="row">
|
<div class="row row justify-content-center">
|
||||||
<paper-dashboard-item v-for="paper in papers"
|
<paper-dashboard-item v-for="paper in papers"
|
||||||
:key="paper.id"
|
:key="paper.id"
|
||||||
:paper="paper">
|
:paper="paper">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
:key="paper.id">
|
:key="paper.id">
|
||||||
</paper-status>
|
</paper-status>
|
||||||
<router-link :to="{ path: '/papers/paper', query: { id: paper.id }}" class="portfolio-link">
|
<router-link :to="{ path: '/papers/paper', query: { id: paper.id }}" class="portfolio-link">
|
||||||
<span class="h6">{{ paper.title }}</span>
|
<span class="h6" :title=paper.title>{{ getTitle}}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col">
|
<div class="col-sm-12 col">
|
||||||
@ -35,6 +35,12 @@
|
|||||||
authorsResult.push(author.lastName + " " + author.firstName);
|
authorsResult.push(author.lastName + " " + author.firstName);
|
||||||
});
|
});
|
||||||
return authorsResult.join(', ')
|
return authorsResult.join(', ')
|
||||||
|
},
|
||||||
|
|
||||||
|
getTitle: function () {
|
||||||
|
return this.paper.title.length > 60
|
||||||
|
? this.paper.title.substring(0, 60) + "..."
|
||||||
|
: this.paper.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="col-lg-12 text-center">
|
||||||
|
<h2 class="section-heading text-uppercase">Статьи</h2>
|
||||||
|
</div>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
<router-link to="/papers/papers" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
|
<router-link to="/papers/papers" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
|
||||||
@ -7,7 +11,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
<router-link to="/papers/dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
<router-link to="/papers/dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||||
aria-hidden="true"></i> Панель
|
aria-hidden="true"></i>
|
||||||
|
Панель
|
||||||
управления
|
управления
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
@ -19,4 +24,5 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user