tyt-api-nest/src/users/dto/register-user.dto.ts
EL 7c4ba1e1a0 feat(auth): 支持同一微信 openId 绑定多个院内账号
feat(patients): 增强 B 端患者列表返回原发病/压力/手术日期字段
2026-03-24 16:51:37 +08:00

77 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Role } from '../../generated/prisma/enums.js';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { EmptyStringToUndefined } from '../../common/transforms/empty-string-to-undefined.transform.js';
import {
IsEnum,
IsInt,
IsOptional,
IsString,
Matches,
Min,
MinLength,
} from 'class-validator';
/**
* 注册 DTO同时服务小程序与后台账号创建。
*/
export class RegisterUserDto {
@ApiProperty({ description: '用户姓名', example: '张三' })
@IsString({ message: 'name 必须是字符串' })
name!: string;
@ApiProperty({ description: '手机号(中国大陆)', example: '13800000001' })
@IsString({ message: 'phone 必须是字符串' })
@Matches(/^1\d{10}$/, { message: 'phone 必须是合法手机号' })
phone!: string;
@ApiProperty({ description: '登录密码(至少 8 位)', example: 'Abcd1234' })
@IsString({ message: 'password 必须是字符串' })
@MinLength(8, { message: 'password 长度至少 8 位' })
password!: string;
@ApiProperty({ description: '系统角色', enum: Role, example: Role.DOCTOR })
@IsEnum(Role, { message: 'role 枚举值不合法' })
role!: Role;
@ApiPropertyOptional({
description: '微信 openId可选院内账号间可复用',
example: 'wx-open-id-demo',
})
@IsOptional()
@IsString({ message: 'openId 必须是字符串' })
openId?: string;
@ApiPropertyOptional({ description: '所属医院 ID', example: 1 })
@IsOptional()
@EmptyStringToUndefined()
@Type(() => Number)
@IsInt({ message: 'hospitalId 必须是整数' })
@Min(1, { message: 'hospitalId 必须大于 0' })
hospitalId?: number;
@ApiPropertyOptional({ description: '所属科室 ID', example: 1 })
@IsOptional()
@EmptyStringToUndefined()
@Type(() => Number)
@IsInt({ message: 'departmentId 必须是整数' })
@Min(1, { message: 'departmentId 必须大于 0' })
departmentId?: number;
@ApiPropertyOptional({ description: '所属小组 ID', example: 1 })
@IsOptional()
@EmptyStringToUndefined()
@Type(() => Number)
@IsInt({ message: 'groupId 必须是整数' })
@Min(1, { message: 'groupId 必须大于 0' })
groupId?: number;
@ApiPropertyOptional({
description: '系统管理员注册引导密钥(仅注册 SYSTEM_ADMIN 需要)',
example: 'admin-bootstrap-key',
})
@IsOptional()
@IsString({ message: 'systemAdminBootstrapKey 必须是字符串' })
systemAdminBootstrapKey?: string;
}