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; ...@@ -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.StandDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandUpdateDTO; 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.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.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.enums.ItemCategory;
import cz.fi.muni.pa165.flea.market.manager.service.StandService; import cz.fi.muni.pa165.flea.market.manager.service.StandService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
...@@ -93,8 +96,10 @@ public class StandController { ...@@ -93,8 +96,10 @@ public class StandController {
return userStands.stream() return userStands.stream()
.map(stand -> new StandUserDTO( .map(stand -> new StandUserDTO(
stand.getId(), stand.getId(),
stand.getItemCategories().stream().map(ItemCategory::getLabel).collect(Collectors.toSet()), stand.getItemCategories().stream().map(ItemCategory::getLabel).collect(Collectors.toList()),
stand.getStandType().getName(), mapper.map(stand.getStandType(), StandTypeDTO.class),
mapper.map(stand.getSeller(), UserDTO.class),
stand.getEvent().getId(),
stand.getEvent().getName(), stand.getEvent().getName(),
stand.getEvent().getStartDate().toString() stand.getEvent().getStartDate().toString()
)) ))
......
...@@ -21,4 +21,7 @@ public class StandUpdateDTO { ...@@ -21,4 +21,7 @@ public class StandUpdateDTO {
private StandTypeDTO standType; private StandTypeDTO standType;
private UserDTO seller; private UserDTO seller;
@NotNull
private String eventId;
} }
package cz.fi.muni.pa165.flea.market.manager.dto.stand; 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.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -19,10 +22,15 @@ public class StandUserDTO { ...@@ -19,10 +22,15 @@ public class StandUserDTO {
@NotBlank @NotBlank
private String id; private String id;
private Set<String> itemCategories; private List<String> itemCategories;
@NotNull @NotNull
private String standTypeName; private StandTypeDTO standType;
private UserDTO seller;
@NotNull
private String eventId;
@NotNull @NotNull
private String eventName; private String eventName;
......
...@@ -96,6 +96,7 @@ public class StandService extends DomainServiceImpl<Stand> { ...@@ -96,6 +96,7 @@ public class StandService extends DomainServiceImpl<Stand> {
Optional.of(standUpdateDTO.getSeller()) Optional.of(standUpdateDTO.getSeller())
.ifPresent(seller -> stand.setSeller(userService.findById(seller.getId()))); .ifPresent(seller -> stand.setSeller(userService.findById(seller.getId())));
stand.setStandType(standTypeServiceService.findById(standUpdateDTO.getStandType().getId())); stand.setStandType(standTypeServiceService.findById(standUpdateDTO.getStandType().getId()));
stand.setEvent(marketEventDao.findById(standUpdateDTO.getEventId()));
return stand; 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