fix cross-client consistency
This commit is contained in:
@@ -6,9 +6,12 @@ import com.example.petstoremobile.dtos.PageResponse;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||||
|
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.HTTP;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
@@ -39,6 +42,6 @@ public interface CouponApi {
|
|||||||
@DELETE("api/v1/coupons/{id}")
|
@DELETE("api/v1/coupons/{id}")
|
||||||
Call<Void> deleteCoupon(@Path("id") Long id);
|
Call<Void> deleteCoupon(@Path("id") Long id);
|
||||||
|
|
||||||
@DELETE("api/v1/coupons")
|
@HTTP(method = "DELETE", path = "api/v1/coupons", hasBody = true)
|
||||||
Call<Void> bulkDeleteCoupons(@Query("ids") List<Long> ids);
|
Call<Void> bulkDeleteCoupons(@Body BulkDeleteRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ package com.example.petstoremobile.dtos;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BulkDeleteRequest {
|
public class BulkDeleteRequest {
|
||||||
private List<String> ids;
|
private List<Long> ids;
|
||||||
|
|
||||||
public BulkDeleteRequest() {
|
public BulkDeleteRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BulkDeleteRequest(List<String> ids) {
|
public BulkDeleteRequest(List<Long> ids) {
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getIds() {
|
public List<Long> getIds() {
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIds(List<String> ids) {
|
public void setIds(List<Long> ids) {
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.example.petstoremobile.repositories;
|
|||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.example.petstoremobile.api.CouponApi;
|
import com.example.petstoremobile.api.CouponApi;
|
||||||
|
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||||
import com.example.petstoremobile.dtos.CouponDTO;
|
import com.example.petstoremobile.dtos.CouponDTO;
|
||||||
import com.example.petstoremobile.dtos.PageResponse;
|
import com.example.petstoremobile.dtos.PageResponse;
|
||||||
import com.example.petstoremobile.utils.Resource;
|
import com.example.petstoremobile.utils.Resource;
|
||||||
@@ -47,6 +48,6 @@ public class CouponRepository extends BaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteCoupons(List<Long> ids) {
|
public LiveData<Resource<Void>> bulkDeleteCoupons(List<Long> ids) {
|
||||||
return executeCall(couponApi.bulkDeleteCoupons(ids));
|
return executeCall(couponApi.bulkDeleteCoupons(new BulkDeleteRequest(ids)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public class AdoptionListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteAdoptions(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteAdoptions(List<String> ids) {
|
||||||
return adoptionRepository.bulkDeleteAdoptions(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return adoptionRepository.bulkDeleteAdoptions(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class AppointmentListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteAppointments(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteAppointments(List<String> ids) {
|
||||||
return appointmentRepository.bulkDeleteAppointments(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return appointmentRepository.bulkDeleteAppointments(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public class InventoryListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteInventory(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteInventory(List<String> ids) {
|
||||||
return inventoryRepository.bulkDeleteInventory(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return inventoryRepository.bulkDeleteInventory(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ public class PetListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeletePets(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeletePets(List<String> ids) {
|
||||||
return petRepository.bulkDeletePets(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return petRepository.bulkDeletePets(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public class ProductSupplierListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteProductSuppliers(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteProductSuppliers(List<String> ids) {
|
||||||
return psRepository.bulkDeleteProductSuppliers(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return psRepository.bulkDeleteProductSuppliers(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class ServiceListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteServices(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteServices(List<String> ids) {
|
||||||
return repository.bulkDeleteServices(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return repository.bulkDeleteServices(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public class SupplierListViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Resource<Void>> bulkDeleteSuppliers(List<String> ids) {
|
public LiveData<Resource<Void>> bulkDeleteSuppliers(List<String> ids) {
|
||||||
return repository.bulkDeleteSuppliers(new BulkDeleteRequest(ids));
|
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
|
||||||
|
return repository.bulkDeleteSuppliers(new BulkDeleteRequest(longIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,4 +41,11 @@ public class AuthApi {
|
|||||||
body.put("usernameOrEmail", usernameOrEmail);
|
body.put("usernameOrEmail", usernameOrEmail);
|
||||||
apiClient.post("/api/v1/auth/forgot-password", body, Object.class);
|
apiClient.post("/api/v1/auth/forgot-password", body, Object.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetPassword(String token, String newPassword) throws Exception {
|
||||||
|
Map<String, String> body = new HashMap<>();
|
||||||
|
body.put("token", token);
|
||||||
|
body.put("newPassword", newPassword);
|
||||||
|
apiClient.post("/api/v1/auth/reset-password", body, Object.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user