Fix product API field names to match Postman

This commit is contained in:
2026-03-05 10:53:49 -07:00
parent d7fb057e64
commit caec657d5b
2 changed files with 28 additions and 28 deletions

View File

@@ -8,25 +8,25 @@ import java.util.Objects;
public class ProductRequest {
@NotBlank(message = "Product name is required")
private String productName;
private String prodName;
@NotNull(message = "Category ID is required")
private Long categoryId;
private String productDescription;
private String prodDesc;
@NotNull(message = "Product price is required")
@Positive(message = "Price must be positive")
private BigDecimal productPrice;
private BigDecimal prodPrice;
private Boolean active = true;
public String getProductName() {
return productName;
public String getProdName() {
return prodName;
}
public void setProductName(String productName) {
this.productName = productName;
public void setProdName(String prodName) {
this.prodName = prodName;
}
public Long getCategoryId() {
@@ -37,20 +37,20 @@ public class ProductRequest {
this.categoryId = categoryId;
}
public String getProductDescription() {
return productDescription;
public String getProdDesc() {
return prodDesc;
}
public void setProductDescription(String productDescription) {
this.productDescription = productDescription;
public void setProdDesc(String prodDesc) {
this.prodDesc = prodDesc;
}
public BigDecimal getProductPrice() {
return productPrice;
public BigDecimal getProdPrice() {
return prodPrice;
}
public void setProductPrice(BigDecimal productPrice) {
this.productPrice = productPrice;
public void setProdPrice(BigDecimal prodPrice) {
this.prodPrice = prodPrice;
}
public Boolean getActive() {
@@ -66,25 +66,25 @@ public class ProductRequest {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ProductRequest that = (ProductRequest) o;
return Objects.equals(productName, that.productName) &&
return Objects.equals(prodName, that.prodName) &&
Objects.equals(categoryId, that.categoryId) &&
Objects.equals(productDescription, that.productDescription) &&
Objects.equals(productPrice, that.productPrice) &&
Objects.equals(prodDesc, that.prodDesc) &&
Objects.equals(prodPrice, that.prodPrice) &&
Objects.equals(active, that.active);
}
@Override
public int hashCode() {
return Objects.hash(productName, categoryId, productDescription, productPrice, active);
return Objects.hash(prodName, categoryId, prodDesc, prodPrice, active);
}
@Override
public String toString() {
return "ProductRequest{" +
"productName='" + productName + '\'' +
"prodName='" + prodName + '\'' +
", categoryId=" + categoryId +
", productDescription='" + productDescription + '\'' +
", productPrice=" + productPrice +
", prodDesc='" + prodDesc + '\'' +
", prodPrice=" + prodPrice +
", active=" + active +
'}';
}

View File

@@ -46,10 +46,10 @@ public class ProductService {
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
Product product = new Product();
product.setProductName(request.getProductName());
product.setProductName(request.getProdName());
product.setCategory(category);
product.setProductDescription(request.getProductDescription());
product.setProductPrice(request.getProductPrice());
product.setProductDescription(request.getProdDesc());
product.setProductPrice(request.getProdPrice());
product.setActive(request.getActive() != null ? request.getActive() : true);
product = productRepository.save(product);
@@ -64,10 +64,10 @@ public class ProductService {
Category category = categoryRepository.findById(request.getCategoryId())
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
product.setProductName(request.getProductName());
product.setProductName(request.getProdName());
product.setCategory(category);
product.setProductDescription(request.getProductDescription());
product.setProductPrice(request.getProductPrice());
product.setProductDescription(request.getProdDesc());
product.setProductPrice(request.getProdPrice());
product.setActive(request.getActive() != null ? request.getActive() : true);
product = productRepository.save(product);