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

Add StandUserDTO and new endpoint findAllBySellerId

parent 84f7c90e
...@@ -4,6 +4,7 @@ import cz.fi.muni.pa165.flea.market.manager.dto.enums.EnumDTO; ...@@ -4,6 +4,7 @@ import cz.fi.muni.pa165.flea.market.manager.dto.enums.EnumDTO;
import cz.fi.muni.pa165.flea.market.manager.dto.stand.StandCreateDTO; 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.entity.Stand; import cz.fi.muni.pa165.flea.market.manager.entity.Stand;
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;
...@@ -85,4 +86,17 @@ public class StandController { ...@@ -85,4 +86,17 @@ public class StandController {
.map(itemCategory -> new EnumDTO(itemCategory.name(), itemCategory.getLabel())) .map(itemCategory -> new EnumDTO(itemCategory.name(), itemCategory.getLabel()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@GetMapping(value = "/list/user/{userId}")
public List<StandUserDTO> findAllBySellerId(@PathVariable("userId") String userId) {
List<Stand> userStands = standService.findAllBySellerId(userId);
return userStands.stream()
.map(stand -> new StandUserDTO(
stand.getId(),
stand.getItemCategories().stream().map(ItemCategory::getLabel).collect(Collectors.toSet()),
stand.getStandType().getName(),
stand.getEvent().getName()
))
.collect(Collectors.toList());
}
} }
\ No newline at end of file
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;
/**
* @author Lucia Lopuchova
*/
@Getter
@Setter
@AllArgsConstructor
public class StandUserDTO {
@NotBlank
private String id;
private Set<String> itemCategories;
@NotNull
private String standTypeName;
@NotNull
private String eventName;
}
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