mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-07 11:17:27 +08:00
feat: relocate remaining dtos
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.openisle.controller;
|
||||
|
||||
import com.openisle.dto.PushPublicKeyDto;
|
||||
import com.openisle.dto.PushSubscriptionRequest;
|
||||
import com.openisle.service.PushSubscriptionService;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -16,26 +17,14 @@ public class PushSubscriptionController {
|
||||
private String publicKey;
|
||||
|
||||
@GetMapping("/public-key")
|
||||
public PublicKeyResponse getPublicKey() {
|
||||
PublicKeyResponse r = new PublicKeyResponse();
|
||||
public PushPublicKeyDto getPublicKey() {
|
||||
PushPublicKeyDto r = new PushPublicKeyDto();
|
||||
r.setKey(publicKey);
|
||||
return r;
|
||||
}
|
||||
|
||||
@PostMapping("/subscribe")
|
||||
public void subscribe(@RequestBody SubscriptionRequest req, Authentication auth) {
|
||||
public void subscribe(@RequestBody PushSubscriptionRequest req, Authentication auth) {
|
||||
pushSubscriptionService.saveSubscription(auth.getName(), req.getEndpoint(), req.getP256dh(), req.getAuth());
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class PublicKeyResponse {
|
||||
private String key;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class SubscriptionRequest {
|
||||
private String endpoint;
|
||||
private String p256dh;
|
||||
private String auth;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user