Add API infrastructure and DTOs
This commit is contained in:
164
src/main/java/org/example/petshopdesktop/api/ApiClient.java
Normal file
164
src/main/java/org/example/petshopdesktop/api/ApiClient.java
Normal file
@@ -0,0 +1,164 @@
|
||||
package org.example.petshopdesktop.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.example.petshopdesktop.auth.UserSession;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
|
||||
public class ApiClient {
|
||||
private static final ApiClient INSTANCE = new ApiClient();
|
||||
private final HttpClient httpClient;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final String baseUrl;
|
||||
|
||||
private ApiClient() {
|
||||
this.httpClient = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.registerModule(new JavaTimeModule());
|
||||
this.baseUrl = ApiConfig.getInstance().getBaseUrl();
|
||||
}
|
||||
|
||||
public static ApiClient getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public <T> T get(String path, Class<T> responseClass) throws Exception {
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(baseUrl + path))
|
||||
.GET()
|
||||
.timeout(Duration.ofSeconds(30));
|
||||
|
||||
addAuthHeader(builder);
|
||||
|
||||
HttpRequest request = builder.build();
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
return handleResponse(response, responseClass);
|
||||
}
|
||||
|
||||
public <T> T post(String path, Object requestBody, Class<T> responseClass) throws Exception {
|
||||
String jsonBody = objectMapper.writeValueAsString(requestBody);
|
||||
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(baseUrl + path))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
|
||||
.timeout(Duration.ofSeconds(30));
|
||||
|
||||
addAuthHeader(builder);
|
||||
|
||||
HttpRequest request = builder.build();
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
return handleResponse(response, responseClass);
|
||||
}
|
||||
|
||||
public <T> T put(String path, Object requestBody, Class<T> responseClass) throws Exception {
|
||||
String jsonBody = objectMapper.writeValueAsString(requestBody);
|
||||
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(baseUrl + path))
|
||||
.header("Content-Type", "application/json")
|
||||
.PUT(HttpRequest.BodyPublishers.ofString(jsonBody))
|
||||
.timeout(Duration.ofSeconds(30));
|
||||
|
||||
addAuthHeader(builder);
|
||||
|
||||
HttpRequest request = builder.build();
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
return handleResponse(response, responseClass);
|
||||
}
|
||||
|
||||
public void delete(String path) throws Exception {
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(baseUrl + path))
|
||||
.DELETE()
|
||||
.timeout(Duration.ofSeconds(30));
|
||||
|
||||
addAuthHeader(builder);
|
||||
|
||||
HttpRequest request = builder.build();
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() != 204 && response.statusCode() != 200) {
|
||||
throw new RuntimeException(parseErrorMessage(response));
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteWithBody(String path, Object requestBody) throws Exception {
|
||||
String jsonBody = objectMapper.writeValueAsString(requestBody);
|
||||
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(baseUrl + path))
|
||||
.header("Content-Type", "application/json")
|
||||
.method("DELETE", HttpRequest.BodyPublishers.ofString(jsonBody))
|
||||
.timeout(Duration.ofSeconds(30));
|
||||
|
||||
addAuthHeader(builder);
|
||||
|
||||
HttpRequest request = builder.build();
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() != 204 && response.statusCode() != 200) {
|
||||
throw new RuntimeException(parseErrorMessage(response));
|
||||
}
|
||||
}
|
||||
|
||||
private void addAuthHeader(HttpRequest.Builder builder) {
|
||||
String token = UserSession.getInstance().getJwtToken();
|
||||
if (token != null && !token.isEmpty()) {
|
||||
builder.header("Authorization", "Bearer " + token);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T handleResponse(HttpResponse<String> response, Class<T> responseClass) throws Exception {
|
||||
int statusCode = response.statusCode();
|
||||
|
||||
if (statusCode == 200 || statusCode == 201) {
|
||||
if (response.body() == null || response.body().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return objectMapper.readValue(response.body(), responseClass);
|
||||
} else if (statusCode == 204) {
|
||||
return null;
|
||||
} else if (statusCode == 401) {
|
||||
throw new RuntimeException("Authentication failed. Please log in again.");
|
||||
} else if (statusCode == 403) {
|
||||
throw new RuntimeException("Access restricted. You don't have permission to perform this action.");
|
||||
} else {
|
||||
throw new RuntimeException(parseErrorMessage(response));
|
||||
}
|
||||
}
|
||||
|
||||
private String parseErrorMessage(HttpResponse<String> response) {
|
||||
try {
|
||||
if (response.body() != null && !response.body().isEmpty()) {
|
||||
var errorNode = objectMapper.readTree(response.body());
|
||||
if (errorNode.has("message")) {
|
||||
return errorNode.get("message").asText();
|
||||
}
|
||||
if (errorNode.has("errors")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
errorNode.get("errors").fields().forEachRemaining(entry -> {
|
||||
sb.append(entry.getValue().asText()).append("\n");
|
||||
});
|
||||
return sb.toString().trim();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return "Request failed with status " + response.statusCode();
|
||||
}
|
||||
|
||||
public ObjectMapper getObjectMapper() {
|
||||
return objectMapper;
|
||||
}
|
||||
}
|
||||
34
src/main/java/org/example/petshopdesktop/api/ApiConfig.java
Normal file
34
src/main/java/org/example/petshopdesktop/api/ApiConfig.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package org.example.petshopdesktop.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ApiConfig {
|
||||
private static final ApiConfig INSTANCE = new ApiConfig();
|
||||
private final String baseUrl;
|
||||
|
||||
private ApiConfig() {
|
||||
Properties props = new Properties();
|
||||
String url = "http://localhost:8080";
|
||||
|
||||
try (InputStream input = getClass().getClassLoader().getResourceAsStream("connectionpetstore.properties")) {
|
||||
if (input != null) {
|
||||
props.load(input);
|
||||
url = props.getProperty("api.baseUrl", "http://localhost:8080");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to load api.baseUrl from properties: " + e.getMessage());
|
||||
}
|
||||
|
||||
this.baseUrl = url;
|
||||
}
|
||||
|
||||
public static ApiConfig getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.example.petshopdesktop.api.dto.adoption;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class AdoptionRequest {
|
||||
private Long petId;
|
||||
private Long customerId;
|
||||
private LocalDate adoptionDate;
|
||||
private String adoptionStatus;
|
||||
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public LocalDate getAdoptionDate() {
|
||||
return adoptionDate;
|
||||
}
|
||||
|
||||
public void setAdoptionDate(LocalDate adoptionDate) {
|
||||
this.adoptionDate = adoptionDate;
|
||||
}
|
||||
|
||||
public String getAdoptionStatus() {
|
||||
return adoptionStatus;
|
||||
}
|
||||
|
||||
public void setAdoptionStatus(String adoptionStatus) {
|
||||
this.adoptionStatus = adoptionStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.example.petshopdesktop.api.dto.adoption;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class AdoptionResponse {
|
||||
private Long id;
|
||||
private String petName;
|
||||
private String customerName;
|
||||
private LocalDate adoptionDate;
|
||||
private String adoptionStatus;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPetName() {
|
||||
return petName;
|
||||
}
|
||||
|
||||
public void setPetName(String petName) {
|
||||
this.petName = petName;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public LocalDate getAdoptionDate() {
|
||||
return adoptionDate;
|
||||
}
|
||||
|
||||
public void setAdoptionDate(LocalDate adoptionDate) {
|
||||
this.adoptionDate = adoptionDate;
|
||||
}
|
||||
|
||||
public String getAdoptionStatus() {
|
||||
return adoptionStatus;
|
||||
}
|
||||
|
||||
public void setAdoptionStatus(String adoptionStatus) {
|
||||
this.adoptionStatus = adoptionStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.example.petshopdesktop.api.dto.analytics;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class DailySales {
|
||||
private LocalDate date;
|
||||
private BigDecimal totalSales;
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalSales() {
|
||||
return totalSales;
|
||||
}
|
||||
|
||||
public void setTotalSales(BigDecimal totalSales) {
|
||||
this.totalSales = totalSales;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.example.petshopdesktop.api.dto.analytics;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public class DashboardResponse {
|
||||
private BigDecimal totalRevenue;
|
||||
private Long totalSales;
|
||||
private Long totalCustomers;
|
||||
private Long totalProducts;
|
||||
private List<DailySales> dailySales;
|
||||
private List<TopProduct> topProducts;
|
||||
|
||||
public BigDecimal getTotalRevenue() {
|
||||
return totalRevenue;
|
||||
}
|
||||
|
||||
public void setTotalRevenue(BigDecimal totalRevenue) {
|
||||
this.totalRevenue = totalRevenue;
|
||||
}
|
||||
|
||||
public Long getTotalSales() {
|
||||
return totalSales;
|
||||
}
|
||||
|
||||
public void setTotalSales(Long totalSales) {
|
||||
this.totalSales = totalSales;
|
||||
}
|
||||
|
||||
public Long getTotalCustomers() {
|
||||
return totalCustomers;
|
||||
}
|
||||
|
||||
public void setTotalCustomers(Long totalCustomers) {
|
||||
this.totalCustomers = totalCustomers;
|
||||
}
|
||||
|
||||
public Long getTotalProducts() {
|
||||
return totalProducts;
|
||||
}
|
||||
|
||||
public void setTotalProducts(Long totalProducts) {
|
||||
this.totalProducts = totalProducts;
|
||||
}
|
||||
|
||||
public List<DailySales> getDailySales() {
|
||||
return dailySales;
|
||||
}
|
||||
|
||||
public void setDailySales(List<DailySales> dailySales) {
|
||||
this.dailySales = dailySales;
|
||||
}
|
||||
|
||||
public List<TopProduct> getTopProducts() {
|
||||
return topProducts;
|
||||
}
|
||||
|
||||
public void setTopProducts(List<TopProduct> topProducts) {
|
||||
this.topProducts = topProducts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.example.petshopdesktop.api.dto.analytics;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TopProduct {
|
||||
private String productName;
|
||||
private Integer quantitySold;
|
||||
private BigDecimal totalRevenue;
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getQuantitySold() {
|
||||
return quantitySold;
|
||||
}
|
||||
|
||||
public void setQuantitySold(Integer quantitySold) {
|
||||
this.quantitySold = quantitySold;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalRevenue() {
|
||||
return totalRevenue;
|
||||
}
|
||||
|
||||
public void setTotalRevenue(BigDecimal totalRevenue) {
|
||||
this.totalRevenue = totalRevenue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.example.petshopdesktop.api.dto.appointment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
public class AppointmentRequest {
|
||||
private List<Long> petIds;
|
||||
private Long customerId;
|
||||
private Long serviceId;
|
||||
private LocalDate appointmentDate;
|
||||
private LocalTime appointmentTime;
|
||||
private String appointmentStatus;
|
||||
|
||||
public List<Long> getPetIds() {
|
||||
return petIds;
|
||||
}
|
||||
|
||||
public void setPetIds(List<Long> petIds) {
|
||||
this.petIds = petIds;
|
||||
}
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public Long getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public void setServiceId(Long serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
public LocalDate getAppointmentDate() {
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
public void setAppointmentDate(LocalDate appointmentDate) {
|
||||
this.appointmentDate = appointmentDate;
|
||||
}
|
||||
|
||||
public LocalTime getAppointmentTime() {
|
||||
return appointmentTime;
|
||||
}
|
||||
|
||||
public void setAppointmentTime(LocalTime appointmentTime) {
|
||||
this.appointmentTime = appointmentTime;
|
||||
}
|
||||
|
||||
public String getAppointmentStatus() {
|
||||
return appointmentStatus;
|
||||
}
|
||||
|
||||
public void setAppointmentStatus(String appointmentStatus) {
|
||||
this.appointmentStatus = appointmentStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.example.petshopdesktop.api.dto.appointment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class AppointmentResponse {
|
||||
private Long id;
|
||||
private String customerName;
|
||||
private String petNames;
|
||||
private String serviceName;
|
||||
private LocalDate appointmentDate;
|
||||
private LocalTime appointmentTime;
|
||||
private String appointmentStatus;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public String getPetNames() {
|
||||
return petNames;
|
||||
}
|
||||
|
||||
public void setPetNames(String petNames) {
|
||||
this.petNames = petNames;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public LocalDate getAppointmentDate() {
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
public void setAppointmentDate(LocalDate appointmentDate) {
|
||||
this.appointmentDate = appointmentDate;
|
||||
}
|
||||
|
||||
public LocalTime getAppointmentTime() {
|
||||
return appointmentTime;
|
||||
}
|
||||
|
||||
public void setAppointmentTime(LocalTime appointmentTime) {
|
||||
this.appointmentTime = appointmentTime;
|
||||
}
|
||||
|
||||
public String getAppointmentStatus() {
|
||||
return appointmentStatus;
|
||||
}
|
||||
|
||||
public void setAppointmentStatus(String appointmentStatus) {
|
||||
this.appointmentStatus = appointmentStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.example.petshopdesktop.api.dto.auth;
|
||||
|
||||
public class LoginRequest {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public LoginRequest() {
|
||||
}
|
||||
|
||||
public LoginRequest(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.example.petshopdesktop.api.dto.auth;
|
||||
|
||||
public class LoginResponse {
|
||||
private String token;
|
||||
private String username;
|
||||
private String role;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.example.petshopdesktop.api.dto.auth;
|
||||
|
||||
public class UserInfoResponse {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String role;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.example.petshopdesktop.api.dto.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BulkDeleteRequest {
|
||||
private List<Long> ids;
|
||||
|
||||
public BulkDeleteRequest() {
|
||||
}
|
||||
|
||||
public BulkDeleteRequest(List<Long> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<Long> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<Long> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.example.petshopdesktop.api.dto.common;
|
||||
|
||||
public class DropdownOption {
|
||||
private Long id;
|
||||
private String label;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.example.petshopdesktop.api.dto.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PageResponse<T> {
|
||||
private List<T> content;
|
||||
private int pageNumber;
|
||||
private int pageSize;
|
||||
private long totalElements;
|
||||
private int totalPages;
|
||||
private boolean last;
|
||||
|
||||
public List<T> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(List<T> content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public void setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public long getTotalElements() {
|
||||
return totalElements;
|
||||
}
|
||||
|
||||
public void setTotalElements(long totalElements) {
|
||||
this.totalElements = totalElements;
|
||||
}
|
||||
|
||||
public int getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
public void setTotalPages(int totalPages) {
|
||||
this.totalPages = totalPages;
|
||||
}
|
||||
|
||||
public boolean isLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public void setLast(boolean last) {
|
||||
this.last = last;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.example.petshopdesktop.api.dto.inventory;
|
||||
|
||||
public class InventoryRequest {
|
||||
private Long productId;
|
||||
private Long storeId;
|
||||
private Integer stockQuantity;
|
||||
private Integer reorderLevel;
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Long storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public Integer getStockQuantity() {
|
||||
return stockQuantity;
|
||||
}
|
||||
|
||||
public void setStockQuantity(Integer stockQuantity) {
|
||||
this.stockQuantity = stockQuantity;
|
||||
}
|
||||
|
||||
public Integer getReorderLevel() {
|
||||
return reorderLevel;
|
||||
}
|
||||
|
||||
public void setReorderLevel(Integer reorderLevel) {
|
||||
this.reorderLevel = reorderLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.example.petshopdesktop.api.dto.inventory;
|
||||
|
||||
public class InventoryResponse {
|
||||
private Long id;
|
||||
private String productName;
|
||||
private String categoryName;
|
||||
private String storeName;
|
||||
private Integer stockQuantity;
|
||||
private Integer reorderLevel;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public Integer getStockQuantity() {
|
||||
return stockQuantity;
|
||||
}
|
||||
|
||||
public void setStockQuantity(Integer stockQuantity) {
|
||||
this.stockQuantity = stockQuantity;
|
||||
}
|
||||
|
||||
public Integer getReorderLevel() {
|
||||
return reorderLevel;
|
||||
}
|
||||
|
||||
public void setReorderLevel(Integer reorderLevel) {
|
||||
this.reorderLevel = reorderLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.example.petshopdesktop.api.dto.pet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PetRequest {
|
||||
private String petName;
|
||||
private String species;
|
||||
private String breed;
|
||||
private LocalDate dateOfBirth;
|
||||
private String gender;
|
||||
private String color;
|
||||
private BigDecimal price;
|
||||
private String petStatus;
|
||||
|
||||
public String getPetName() {
|
||||
return petName;
|
||||
}
|
||||
|
||||
public void setPetName(String petName) {
|
||||
this.petName = petName;
|
||||
}
|
||||
|
||||
public String getSpecies() {
|
||||
return species;
|
||||
}
|
||||
|
||||
public void setSpecies(String species) {
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
public String getBreed() {
|
||||
return breed;
|
||||
}
|
||||
|
||||
public void setBreed(String breed) {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
public LocalDate getDateOfBirth() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void setDateOfBirth(LocalDate dateOfBirth) {
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getPetStatus() {
|
||||
return petStatus;
|
||||
}
|
||||
|
||||
public void setPetStatus(String petStatus) {
|
||||
this.petStatus = petStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.example.petshopdesktop.api.dto.pet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PetResponse {
|
||||
private Long id;
|
||||
private String petName;
|
||||
private String species;
|
||||
private String breed;
|
||||
private LocalDate dateOfBirth;
|
||||
private String gender;
|
||||
private String color;
|
||||
private BigDecimal price;
|
||||
private String petStatus;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPetName() {
|
||||
return petName;
|
||||
}
|
||||
|
||||
public void setPetName(String petName) {
|
||||
this.petName = petName;
|
||||
}
|
||||
|
||||
public String getSpecies() {
|
||||
return species;
|
||||
}
|
||||
|
||||
public void setSpecies(String species) {
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
public String getBreed() {
|
||||
return breed;
|
||||
}
|
||||
|
||||
public void setBreed(String breed) {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
public LocalDate getDateOfBirth() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void setDateOfBirth(LocalDate dateOfBirth) {
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getPetStatus() {
|
||||
return petStatus;
|
||||
}
|
||||
|
||||
public void setPetStatus(String petStatus) {
|
||||
this.petStatus = petStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.example.petshopdesktop.api.dto.product;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ProductRequest {
|
||||
private String productName;
|
||||
private Long categoryId;
|
||||
private BigDecimal price;
|
||||
private String description;
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(Long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.example.petshopdesktop.api.dto.product;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ProductResponse {
|
||||
private Long id;
|
||||
private String productName;
|
||||
private String categoryName;
|
||||
private BigDecimal price;
|
||||
private String description;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.example.petshopdesktop.api.dto.productsupplier;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ProductSupplierRequest {
|
||||
private Long productId;
|
||||
private Long supplierId;
|
||||
private BigDecimal supplierPrice;
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getSupplierId() {
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setSupplierId(Long supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public BigDecimal getSupplierPrice() {
|
||||
return supplierPrice;
|
||||
}
|
||||
|
||||
public void setSupplierPrice(BigDecimal supplierPrice) {
|
||||
this.supplierPrice = supplierPrice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.example.petshopdesktop.api.dto.productsupplier;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ProductSupplierResponse {
|
||||
private Long id;
|
||||
private String productName;
|
||||
private String supplierName;
|
||||
private BigDecimal supplierPrice;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public BigDecimal getSupplierPrice() {
|
||||
return supplierPrice;
|
||||
}
|
||||
|
||||
public void setSupplierPrice(BigDecimal supplierPrice) {
|
||||
this.supplierPrice = supplierPrice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.example.petshopdesktop.api.dto.purchaseorder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PurchaseOrderResponse {
|
||||
private Long id;
|
||||
private String supplierName;
|
||||
private LocalDate orderDate;
|
||||
private LocalDate expectedDeliveryDate;
|
||||
private String orderStatus;
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public LocalDate getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public void setOrderDate(LocalDate orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public LocalDate getExpectedDeliveryDate() {
|
||||
return expectedDeliveryDate;
|
||||
}
|
||||
|
||||
public void setExpectedDeliveryDate(LocalDate expectedDeliveryDate) {
|
||||
this.expectedDeliveryDate = expectedDeliveryDate;
|
||||
}
|
||||
|
||||
public String getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.example.petshopdesktop.api.dto.sale;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class SaleItemRequest {
|
||||
private Long productId;
|
||||
private Integer quantity;
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public BigDecimal getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(BigDecimal unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.example.petshopdesktop.api.dto.sale;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class SaleItemResponse {
|
||||
private Long id;
|
||||
private String productName;
|
||||
private Integer quantity;
|
||||
private BigDecimal unitPrice;
|
||||
private BigDecimal lineTotal;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public BigDecimal getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(BigDecimal unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getLineTotal() {
|
||||
return lineTotal;
|
||||
}
|
||||
|
||||
public void setLineTotal(BigDecimal lineTotal) {
|
||||
this.lineTotal = lineTotal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.example.petshopdesktop.api.dto.sale;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SaleRequest {
|
||||
private Long storeId;
|
||||
private String paymentMethod;
|
||||
private List<SaleItemRequest> items;
|
||||
private Boolean isRefund;
|
||||
private Long originalSaleId;
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Long storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getPaymentMethod() {
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public void setPaymentMethod(String paymentMethod) {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public List<SaleItemRequest> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<SaleItemRequest> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public Boolean getIsRefund() {
|
||||
return isRefund;
|
||||
}
|
||||
|
||||
public void setIsRefund(Boolean isRefund) {
|
||||
this.isRefund = isRefund;
|
||||
}
|
||||
|
||||
public Long getOriginalSaleId() {
|
||||
return originalSaleId;
|
||||
}
|
||||
|
||||
public void setOriginalSaleId(Long originalSaleId) {
|
||||
this.originalSaleId = originalSaleId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.example.petshopdesktop.api.dto.sale;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class SaleResponse {
|
||||
private Long id;
|
||||
private String employeeName;
|
||||
private String storeName;
|
||||
private LocalDateTime saleDate;
|
||||
private BigDecimal totalAmount;
|
||||
private String paymentMethod;
|
||||
private Boolean isRefund;
|
||||
private Long originalSaleId;
|
||||
private List<SaleItemResponse> items;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmployeeName() {
|
||||
return employeeName;
|
||||
}
|
||||
|
||||
public void setEmployeeName(String employeeName) {
|
||||
this.employeeName = employeeName;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public LocalDateTime getSaleDate() {
|
||||
return saleDate;
|
||||
}
|
||||
|
||||
public void setSaleDate(LocalDateTime saleDate) {
|
||||
this.saleDate = saleDate;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public String getPaymentMethod() {
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public void setPaymentMethod(String paymentMethod) {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public Boolean getIsRefund() {
|
||||
return isRefund;
|
||||
}
|
||||
|
||||
public void setIsRefund(Boolean isRefund) {
|
||||
this.isRefund = isRefund;
|
||||
}
|
||||
|
||||
public Long getOriginalSaleId() {
|
||||
return originalSaleId;
|
||||
}
|
||||
|
||||
public void setOriginalSaleId(Long originalSaleId) {
|
||||
this.originalSaleId = originalSaleId;
|
||||
}
|
||||
|
||||
public List<SaleItemResponse> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<SaleItemResponse> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.example.petshopdesktop.api.dto.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ServiceRequest {
|
||||
private String serviceName;
|
||||
private BigDecimal price;
|
||||
private String description;
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.example.petshopdesktop.api.dto.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ServiceResponse {
|
||||
private Long id;
|
||||
private String serviceName;
|
||||
private BigDecimal price;
|
||||
private String description;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.example.petshopdesktop.api.dto.supplier;
|
||||
|
||||
public class SupplierRequest {
|
||||
private String supplierName;
|
||||
private String contactPerson;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String address;
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public String getContactPerson() {
|
||||
return contactPerson;
|
||||
}
|
||||
|
||||
public void setContactPerson(String contactPerson) {
|
||||
this.contactPerson = contactPerson;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.example.petshopdesktop.api.dto.supplier;
|
||||
|
||||
public class SupplierResponse {
|
||||
private Long id;
|
||||
private String supplierName;
|
||||
private String contactPerson;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String address;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public String getContactPerson() {
|
||||
return contactPerson;
|
||||
}
|
||||
|
||||
public void setContactPerson(String contactPerson) {
|
||||
this.contactPerson = contactPerson;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.example.petshopdesktop.api.dto.user;
|
||||
|
||||
public class UserRequest {
|
||||
private String username;
|
||||
private String password;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String role;
|
||||
private Boolean active;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.example.petshopdesktop.api.dto.user;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class UserResponse {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String fullName;
|
||||
private String role;
|
||||
private Boolean active;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.adoption.AdoptionRequest;
|
||||
import org.example.petshopdesktop.api.dto.adoption.AdoptionResponse;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AdoptionApi {
|
||||
private static final AdoptionApi INSTANCE = new AdoptionApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private AdoptionApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static AdoptionApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<AdoptionResponse> listAdoptions(String query) throws Exception {
|
||||
String path = "/api/v1/adoptions?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<AdoptionResponse>>() {});
|
||||
}
|
||||
|
||||
public AdoptionResponse createAdoption(AdoptionRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/adoptions", request, AdoptionResponse.class);
|
||||
}
|
||||
|
||||
public AdoptionResponse updateAdoption(Long id, AdoptionRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/adoptions/" + id, request, AdoptionResponse.class);
|
||||
}
|
||||
|
||||
public void deleteAdoptions(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/adoptions", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.analytics.DashboardResponse;
|
||||
|
||||
public class AnalyticsApi {
|
||||
private static final AnalyticsApi INSTANCE = new AnalyticsApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private AnalyticsApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static AnalyticsApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public DashboardResponse getDashboard(int days, int top) throws Exception {
|
||||
String path = "/api/v1/analytics/dashboard?days=" + days + "&top=" + top;
|
||||
return apiClient.get(path, DashboardResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.appointment.AppointmentRequest;
|
||||
import org.example.petshopdesktop.api.dto.appointment.AppointmentResponse;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppointmentApi {
|
||||
private static final AppointmentApi INSTANCE = new AppointmentApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private AppointmentApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static AppointmentApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<AppointmentResponse> listAppointments(String query) throws Exception {
|
||||
String path = "/api/v1/appointments?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<AppointmentResponse>>() {});
|
||||
}
|
||||
|
||||
public AppointmentResponse createAppointment(AppointmentRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/appointments", request, AppointmentResponse.class);
|
||||
}
|
||||
|
||||
public AppointmentResponse updateAppointment(Long id, AppointmentRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/appointments/" + id, request, AppointmentResponse.class);
|
||||
}
|
||||
|
||||
public void deleteAppointments(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/appointments", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.DropdownOption;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DropdownApi {
|
||||
private static final DropdownApi INSTANCE = new DropdownApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private DropdownApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static DropdownApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<DropdownOption> getCategories() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/categories", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getProducts() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/products", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getSuppliers() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/suppliers", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getServices() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/services", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getCustomers() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/customers", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getPets() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/pets", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
|
||||
public List<DropdownOption> getStores() throws Exception {
|
||||
String response = apiClient.get("/api/v1/dropdowns/stores", String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<DropdownOption>>() {});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.inventory.InventoryRequest;
|
||||
import org.example.petshopdesktop.api.dto.inventory.InventoryResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryApi {
|
||||
private static final InventoryApi INSTANCE = new InventoryApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private InventoryApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static InventoryApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<InventoryResponse> listInventory(String query) throws Exception {
|
||||
String path = "/api/v1/inventory?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<InventoryResponse>>() {});
|
||||
}
|
||||
|
||||
public InventoryResponse createInventory(InventoryRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/inventory", request, InventoryResponse.class);
|
||||
}
|
||||
|
||||
public InventoryResponse updateInventory(Long id, InventoryRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/inventory/" + id, request, InventoryResponse.class);
|
||||
}
|
||||
|
||||
public void deleteInventory(Long id) throws Exception {
|
||||
apiClient.delete("/api/v1/inventory/" + id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
import org.example.petshopdesktop.api.dto.pet.PetRequest;
|
||||
import org.example.petshopdesktop.api.dto.pet.PetResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PetApi {
|
||||
private static final PetApi INSTANCE = new PetApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private PetApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static PetApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<PetResponse> listPets(String query) throws Exception {
|
||||
String path = "/api/v1/pets?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<PetResponse>>() {});
|
||||
}
|
||||
|
||||
public PetResponse createPet(PetRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/pets", request, PetResponse.class);
|
||||
}
|
||||
|
||||
public PetResponse updatePet(Long id, PetRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/pets/" + id, request, PetResponse.class);
|
||||
}
|
||||
|
||||
public void deletePets(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/pets", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
import org.example.petshopdesktop.api.dto.product.ProductRequest;
|
||||
import org.example.petshopdesktop.api.dto.product.ProductResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProductApi {
|
||||
private static final ProductApi INSTANCE = new ProductApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private ProductApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static ProductApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<ProductResponse> listProducts(String query) throws Exception {
|
||||
String path = "/api/v1/products?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<ProductResponse>>() {});
|
||||
}
|
||||
|
||||
public ProductResponse createProduct(ProductRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/products", request, ProductResponse.class);
|
||||
}
|
||||
|
||||
public ProductResponse updateProduct(Long id, ProductRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/products/" + id, request, ProductResponse.class);
|
||||
}
|
||||
|
||||
public void deleteProducts(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/products", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
import org.example.petshopdesktop.api.dto.productsupplier.ProductSupplierRequest;
|
||||
import org.example.petshopdesktop.api.dto.productsupplier.ProductSupplierResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProductSupplierApi {
|
||||
private static final ProductSupplierApi INSTANCE = new ProductSupplierApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private ProductSupplierApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static ProductSupplierApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<ProductSupplierResponse> listProductSuppliers(String query) throws Exception {
|
||||
String path = "/api/v1/product-suppliers?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<ProductSupplierResponse>>() {});
|
||||
}
|
||||
|
||||
public ProductSupplierResponse createProductSupplier(ProductSupplierRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/product-suppliers", request, ProductSupplierResponse.class);
|
||||
}
|
||||
|
||||
public ProductSupplierResponse updateProductSupplier(Long id, ProductSupplierRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/product-suppliers/" + id, request, ProductSupplierResponse.class);
|
||||
}
|
||||
|
||||
public void deleteProductSuppliers(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/product-suppliers", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.purchaseorder.PurchaseOrderResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PurchaseOrderApi {
|
||||
private static final PurchaseOrderApi INSTANCE = new PurchaseOrderApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private PurchaseOrderApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static PurchaseOrderApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<PurchaseOrderResponse> listPurchaseOrders(String query) throws Exception {
|
||||
String path = "/api/v1/purchase-orders?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<PurchaseOrderResponse>>() {});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.sale.SaleRequest;
|
||||
import org.example.petshopdesktop.api.dto.sale.SaleResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SaleApi {
|
||||
private static final SaleApi INSTANCE = new SaleApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private SaleApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static SaleApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<SaleResponse> listSales(int page, int size, String query) throws Exception {
|
||||
String path = "/api/v1/sales?page=" + page + "&size=" + size;
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<SaleResponse>>() {});
|
||||
}
|
||||
|
||||
public SaleResponse getSale(Long id) throws Exception {
|
||||
return apiClient.get("/api/v1/sales/" + id, SaleResponse.class);
|
||||
}
|
||||
|
||||
public SaleResponse createSale(SaleRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/sales", request, SaleResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
import org.example.petshopdesktop.api.dto.service.ServiceRequest;
|
||||
import org.example.petshopdesktop.api.dto.service.ServiceResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceApi {
|
||||
private static final ServiceApi INSTANCE = new ServiceApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private ServiceApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static ServiceApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<ServiceResponse> listServices(String query) throws Exception {
|
||||
String path = "/api/v1/services?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<ServiceResponse>>() {});
|
||||
}
|
||||
|
||||
public ServiceResponse createService(ServiceRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/services", request, ServiceResponse.class);
|
||||
}
|
||||
|
||||
public ServiceResponse updateService(Long id, ServiceRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/services/" + id, request, ServiceResponse.class);
|
||||
}
|
||||
|
||||
public void deleteServices(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/services", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.common.BulkDeleteRequest;
|
||||
import org.example.petshopdesktop.api.dto.supplier.SupplierRequest;
|
||||
import org.example.petshopdesktop.api.dto.supplier.SupplierResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SupplierApi {
|
||||
private static final SupplierApi INSTANCE = new SupplierApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private SupplierApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static SupplierApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<SupplierResponse> listSuppliers(String query) throws Exception {
|
||||
String path = "/api/v1/suppliers?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<SupplierResponse>>() {});
|
||||
}
|
||||
|
||||
public SupplierResponse createSupplier(SupplierRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/suppliers", request, SupplierResponse.class);
|
||||
}
|
||||
|
||||
public SupplierResponse updateSupplier(Long id, SupplierRequest request) throws Exception {
|
||||
return apiClient.put("/api/v1/suppliers/" + id, request, SupplierResponse.class);
|
||||
}
|
||||
|
||||
public void deleteSuppliers(List<Long> ids) throws Exception {
|
||||
apiClient.deleteWithBody("/api/v1/suppliers", new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.example.petshopdesktop.api.endpoints;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.example.petshopdesktop.api.ApiClient;
|
||||
import org.example.petshopdesktop.api.dto.user.UserRequest;
|
||||
import org.example.petshopdesktop.api.dto.user.UserResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserApi {
|
||||
private static final UserApi INSTANCE = new UserApi();
|
||||
private final ApiClient apiClient;
|
||||
|
||||
private UserApi() {
|
||||
this.apiClient = ApiClient.getInstance();
|
||||
}
|
||||
|
||||
public static UserApi getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<UserResponse> listUsers(String query) throws Exception {
|
||||
String path = "/api/v1/users?page=0&size=1000";
|
||||
if (query != null && !query.isEmpty()) {
|
||||
path += "&q=" + query;
|
||||
}
|
||||
String response = apiClient.get(path, String.class);
|
||||
return apiClient.getObjectMapper().readValue(response, new TypeReference<List<UserResponse>>() {});
|
||||
}
|
||||
|
||||
public UserResponse createUser(UserRequest request) throws Exception {
|
||||
return apiClient.post("/api/v1/users", request, UserResponse.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user