我正在尝试制作一个电子商务移动应用程序,其后端是使用JPA在Spring Boot中构建的。现在,我需要从应用程序向我的服务器发送删除请求。我不能为此目的使用主键。我需要通过姓名或电子邮件将其删除。
用于删除请求的普通删除URL如下所示
https:localhost:8080/api/customers/1
但就我而言,我需要根据电子邮件(而不是ID)删除客户 我的Jpa代码看起来像这样
public interface CustomerRepository extends JpaRepository<Customer, Integer> {
@Transactional
@RestResource(exported = true)
List<Customer> deleteByEmail(String email);
// the url will look something like this: http://localhost:8080/api/customers/search/findByEmail?customer_email=thekopsfc.sd@gmail.com
Customer findByEmail(@Param("customer_email") String email);
}
如何将删除请求发送到服务器?