Files
jurong_circle_chat_black/src/const/result.ts
2025-09-28 09:30:27 +08:00

21 lines
540 B
TypeScript

import { HttpStatus } from '@nestjs/common';
export class ResultData {
constructor(
public code = HttpStatus.OK,
public msg?: string,
public data?: any,
) {
this.code = code;
this.msg = msg || '操作成功';
this.data = data || null;
}
static success(data?: any, msg?: string) {
return new ResultData(HttpStatus.OK, msg, data);
}
static fail(code = HttpStatus.BAD_REQUEST, msg?: string, data?: any) {
return new ResultData(code, msg, data);
}
}