pos-be/src/modules/user-related/user/infrastructure/dto/update-user.dto.ts

43 lines
1.2 KiB
TypeScript

import { ApiProperty } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { IsBoolean, IsObject, IsString, ValidateIf } from 'class-validator';
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
import { UserPrivilegeModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege.model';
import { UserRole } from 'src/modules/user-related/user/constants';
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
export class UpdateUserDto extends BaseStatusDto implements UserEntity {
@ApiProperty({ name: 'name', required: true, example: 'Amanda' })
@IsString()
name: string;
@ApiProperty({ name: 'username', required: true, example: 'amanda' })
@IsString()
username: string;
@ApiProperty({ name: 'role', required: true, example: UserRole.STAFF })
@IsString()
role: UserRole;
@ApiProperty({
name: 'user_privilege',
type: Object,
required: false,
example: {
id: 'uuid',
},
})
@IsObject()
@ValidateIf((body) => body.user_privilege)
user_privilege: UserPrivilegeModel;
@Exclude()
share_margin: number;
@Exclude()
email: string;
@Exclude()
password: string;
}