Refactor BFF Package Structure #64

Merged
stne3960 merged 12 commits from refactor/bff-structure into main 2026-01-12 17:38:55 +01:00
2 changed files with 32 additions and 3 deletions
Showing only changes of commit d1735c12cb - Show all commits

View File

@ -1,4 +1,4 @@
package se.su.dsv.studentportalen.bff.frontend.profile; package se.su.dsv.studentportalen.bff.controller;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
@ -6,14 +6,26 @@ import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import se.su.dsv.studentportalen.bff.dto.response.ProfileResponse;
import se.su.dsv.studentportalen.bff.service.ProfileService;
/**
* REST controller for user profile operations.
*/
@RestController @RestController
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public class ProfileController { public class ProfileController {
private final ProfileService service;
public ProfileController(ProfileService service) {
this.service = service;
}
@GetMapping("/profile") @GetMapping("/profile")
public Profile getProfile( public ProfileResponse getProfile(
@AuthenticationPrincipal(errorOnInvalidType = true) OAuth2User currentUser) @AuthenticationPrincipal(errorOnInvalidType = true) OAuth2User currentUser)
{ {
return new Profile(currentUser.getAttribute("name"), Profile.Language.ENGLISH); return service.getProfile(currentUser);
} }
} }

View File

@ -0,0 +1,17 @@
package se.su.dsv.studentportalen.bff.service;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import se.su.dsv.studentportalen.bff.dto.response.ProfileResponse;
/**
* Service for user profile operations.
*/
@Service
public class ProfileService {
public ProfileResponse getProfile(OAuth2User currentUser) {
String name = currentUser.getAttribute("name");
return new ProfileResponse(name, ProfileResponse.Language.ENGLISH);
}
}