fix enum dtos

pull/244/head
Anton Romanov 5 years ago
parent 8449c028f9
commit 51164ce11c

@ -3,22 +3,18 @@ package ru.ulstu.paper.controller;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperListDto;
import ru.ulstu.paper.service.LatexService;
import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
@ -103,21 +99,6 @@ public class PaperController {
return "/papers/paper";
}
@ModelAttribute("allStatuses")
public List<Paper.PaperStatus> getPaperStatuses() {
return paperService.getPaperStatuses();
}
@ModelAttribute("allTypes")
public List<Paper.PaperType> getPaperTypes() {
return paperService.getPaperTypes();
}
@ModelAttribute("allAuthors")
public List<User> getAllAuthors() {
return paperService.getPaperAuthors();
}
@ModelAttribute("allYears")
public List<Integer> getAllYears() {
List<Integer> years = new ArrayList<>();

@ -10,9 +10,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.response.Response;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperListDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.model.PaperTypeDto;
import ru.ulstu.paper.model.ReferenceDto;
import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.model.User;
@ -86,12 +87,12 @@ public class PaperRestController {
}
@GetMapping("/allTypes")
public Response<List<Paper.PaperType>> getPaperTypes() {
public Response<List<PaperTypeDto>> getPaperTypes() {
return new Response<>(paperService.getPaperTypes());
}
@GetMapping("/allStatuses")
public Response<List<Paper.PaperStatus>> getPaperStatuses() {
public Response<List<PaperStatusDto>> getPaperStatuses() {
return new Response<>(paperService.getPaperStatuses());
}
}

@ -0,0 +1,19 @@
package ru.ulstu.paper.model;
public class PaperStatusDto {
private final String id;
private final String name;
public PaperStatusDto(Paper.PaperStatus status) {
this.id = status.name();
this.name = status.getStatusName();
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}

@ -0,0 +1,19 @@
package ru.ulstu.paper.model;
public class PaperTypeDto {
private final String id;
private final String name;
public PaperTypeDto(Paper.PaperType type) {
this.id = type.name();
this.name = type.getTypeName();
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}

@ -10,6 +10,8 @@ import ru.ulstu.file.service.FileService;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperListDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.model.PaperTypeDto;
import ru.ulstu.paper.model.ReferenceDto;
import ru.ulstu.paper.repository.PaperRepository;
import ru.ulstu.timeline.service.EventService;
@ -160,12 +162,12 @@ public class PaperService {
paperRepository.delete(paper);
}
public List<Paper.PaperStatus> getPaperStatuses() {
return Arrays.asList(Paper.PaperStatus.values());
public List<PaperStatusDto> getPaperStatuses() {
return convert(Arrays.asList(Paper.PaperStatus.values()), PaperStatusDto::new);
}
public List<Paper.PaperType> getPaperTypes() {
return Arrays.asList(Paper.PaperType.values());
public List<PaperTypeDto> getPaperTypes() {
return convert(Arrays.asList(Paper.PaperType.values()), PaperTypeDto::new);
}
@Transactional

@ -35,7 +35,7 @@
<div class="form-group">
<label for="type">Тип статьи:</label>
<select class="form-control" id="type">
<option v-for="type in allTypes" value="type">{{ type }}
<option v-for="type in allTypes" value="type.id">{{ type.name }}
</option>
</select>
</div>
@ -43,7 +43,7 @@
<div class="form-group">
<label for="status">Статус:</label>
<select class="form-control" id="status">
<option v-for="status in allStatuses" value="status">{{status}}
<option v-for="status in allStatuses" value="status.id">{{status.name}}
</option>
</select>
</div>

Loading…
Cancel
Save