// common/dto/base-result.dto.ts
export class BaseResultDto<T = any> {
    success: boolean;
    code: string;
    message: string;
    data?: T;
    timestamp: string;
  
    constructor(
      success: boolean,
      code: string,
      message: string,
      data?: T,
    ) {
      this.success = success;
      this.code = code;
      this.message = message;
      this.data = data;
      this.timestamp = new Date().toISOString();
    }
  
    static ok<T>(
      data?: T,
      message = 'SUCCESS',
      code = 'OK',
    ): BaseResultDto<T> {
      return new BaseResultDto<T>(true, code, message, data);
    }
  
    static fail(
      message: string,
      code = 'FAIL',
    ): BaseResultDto<null> {
      return new BaseResultDto<null>(false, code, message);
    }
  }
  