added uniqueness constraints
This commit is contained in:
parent
eede89b7be
commit
e806c18809
4 changed files with 11 additions and 7 deletions
|
@ -30,7 +30,7 @@ public abstract class Device {
|
|||
* The room this device belongs in, as a foreign key id. To use when updating and inserting from
|
||||
* a REST call.
|
||||
*/
|
||||
@Column(name = "room_id", nullable = false)
|
||||
@Column(name = "room_id", nullable = false, unique = true)
|
||||
@NotNull
|
||||
private Long roomId;
|
||||
|
||||
|
|
|
@ -33,7 +33,11 @@ public class KnobDimmer extends Dimmer {
|
|||
dl.setIntensity((dl.getIntensity() + 5) % 105);
|
||||
} else {
|
||||
dl.setIntensity(dl.getIntensity() + (5 - remainder));
|
||||
dl.setIntensity((dl.getIntensity() - 5) % 105);
|
||||
if (dl.getIntensity() == 0) {
|
||||
dl.setIntensity(100);
|
||||
} else {
|
||||
dl.setIntensity(dl.getIntensity() - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Room {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "id", updatable = false, nullable = false)
|
||||
@Column(name = "id", updatable = false, nullable = false, unique = true)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long id;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Room {
|
|||
* inserting from a REST call.
|
||||
*/
|
||||
@NotNull
|
||||
@Column(name = "user_id", nullable = false)
|
||||
@Column(name = "user_id", nullable = false, unique = true)
|
||||
private Long userId;
|
||||
|
||||
/** The user given name of this room (e.g. 'Master bedroom') */
|
||||
|
|
|
@ -14,7 +14,7 @@ public class User {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "id", updatable = false, nullable = false)
|
||||
@Column(name = "id", updatable = false, nullable = false, unique = true)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long id;
|
||||
|
||||
|
@ -24,9 +24,9 @@ public class User {
|
|||
@NotEmpty(message = "Please provide a full name")
|
||||
private String name;
|
||||
|
||||
/** The full name of the user */
|
||||
/** The full username of the user */
|
||||
@NotNull
|
||||
@Column(nullable = false)
|
||||
@Column(nullable = false, unique = true)
|
||||
@NotEmpty(message = "Please provide a username")
|
||||
private String username;
|
||||
|
||||
|
|
Loading…
Reference in a new issue