refactor(user): reorganize imports and code structure
This commit is contained in:
parent
6c025cc8d2
commit
7bd06dee62
@ -1,14 +1,20 @@
|
||||
package de.szut.casino.user;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -22,6 +28,7 @@ public class UserController {
|
||||
if (id == null || !userService.exists(id)) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(userService.getUser(id));
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,18 @@
|
||||
package de.szut.casino.user;
|
||||
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
@ -39,8 +34,8 @@ public class UserService {
|
||||
|
||||
public GetUserDto getUser(String keycloakId) {
|
||||
Optional<UserEntity> user = this.userRepository.findOneByKeycloakId(keycloakId);
|
||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
||||
|
||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
||||
}
|
||||
|
||||
public GetUserDto getCurrentUser(String token) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { LandingComponent } from './feature/landing/landing.component';
|
||||
import { HomeComponent } from './feature/home/home.component';
|
||||
import { authGuard } from './auth.guard';
|
||||
|
||||
export const routes: Routes = [
|
||||
@ -11,10 +10,10 @@ export const routes: Routes = [
|
||||
{
|
||||
path: 'login/success',
|
||||
loadComponent: () => import('./feature/login-success/login-success.component'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'home',
|
||||
component: HomeComponent,
|
||||
loadComponent: () => import('./feature/home/home.component'),
|
||||
canActivate: [authGuard],
|
||||
},
|
||||
];
|
||||
|
@ -31,6 +31,7 @@ export class UserService {
|
||||
if (user) {
|
||||
return user;
|
||||
}
|
||||
|
||||
return await this.createUser(userProfile.id ?? '', userProfile.username ?? '').toPromise();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user