Commit c14c3a0e authored by Lucia Lopuchova's avatar Lucia Lopuchova Committed by cizek
Browse files

Fix stand controller, service and DTOs

parent 7aeff2cf
......@@ -5,7 +5,10 @@ import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandCreateDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandUpdateDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandUserDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.standType.StandTypeDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.user.UserDTO;
import cz.fi.muni.pa165.flea.market.manager.entity.Stand;
import cz.fi.muni.pa165.flea.market.manager.entity.StandType;
import cz.fi.muni.pa165.flea.market.manager.enums.ItemCategory;
import cz.fi.muni.pa165.flea.market.manager.service.StandService;
import io.swagger.v3.oas.annotations.tags.Tag;
......@@ -93,8 +96,10 @@ public class StandController {
return userStands.stream()
.map(stand -> new StandUserDTO(
stand.getId(),
stand.getItemCategories().stream().map(ItemCategory::getLabel).collect(Collectors.toSet()),
stand.getStandType().getName(),
stand.getItemCategories().stream().map(ItemCategory::getLabel).collect(Collectors.toList()),
mapper.map(stand.getStandType(), StandTypeDTO.class),
mapper.map(stand.getSeller(), UserDTO.class),
stand.getEvent().getId(),
stand.getEvent().getName(),
stand.getEvent().getStartDate().toString()
))
......
......@@ -21,4 +21,7 @@ public class StandUpdateDTO {
private StandTypeDTO standType;
private UserDTO seller;
@NotNull
private String eventId;
}
package cz.fi.muni.pa165.flea.market.manager.dto.stand;
import cz.fi.muni.pa165.flea.market.manager.dto.standType.StandTypeDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.user.UserDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;
/**
......@@ -19,10 +22,15 @@ public class StandUserDTO {
@NotBlank
private String id;
private Set<String> itemCategories;
private List<String> itemCategories;
@NotNull
private String standTypeName;
private StandTypeDTO standType;
private UserDTO seller;
@NotNull
private String eventId;
@NotNull
private String eventName;
......
......@@ -96,6 +96,7 @@ public class StandService extends DomainServiceImpl<Stand> {
Optional.of(standUpdateDTO.getSeller())
.ifPresent(seller -> stand.setSeller(userService.findById(seller.getId())));
stand.setStandType(standTypeServiceService.findById(standUpdateDTO.getStandType().getId()));
stand.setEvent(marketEventDao.findById(standUpdateDTO.getEventId()));
return stand;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment