1.po开发
在项目目录“/src/main/java/com/example/es”下新建po目录,并在po目录下新建Employee实体类,具体代码如下。
@Data public class Employee implements IdProvider { @JsonProperty("id") private String id; @JsonProperty("name") private String name; @JsonProperty("age") private Integer age; @JsonProperty("birthday") private String birthday; @JsonProperty("job") private String job; @JsonProperty("salary") private Float salary; @Override public String getId() { return id; } }
2.mapper开发
在项目目录“/src/main/java/com/example/es”下新建mapper目录,并在mapper目录下新建EmployeeMapper接口,具体代码如下。
@EasyMapper(indices = "employee", clusterRouter = "sampleCluster") public interface EmployeeMapper { @Delete Boolean deleteEmployeeBoolean(String id); @Delete void deleteEmployeeVoid(String id); @Delete RestStatus deleteEmployee(Employee employee); @Delete DeleteResponse deleteEmployeeDeleteResponse(String id); @Delete RestStatus deleteEmployee(String id); @Delete CompletableFuturedeleteEmployeeBooleanFuture(String id); @Delete CompletableFuture deleteEmployeeVoidFuture(String id); }
3.controller开发
在项目目录“/src/main/java/com/example/es”下新建controller目录,并在controller目录下新建EmployeeController类,以deleteEmployee接口为例演示开发步骤,具体代码如下。
@RestController @RequestMapping("/employee") public class EmployeeController { @Resource private EmployeeMapper employeeMapper; @ResponseBody @RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE) public RestStatus deleteEmployee(@RequestBody Employee employee) { return employeeMapper.deleteEmployee(employee); } }
4.测试
启动项目,然后在postman中请求“http://localhost:8080/employee/deleteEmployee”,返回请求执行结果。
{ "id":"10001" }
"OK"
5.@Delete属性说明
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)