From 7a17583ef43656f21adc20e3c6de484475311134 Mon Sep 17 00:00:00 2001 From: isXuCcc Date: Wed, 30 Mar 2022 15:12:01 +0800 Subject: [PATCH] feat: add http oob support --- .../java/person/xu/oob/ldapoob/ApiController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/person/xu/oob/ldapoob/ApiController.java b/src/main/java/person/xu/oob/ldapoob/ApiController.java index 601f8f5..f9253ff 100644 --- a/src/main/java/person/xu/oob/ldapoob/ApiController.java +++ b/src/main/java/person/xu/oob/ldapoob/ApiController.java @@ -1,6 +1,7 @@ package person.xu.oob.ldapoob; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import java.util.Optional; @@ -23,6 +24,20 @@ public void unregister(@PathVariable(name = "id") String id) { recordRepository.deleteById(id); } + @PostMapping("/{id}/access") + @ResponseStatus(code = HttpStatus.ACCEPTED) + public void access(@PathVariable(name = "id") String id) { + Optional record = recordRepository.findById(id); + record.ifPresent(r -> { + r.setAccess(); + r.updateReceiveTime(); + recordRepository.save(r); + } + ); + + } + + @GetMapping("/{id}/access") public boolean isAccess(@PathVariable(name = "id") String id) { Optional record = recordRepository.findById(id);