This commit is contained in:
Tibor Tarnai 2019-12-10 16:09:46 +01:00
parent dfaa41cc33
commit 83db076e2d
4 changed files with 27 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package com.sap.tamagotchi.controller;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
import com.sap.tamagotchi.model.Device;
@ -25,4 +26,13 @@ public class DeviceController {
public Device getDevice(String deviceId) {
return tamagotchiService.getDevice(deviceId);
}
@RequestMapping("devices")
public Collection<Device> getDevices() {
return tamagotchiService.getDevices();
}
//TODO postmapping create
//request payload
// owner String
// color
}

View file

@ -0,0 +1,4 @@
package com.sap.tamagotchi.model;
public class CreateDevicePayload {
}

View file

@ -0,0 +1,4 @@
package com.sap.tamagotchi.model;
public class Owner {
}

View file

@ -1,6 +1,8 @@
package com.sap.tamagotchi.service;
import com.sap.tamagotchi.model.Device;
import com.sap.tamagotchi.publisher.PublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
@ -10,8 +12,15 @@ import java.util.Map;
@Service
public class TamagotchiService {
private final PublisherService publisherService;
private final Map<String, Device> deviceRegistry = new HashMap<>();
@Autowired
public TamagotchiService(PublisherService publisherService) {
this.publisherService = publisherService;
}
public Device getDevice(String deviceId) {
return deviceRegistry.get(deviceId);
}