Refactor backend services and controllers to use DTOs for Tenant, Lease, and Apartment
- Updated TenantController to utilize TenantService and DTOs for tenant operations. - Refactored UserController to return UserResponse DTO. - Introduced LeaseService and ApartmentService to handle business logic and data mapping. - Created DTOs for Apartment, Lease, Tenant, and User to standardize data transfer. - Implemented mappers for converting between entities and DTOs using MapStruct. - Removed landlordId from Apartment and Lease entities and adjusted related tests. - Added validation and normalization logic for tenant and guarantor data. - Enhanced unit tests to ensure proper mapping and data integrity during updates.
This commit is contained in:
1 parent
181410e28f
commit
c8020c489e
34 files changed
+757
-321
No files matched your search
@@ -1,6 +1,12 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable, inject, signal } from '@angular/core';
|
||||
|
||||
interface UserResponse {
|
||||
authenticated: boolean;
|
||||
username?: string;
|
||||
email?: string;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SessionService {
|
||||
private readonly http = inject(HttpClient);
|
||||
@@ -9,7 +15,7 @@ export class SessionService {
|
||||
readonly email = signal('');
|
||||
|
||||
refresh(): void {
|
||||
this.http.get<{ authenticated: boolean; username?: string; email?: string }>('/api/user').subscribe({
|
||||
this.http.get<UserResponse>('/api/user').subscribe({
|
||||
next: (user) => {
|
||||
this.isLoggedIn.set(user.authenticated);
|
||||
this.username.set(user.authenticated ? (user.username || 'User') : '');
|
||||
|
||||
Reference in new issue
Block a user