feat: add DCB User Service API - Authentication system with KEYCLOAK - Modular architecture with services for each feature

This commit is contained in:
diallolatoile 2025-11-10 20:41:25 +00:00
parent 403baaa0ef
commit 2b4f4ce1b8

View File

@ -192,6 +192,53 @@ export class HubUserResponse {
lastLogin?: number;
}
export class MerchantUserResponse {
@ApiProperty({ description: 'User ID' })
id: string;
@ApiProperty({ description: 'Username' })
username: string;
@ApiProperty({ description: 'Email address' })
email: string;
@ApiProperty({ description: 'First name' })
firstName: string;
@ApiProperty({ description: 'Last name' })
lastName: string;
@ApiProperty({
enum: [UserRole.DCB_ADMIN, UserRole.DCB_SUPPORT, UserRole.DCB_PARTNER, UserRole.DCB_PARTNER_ADMIN, UserRole.DCB_PARTNER_MANAGER, UserRole.DCB_PARTNER_SUPPORT],
description: 'User role'
})
role: UserRole;
@ApiProperty({ description: 'Whether the user is enabled' })
enabled: boolean;
@ApiProperty({ description: 'Whether the email is verified' })
emailVerified: boolean;
@ApiProperty({ required: false, description: 'Merchant partner ID' })
merchantPartnerId?: string;
@ApiProperty({ description: 'User creator ID' })
createdBy: string;
@ApiProperty({ description: 'User creator username' })
createdByUsername: string;
@ApiProperty({ enum: ['HUB', 'MERCHANT'], description: 'User type' })
userType: 'HUB' | 'MERCHANT';
@ApiProperty({ description: 'Creation timestamp' })
createdTimestamp: number;
@ApiProperty({ required: false, description: 'Last login timestamp' })
lastLogin?: number;
}
export class HubUserProfileResponse {
@ApiProperty({ description: 'User ID' })
id: string;
@ -252,6 +299,26 @@ function mapToHubUserResponse(user: User): HubUserResponse {
};
}
// Mapper functions
function mapToMerchantUserResponse(user: User): MerchantUserResponse {
return {
id: user.id,
username: user.username,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
role: user.role,
enabled: user.enabled,
emailVerified: user.emailVerified,
merchantPartnerId: user.merchantPartnerId,
createdBy: user.createdBy,
createdByUsername: user.createdByUsername,
userType: user.userType,
createdTimestamp: user.createdTimestamp,
lastLogin: user.lastLogin,
};
}
function mapToHubUserProfileResponse(profile: any): HubUserProfileResponse {
return {
id: profile.id,
@ -413,7 +480,7 @@ export class HubUsersController {
return {
hubUsers: hubUsers.map(mapToHubUserResponse),
merchantUsers: merchantUsers.map(mapToHubUserResponse),
merchantUsers: merchantUsers.map(mapToMerchantUserResponse),
statistics: {
totalHubUsers: hubUsers.length,
totalMerchantUsers: merchantUsers.length,