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