fix(admin-service): 修复上传版本时isForceUpdate默认为true的问题
- 改进Transform装饰器,正确处理FormData传递的字符串"false" - 添加调试日志用于排查问题 问题原因:FormData传递的布尔值会被转为字符串, 原来的Transform可能在某些情况下处理不正确 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a54a01bba0
commit
058849dc2c
|
|
@ -335,6 +335,9 @@ export class VersionController {
|
|||
file: Express.Multer.File,
|
||||
@Body() dto: UploadVersionDto,
|
||||
): Promise<VersionDto> {
|
||||
// Debug: log isForceUpdate value
|
||||
console.log('[VersionController] uploadVersion - dto.isForceUpdate:', dto.isForceUpdate, 'type:', typeof dto.isForceUpdate)
|
||||
|
||||
// Validate file extension
|
||||
const ext = file.originalname.toLowerCase().split('.').pop()
|
||||
if (dto.platform === Platform.ANDROID && ext !== 'apk') {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,13 @@ export class UploadVersionDto {
|
|||
|
||||
@ApiPropertyOptional({ description: '是否强制更新', default: false })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => value === 'true' || value === true)
|
||||
@Transform(({ value }) => {
|
||||
// Handle string "true"/"false" from FormData
|
||||
if (typeof value === 'string') {
|
||||
return value.toLowerCase() === 'true'
|
||||
}
|
||||
return value === true
|
||||
})
|
||||
@IsBoolean()
|
||||
isForceUpdate?: boolean
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue