fix display paper title
This commit is contained in:
parent
6e14860c34
commit
469a3ad07d
@ -2,6 +2,7 @@ package ru.ulstu.paper.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import ru.ulstu.deadline.model.DeadlineDto;
|
import ru.ulstu.deadline.model.DeadlineDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
@ -16,9 +17,11 @@ import java.util.stream.Collectors;
|
|||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class PaperDto {
|
public class PaperDto {
|
||||||
|
private final static int MAX_AUTHORS_LENGTH = 60;
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
@Size(min = 3, max = 100)
|
@Size(min = 3, max = 254)
|
||||||
private String title;
|
private String title;
|
||||||
private Paper.PaperStatus status;
|
private Paper.PaperStatus status;
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
@ -196,10 +199,10 @@ public class PaperDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorsString() {
|
public String getAuthorsString() {
|
||||||
return authors
|
return StringUtils.abbreviate(authors
|
||||||
.stream()
|
.stream()
|
||||||
.map(author -> author.getLastName())
|
.map(author -> author.getLastName())
|
||||||
.collect(Collectors.joining(", "));
|
.collect(Collectors.joining(", ")), MAX_AUTHORS_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFilterAuthorId() {
|
public Integer getFilterAuthorId() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.paper.service;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
@ -28,6 +29,8 @@ import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaperService {
|
public class PaperService {
|
||||||
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
|
||||||
private final PaperNotificationService paperNotificationService;
|
private final PaperNotificationService paperNotificationService;
|
||||||
private final PaperRepository paperRepository;
|
private final PaperRepository paperRepository;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
@ -51,7 +54,9 @@ public class PaperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> findAllDto() {
|
public List<PaperDto> findAllDto() {
|
||||||
return convert(findAll(), PaperDto::new);
|
List<PaperDto> papers = convert(findAll(), PaperDto::new);
|
||||||
|
papers.forEach(paperDto -> paperDto.setTitle(StringUtils.abbreviate(paperDto.getTitle(), MAX_DISPLAY_SIZE)));
|
||||||
|
return papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaperDto findOneDto(Integer id) {
|
public PaperDto findOneDto(Integer id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user