refactor(dto): use record for Token DTO

This commit is contained in:
2026-06-20 19:01:59 +01:00
parent a6850d3d65
commit b05ae62230
4 changed files with 10 additions and 16 deletions

View File

@@ -2,7 +2,6 @@ package com.ddf.vodsystem.controllers;
import com.ddf.vodsystem.dto.ClipOptions;
import com.ddf.vodsystem.dto.APIResponse;
import com.ddf.vodsystem.services.JobOrchestrationService;
import com.ddf.vodsystem.services.JobRegistryService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

View File

@@ -1,7 +1,7 @@
package com.ddf.vodsystem.controllers;
import com.ddf.vodsystem.dto.APIResponse;
import com.ddf.vodsystem.dto.TokenDTO;
import com.ddf.vodsystem.controllers.dto.Token;
import com.ddf.vodsystem.entities.User;
import com.ddf.vodsystem.exceptions.NotAuthenticated;
import com.ddf.vodsystem.services.UserService;
@@ -39,9 +39,9 @@ public class UserController {
}
@PostMapping("/login")
public ResponseEntity<APIResponse<TokenDTO>> login(@RequestBody TokenDTO tokenDTO,
public ResponseEntity<APIResponse<Token>> login(@RequestBody Token token,
HttpServletResponse response) {
String jwt = userService.login(tokenDTO.getToken());
String jwt = userService.login(token.token());
ResponseCookie cookie = ResponseCookie.from("token", jwt)
.httpOnly(true)
@@ -54,7 +54,7 @@ public class UserController {
response.addHeader("Set-Cookie", cookie.toString());
return ResponseEntity.ok(
new APIResponse<>("success", "Logged in successfully", new TokenDTO(jwt))
new APIResponse<>("success", "Logged in successfully", new Token(jwt))
);
}

View File

@@ -0,0 +1,5 @@
package com.ddf.vodsystem.controllers.dto;
public record Token(
String token
) {}

View File

@@ -1,10 +0,0 @@
package com.ddf.vodsystem.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class TokenDTO {
private String token;
}