Skip to content

Commit

Permalink
Update constraints.
Browse files Browse the repository at this point in the history
  • Loading branch information
czetsuya committed Nov 27, 2019
1 parent b9728bc commit fe1a1cb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/broodcamp/data/LoadDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class LoadDatabase {
CommandLineRunner initDatabase(final CustomerRepository customerRepository) {
return args -> {
log.debug("Preloading 6 customers");
customerRepository.save(new Customer("Kira Yamato", 16, "[email protected]"));
customerRepository.save(new Customer("Aerith Gainsborough", 16, "[email protected]"));
customerRepository.save(new Customer("Tifa Lockheart", 16, "[email protected]"));
customerRepository.save(new Customer("Garnet Til Alexandros", 16, "[email protected]"));
customerRepository.save(new Customer("Terra Branford", 16, "[email protected]"));
customerRepository.save(new Customer("Kira Yamato", 21, "[email protected]"));
customerRepository.save(new Customer("Aerith Gainsborough", 21, "[email protected]"));
customerRepository.save(new Customer("Tifa Lockheart", 21, "[email protected]"));
customerRepository.save(new Customer("Garnet Til Alexandros", 21, "[email protected]"));
customerRepository.save(new Customer("Terra Branford", 21, "[email protected]"));
};
}

Expand Down
56 changes: 33 additions & 23 deletions src/main/java/com/broodcamp/data/entity/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -19,27 +22,34 @@
@Data
public class Customer {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private String name;
private int age;
private String email;

/**
* Because id is being hidden by Spring REST Data JPA
*/
@Transient
private Long entityId;

public Customer(String name, int age, String email) {
this.name = name;
this.age = age;
this.email = email;
}

public Long getEntityId() {
return id;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotBlank
@Size(min = 5, max = 255)
private String name;

@NotBlank
@Size(min = 5, max = 255)
private String email;

@Min(value = 18)
private int age;

/**
* Because id is being hidden by Spring REST Data JPA
*/
@Transient
private Long entityId;

public Customer(String name, int age, String email) {
this.name = name;
this.age = age;
this.email = email;
}

public Long getEntityId() {
return id;
}
}
9 changes: 8 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ management:
web:
exposure:
include:
- '*'
- '*'
springdoc:
api-docs:
path: /api-docs
swagger-ui:
path: /swagger-ui


0 comments on commit fe1a1cb

Please sign in to comment.