load tester beta
This commit is contained in:
@@ -5,13 +5,15 @@ import com.eactive.testmaster.common.exception.NotFoundException;
|
||||
import com.eactive.testmaster.server.dto.ServerDTO;
|
||||
import com.eactive.testmaster.server.entity.Server;
|
||||
import com.eactive.testmaster.server.entity.ServerRepository;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Mapper(componentModel = "spring",
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
@Component
|
||||
public class ServerMapper {
|
||||
|
||||
@@ -19,17 +21,23 @@ public class ServerMapper {
|
||||
ServerRepository serverRepository;
|
||||
|
||||
public Server mapById(Long id) {
|
||||
if (id == null || id == 0) return null;
|
||||
if (id == null || id == 0) {
|
||||
return null;
|
||||
}
|
||||
return serverRepository.findById(id).orElseThrow(() -> new NotFoundException("Server[" + id + "] not found"));
|
||||
}
|
||||
|
||||
public Long mapById(Server server) {
|
||||
if (server == null) return null;
|
||||
if (server == null) {
|
||||
return null;
|
||||
}
|
||||
return server.getId();
|
||||
}
|
||||
|
||||
public ServerDTO map(Server server) {
|
||||
if (server == null) return null;
|
||||
if (server == null) {
|
||||
return null;
|
||||
}
|
||||
ServerDTO dto = new ServerDTO();
|
||||
|
||||
dto.setId(server.getId());
|
||||
@@ -45,7 +53,9 @@ public class ServerMapper {
|
||||
|
||||
|
||||
public Server map(ServerDTO dto) {
|
||||
if (dto == null) return null;
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Server server = new Server();
|
||||
|
||||
@@ -59,4 +69,8 @@ public class ServerMapper {
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public List<ServerDTO> map(List<Server> servers) {
|
||||
return servers.stream().map(this::map).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user