small cahnges
This commit is contained in:
parent
c853c4cd4e
commit
d8bea0015b
10 changed files with 26 additions and 30 deletions
|
@ -18,6 +18,8 @@ public class RoomController {
|
||||||
|
|
||||||
@Autowired private UserRepository userRepository;
|
@Autowired private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired private DeviceRepository deviceRepository;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Iterable<Room> findAll() {
|
public Iterable<Room> findAll() {
|
||||||
return roomRepository.findAll();
|
return roomRepository.findAll();
|
||||||
|
@ -55,4 +57,14 @@ public class RoomController {
|
||||||
public void deleteById(@PathVariable("id") long id) {
|
public void deleteById(@PathVariable("id") long id) {
|
||||||
roomRepository.deleteById(id);
|
roomRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a List<Device> of all Devices that are present in a given room (identified by its
|
||||||
|
* id).
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/room/{roomid}/devices")
|
||||||
|
@ResponseBody
|
||||||
|
public List<Device> getDevices(@PathVariable("roomid") long roomid) {
|
||||||
|
return deviceRepository.findByRoomId(roomid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface ButtonDimmerRepository extends DeviceRepository<ButtonDimmer> {}
|
||||||
|
|
||||||
public interface ButtonDimmerRepository extends CrudRepository<ButtonDimmer, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface DimmableLightRepository extends DeviceRepository<DimmableLight> {}
|
||||||
|
|
||||||
public interface DimmableLightRepository extends CrudRepository<DimmableLight, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface KnobDimmerRepository extends DeviceRepository<KnobDimmer> {}
|
||||||
|
|
||||||
public interface KnobDimmerRepository extends CrudRepository<KnobDimmer, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface MotionSensorRepository extends DeviceRepository<MotionSensor> {}
|
||||||
|
|
||||||
public interface MotionSensorRepository extends CrudRepository<MotionSensor, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface RegularLightRepository extends DeviceRepository<RegularLight> {}
|
||||||
|
|
||||||
public interface RegularLightRepository extends CrudRepository<RegularLight, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface SensorRepository extends DeviceRepository<Sensor> {}
|
||||||
|
|
||||||
public interface SensorRepository extends CrudRepository<Sensor, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface SmartPlugRepository extends DeviceRepository<SmartPlug> {}
|
||||||
|
|
||||||
public interface SmartPlugRepository extends CrudRepository<SmartPlug, Long> {}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
public interface SwitchRepository extends DeviceRepository<Switch> {}
|
||||||
|
|
||||||
public interface SwitchRepository extends CrudRepository<Switch, Long> {}
|
|
||||||
|
|
|
@ -2,11 +2,7 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
|
|
||||||
/** A user of the Smarthut application */
|
/** A user of the Smarthut application */
|
||||||
@Entity(name = "smarthutuser")
|
@Entity(name = "smarthutuser")
|
||||||
|
@ -33,7 +29,11 @@ public class User {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@NotEmpty(message = "Please provide a password")
|
@NotEmpty(message = "Please provide a password")
|
||||||
@Min(value = 6, message = "Your password should be at least 6 characters long")
|
@Size(
|
||||||
|
min = 6,
|
||||||
|
max = 255,
|
||||||
|
message =
|
||||||
|
"Your password should be at least 6 characters long and at most 255 chars long")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue