- 新增后端重置密码接口及前端对应操作入口 - 新增补开电工 APP 账号的更新参数 - 新增 hasAccount 字段标识电工是否开通 APP 账号 - 新增数据库菜单及角色绑定支持密码重置权限 - 移除后台角色中错误的 WORKER 和 CUSTOMER 角色
86 lines
3.6 KiB
TypeScript
86 lines
3.6 KiB
TypeScript
import {
|
|
IsOptional,
|
|
IsString,
|
|
IsInt,
|
|
IsNumber,
|
|
IsBoolean,
|
|
IsArray,
|
|
IsIn,
|
|
IsNotEmpty,
|
|
ValidateNested,
|
|
Matches,
|
|
Min,
|
|
Max,
|
|
MaxLength
|
|
} from "class-validator";
|
|
import { Type } from "class-transformer";
|
|
|
|
export class WorkerQueryDTO {
|
|
@IsOptional() @IsString() @MaxLength(64) keyword?: string;
|
|
@IsOptional() @IsInt() status?: number;
|
|
// 审核状态筛选:0待审核 1已通过 2已驳回
|
|
@IsOptional() @IsInt() @IsIn([0, 1, 2]) auditStatus?: number;
|
|
// 资质状态筛选:none无证书 normal正常 expiring临期 expired已过期
|
|
@IsOptional() @IsString() @IsIn(["none", "normal", "expiring", "expired"]) certStatus?: string;
|
|
@IsOptional() @IsInt() @Min(1) page?: number = 1;
|
|
@IsOptional() @IsInt() @Min(1) @Max(200) pageSize?: number = 10;
|
|
// 兼容部分前端分页参数命名
|
|
@IsOptional() @IsInt() @Min(1) @Max(200) limit?: number;
|
|
}
|
|
|
|
export class WorkerRecommendQueryDTO {
|
|
@IsOptional() @IsInt() @Min(0) loopCount?: number;
|
|
@IsOptional() @IsInt() @Min(1) @Max(3) priority?: number;
|
|
@IsOptional() @IsString() @MaxLength(64) certKeyword?: string;
|
|
}
|
|
|
|
// 单条资质证照
|
|
export class WorkerCertDTO {
|
|
@IsNotEmpty({ message: "证书类型不能为空" }) @IsString() @MaxLength(64) certType!: string;
|
|
@IsNotEmpty({ message: "证书编号不能为空" }) @IsString() @MaxLength(64) certNo!: string;
|
|
@IsOptional() @IsString() @MaxLength(128) issueAuthority?: string;
|
|
@IsOptional() @IsString() @MaxLength(10) issueDate?: string;
|
|
// 有效期至(NULL/缺省=长期有效)
|
|
@IsOptional() @IsString() @MaxLength(10) expireDate?: string;
|
|
@IsOptional() @IsString() @MaxLength(512) certImageUrl?: string;
|
|
}
|
|
|
|
// 证书整体保存(覆盖式)
|
|
export class WorkerCertListDTO {
|
|
@IsArray() @ValidateNested({ each: true }) @Type(() => WorkerCertDTO) certs!: WorkerCertDTO[];
|
|
}
|
|
|
|
// 电工新增
|
|
export class WorkerCreateDTO {
|
|
@IsNotEmpty({ message: "电工姓名不能为空" }) @IsString() @MaxLength(64) workerName!: string;
|
|
@IsNotEmpty({ message: "手机号不能为空" }) @Matches(/^1[3-9]\d{9}$/, { message: "手机号格式不正确" }) phone!: string;
|
|
@IsOptional() @IsString() @MaxLength(18) idCard?: string;
|
|
@IsOptional() @IsString() @MaxLength(32) workerTitle?: string;
|
|
@IsOptional() @IsNumber() @Min(0) @Max(5) rating?: number;
|
|
@IsOptional() @IsString() @MaxLength(128) certInfo?: string;
|
|
// 是否同时开通电工APP账号(默认密码为手机号后 6 位)
|
|
@IsOptional() @IsBoolean() withAccount?: boolean = false;
|
|
@IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => WorkerCertDTO) certs?: WorkerCertDTO[];
|
|
}
|
|
|
|
// 电工更新(字段白名单)
|
|
export class WorkerUpdateDTO {
|
|
@IsOptional() @IsString() @MaxLength(64) workerName?: string;
|
|
@IsOptional() @Matches(/^1[3-9]\d{9}$/, { message: "手机号格式不正确" }) phone?: string;
|
|
@IsOptional() @IsString() @MaxLength(18) idCard?: string;
|
|
@IsOptional() @IsString() @MaxLength(32) workerTitle?: string;
|
|
@IsOptional() @IsInt() @IsIn([0, 1]) status?: number;
|
|
@IsOptional() @IsNumber() @Min(0) @Max(5) rating?: number;
|
|
@IsOptional() @IsString() @MaxLength(128) certInfo?: string;
|
|
// 为尚未开通 APP 账号的电工补开账号(默认密码为手机号后 6 位;已开通时忽略)
|
|
@IsOptional() @IsBoolean() withAccount?: boolean;
|
|
// 存在时整体覆盖该电工的全部证书
|
|
@IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => WorkerCertDTO) certs?: WorkerCertDTO[];
|
|
}
|
|
|
|
// 资质审核
|
|
export class WorkerAuditDTO {
|
|
@IsNotEmpty({ message: "审核结果不能为空" }) @IsBoolean() approved!: boolean;
|
|
// 驳回理由(驳回时必填)
|
|
@IsOptional() @IsString() @MaxLength(255) remark?: string;
|
|
} |