Age input when editing/adding pet profile

This commit is contained in:
augmentedpotato
2026-04-14 13:56:21 -06:00
parent 113c8c61be
commit fbcab5d097
4 changed files with 45 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
package com.petshop.backend.dto.pet;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
@@ -16,6 +18,10 @@ public class MyPetRequest {
@Size(max = 50, message = "Breed must not exceed 50 characters")
private String breed;
@Min(value = 0, message = "Age must be 0 or greater")
@Max(value = 100, message = "Age must not exceed 100")
private Integer petAge;
public String getPetName() {
return petName;
}
@@ -39,4 +45,12 @@ public class MyPetRequest {
public void setBreed(String breed) {
this.breed = breed;
}
public Integer getPetAge() {
return petAge;
}
public void setPetAge(Integer petAge) {
this.petAge = petAge;
}
}

View File

@@ -6,17 +6,19 @@ public class MyPetResponse {
private String petName;
private String species;
private String breed;
private Integer petAge;
private String imageUrl;
private String petStatus;
public MyPetResponse() {
}
public MyPetResponse(Long customerPetId, String petName, String species, String breed, String imageUrl, String petStatus) {
public MyPetResponse(Long customerPetId, String petName, String species, String breed, Integer petAge, String imageUrl, String petStatus) {
this.customerPetId = customerPetId;
this.petName = petName;
this.species = species;
this.breed = breed;
this.petAge = petAge;
this.imageUrl = imageUrl;
this.petStatus = petStatus;
}
@@ -53,6 +55,14 @@ public class MyPetResponse {
this.breed = breed;
}
public Integer getPetAge() {
return petAge;
}
public void setPetAge(Integer petAge) {
this.petAge = petAge;
}
public String getImageUrl() {
return imageUrl;
}

View File

@@ -357,6 +357,7 @@ public class PetService {
pet.getPetName(),
pet.getPetSpecies(),
pet.getPetBreed(),
pet.getPetAge(),
pet.getImageUrl() != null && !pet.getImageUrl().isBlank() ? "/api/v1/pets/" + pet.getPetId() + "/image" : null,
pet.getPetStatus()
);
@@ -366,7 +367,7 @@ public class PetService {
pet.setPetName(request.getPetName().trim());
pet.setPetSpecies(request.getSpecies().trim());
pet.setPetBreed(normalizeOptional(request.getBreed()));
pet.setPetAge(null);
pet.setPetAge(request.getPetAge());
pet.setPetPrice(null);
}