Skip to content

Commit

Permalink
这下应该真修好了吧
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-chu committed Jan 7, 2025
1 parent 7b55ccf commit b1865d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public class PingController extends SparkleController {

@PostMapping("/peers/submit")
public ResponseEntity<String> submitPeers(@RequestBody @Validated BtnPeerPing ping) throws AccessDeniedException, UnknownHostException {
var cred = cred();
userApplicationService.updateUserApplicationLastAccessTime(cred);
var cred = userApplicationService.updateUserApplicationLastAccessTime(cred());
var audit = new LinkedHashMap<String, Object>();
audit.put("appId", cred.getAppId());
if (isCredBanned(cred)) {
Expand All @@ -95,8 +94,7 @@ public ResponseEntity<String> submitPeers(@RequestBody @Validated BtnPeerPing pi

@PostMapping("/histories/submit")
public ResponseEntity<String> submitPeerHistories(@RequestBody @Validated BtnPeerHistoryPing ping) throws AccessDeniedException, UnknownHostException {
var cred = cred();
userApplicationService.updateUserApplicationLastAccessTime(cred);
var cred = userApplicationService.updateUserApplicationLastAccessTime(cred());
var audit = new LinkedHashMap<String, Object>();
audit.put("appId", cred.getAppId());
if (isCredBanned(cred)) {
Expand All @@ -117,8 +115,7 @@ public ResponseEntity<String> submitPeerHistories(@RequestBody @Validated BtnPee

@PostMapping("/bans/submit")
public ResponseEntity<String> submitBans(@RequestBody @Validated BtnBanPing ping) throws AccessDeniedException, UnknownHostException {
var cred = cred();
userApplicationService.updateUserApplicationLastAccessTime(cred);
var cred = userApplicationService.updateUserApplicationLastAccessTime(cred());
var audit = new LinkedHashMap<String, Object>();
audit.put("appId", cred.getAppId());
if (isCredBanned(cred)) {
Expand All @@ -138,8 +135,7 @@ public ResponseEntity<String> submitBans(@RequestBody @Validated BtnBanPing ping

@GetMapping("/config")
public ResponseEntity<Object> config() throws AccessDeniedException, JsonProcessingException, UnknownHostException {
var cred = cred();
userApplicationService.updateUserApplicationLastAccessTime(cred);
var cred = userApplicationService.updateUserApplicationLastAccessTime(cred());
var audit = new LinkedHashMap<String, Object>();
audit.put("appId", cred.getAppId());
if (isCredBanned(cred)) {
Expand Down Expand Up @@ -173,8 +169,7 @@ public ResponseEntity<Object> config() throws AccessDeniedException, JsonProcess

@GetMapping("/rules/retrieve")
public ResponseEntity<String> rule() throws IOException, AccessDeniedException {
var cred = cred();
userApplicationService.updateUserApplicationLastAccessTime(cred);
var cred = userApplicationService.updateUserApplicationLastAccessTime(cred());
var audit = new LinkedHashMap<String, Object>();
audit.put("appId", cred.getAppId());
if (isCredBanned(cred)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ public UserApplication editUserApplicationComment(Long id, String comment) throw
@Transactional(Transactional.TxType.NOT_SUPPORTED)
@Lock(value = LockModeType.OPTIMISTIC)
@Retryable(retryFor = ObjectOptimisticLockingFailureException.class, backoff = @Backoff(delay = 100, multiplier = 2))
public void updateUserApplicationLastAccessTime(UserApplication userApplication) {
public UserApplication updateUserApplicationLastAccessTime(UserApplication userApplication) {
userApplication.setLastAccessAt(OffsetDateTime.now());
try {
userApplicationRepository.save(userApplication);
return userApplicationRepository.save(userApplication);
} catch (Exception e) {
log.info("Failed to update last access time for user application: {}", userApplication.getId(), e);
}
return userApplication;
}

public UserApplicationDto toDto(UserApplication userApplication) {
Expand Down

0 comments on commit b1865d1

Please sign in to comment.