fix(admin-service): 修复移动端维护状态API响应格式不匹配问题

移动端期望的格式:
{
  "isUnderMaintenance": true,
  "maintenance": { "title", "message", "startTime", "endTime", "remainingMinutes" }
}

后端之前返回的格式:
{
  "inMaintenance": true,
  "title", "message", "endTime"
}

修改内容:
- 字段名 inMaintenance → isUnderMaintenance
- 嵌套维护详情到 maintenance 对象
- 添加 startTime 和 remainingMinutes 字段

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-28 05:10:18 -08:00
parent 912cc1eb8f
commit 75a9ffadef
2 changed files with 38 additions and 14 deletions

View File

@ -210,14 +210,24 @@ export class MobileMaintenanceController {
const active = await this.maintenanceRepo.findActiveMaintenance();
if (!active) {
return { inMaintenance: false };
return { isUnderMaintenance: false, maintenance: null };
}
// 计算剩余分钟数
const now = new Date();
const endTime = new Date(active.endTime);
const remainingMs = endTime.getTime() - now.getTime();
const remainingMinutes = Math.max(0, Math.ceil(remainingMs / 60000));
return {
inMaintenance: true,
title: active.title,
message: active.message,
endTime: active.endTime,
isUnderMaintenance: true,
maintenance: {
title: active.title,
message: active.message,
startTime: active.startTime,
endTime: active.endTime,
remainingMinutes,
},
};
}
}

View File

@ -66,19 +66,33 @@ export class MaintenanceListResponseDto {
total: number;
}
/**
*
*/
export class MaintenanceDetailDto {
@ApiProperty({ description: '维护标题' })
title: string;
@ApiProperty({ description: '维护说明' })
message: string;
@ApiProperty({ description: '开始时间' })
startTime: Date;
@ApiProperty({ description: '预计结束时间' })
endTime: Date;
@ApiProperty({ description: '预计剩余分钟数' })
remainingMinutes: number;
}
/**
*
*/
export class MaintenanceStatusResponseDto {
@ApiProperty({ description: '是否在维护中' })
inMaintenance: boolean;
isUnderMaintenance: boolean;
@ApiPropertyOptional({ description: '维护标题' })
title?: string;
@ApiPropertyOptional({ description: '维护说明' })
message?: string;
@ApiPropertyOptional({ description: '预计结束时间' })
endTime?: Date;
@ApiPropertyOptional({ description: '维护详情', type: MaintenanceDetailDto })
maintenance?: MaintenanceDetailDto | null;
}