fix(admin-service): 修复TypeScript编译错误
- 修复 version.controller.ts 中 FileSize 使用 .bytes 替代 .value - 修复测试文件中 AppVersion.create 缺少 isForceUpdate 参数 - 修复测试文件中使用正确的 Prisma Platform 枚举类型 - 修复 CreateVersionCommand 参数顺序错误 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
eae1350f35
commit
37c255bdc1
|
|
@ -60,16 +60,16 @@ export class VersionController {
|
|||
return {
|
||||
id: version.id,
|
||||
platform: version.platform,
|
||||
versionCode: version.versionCode,
|
||||
versionName: version.versionName,
|
||||
buildNumber: version.buildNumber,
|
||||
downloadUrl: version.downloadUrl,
|
||||
fileSize: version.fileSize.toString(),
|
||||
fileSha256: version.fileSha256,
|
||||
changelog: version.changelog,
|
||||
versionCode: version.versionCode.value,
|
||||
versionName: version.versionName.value,
|
||||
buildNumber: version.buildNumber.value,
|
||||
downloadUrl: version.downloadUrl.value,
|
||||
fileSize: version.fileSize.bytes.toString(),
|
||||
fileSha256: version.fileSha256.value,
|
||||
changelog: version.changelog.value,
|
||||
isForceUpdate: version.isForceUpdate,
|
||||
isEnabled: version.isEnabled,
|
||||
minOsVersion: version.minOsVersion,
|
||||
minOsVersion: version.minOsVersion?.value ?? null,
|
||||
releaseDate: version.releaseDate,
|
||||
createdAt: version.createdAt,
|
||||
updatedAt: version.updatedAt,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import * as request from 'supertest';
|
|||
import { PrismaService } from '../../src/infrastructure/persistence/prisma/prisma.service';
|
||||
import { AppModule } from '../../src/app.module';
|
||||
import { Platform } from '../../src/domain/enums/platform.enum';
|
||||
import { Platform as PrismaPlatform } from '@prisma/client';
|
||||
|
||||
describe('VersionController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
|
@ -189,7 +190,7 @@ describe('VersionController (e2e)', () => {
|
|||
await prisma.appVersion.create({
|
||||
data: {
|
||||
id: 'test-v1',
|
||||
platform: 'android',
|
||||
platform: PrismaPlatform.ANDROID,
|
||||
versionCode: 100,
|
||||
versionName: '1.0.0',
|
||||
buildNumber: '100',
|
||||
|
|
@ -210,7 +211,7 @@ describe('VersionController (e2e)', () => {
|
|||
await prisma.appVersion.create({
|
||||
data: {
|
||||
id: 'test-v2',
|
||||
platform: 'android',
|
||||
platform: PrismaPlatform.ANDROID,
|
||||
versionCode: 200,
|
||||
versionName: '2.0.0',
|
||||
buildNumber: '200',
|
||||
|
|
@ -305,7 +306,7 @@ describe('VersionController (e2e)', () => {
|
|||
await prisma.appVersion.create({
|
||||
data: {
|
||||
id: 'test-latest',
|
||||
platform: 'android',
|
||||
platform: PrismaPlatform.ANDROID,
|
||||
versionCode: 300,
|
||||
versionName: '3.0.0',
|
||||
buildNumber: '300',
|
||||
|
|
|
|||
|
|
@ -56,11 +56,10 @@ describe('CreateVersionHandler Integration Tests', () => {
|
|||
10485760n,
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
|
||||
'Initial release with basic features',
|
||||
'admin',
|
||||
'5.0',
|
||||
true,
|
||||
false,
|
||||
'5.0',
|
||||
null,
|
||||
'admin',
|
||||
);
|
||||
|
||||
const result = await handler.execute(command);
|
||||
|
|
@ -83,11 +82,10 @@ describe('CreateVersionHandler Integration Tests', () => {
|
|||
15728640n,
|
||||
'0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'iOS initial release',
|
||||
'admin',
|
||||
'14.0',
|
||||
true,
|
||||
false,
|
||||
'14.0',
|
||||
null,
|
||||
'admin',
|
||||
);
|
||||
|
||||
const result = await handler.execute(command);
|
||||
|
|
@ -107,11 +105,10 @@ describe('CreateVersionHandler Integration Tests', () => {
|
|||
20971520n,
|
||||
'1111111111111111111111111111111111111111111111111111111111111111',
|
||||
'Critical security update',
|
||||
'admin',
|
||||
true,
|
||||
'6.0',
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
'admin',
|
||||
);
|
||||
|
||||
const result = await handler.execute(command);
|
||||
|
|
@ -130,11 +127,10 @@ describe('CreateVersionHandler Integration Tests', () => {
|
|||
31457280n,
|
||||
'2222222222222222222222222222222222222222222222222222222222222222',
|
||||
'Scheduled major release',
|
||||
'admin',
|
||||
'7.0',
|
||||
true,
|
||||
false,
|
||||
'7.0',
|
||||
releaseDate,
|
||||
'admin',
|
||||
);
|
||||
|
||||
const result = await handler.execute(command);
|
||||
|
|
@ -152,11 +148,10 @@ describe('CreateVersionHandler Integration Tests', () => {
|
|||
41943040n,
|
||||
'3333333333333333333333333333333333333333333333333333333333333333',
|
||||
'Persistence test version',
|
||||
'admin',
|
||||
'8.0',
|
||||
true,
|
||||
false,
|
||||
'8.0',
|
||||
null,
|
||||
'admin',
|
||||
);
|
||||
|
||||
const result = await handler.execute(command);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ describe('AppVersionRepository Integration Tests', () => {
|
|||
fileSize: FileSize.create(10485760n),
|
||||
fileSha256: FileSha256.create('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'),
|
||||
changelog: Changelog.create('Test version for integration testing'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'test-user',
|
||||
});
|
||||
};
|
||||
|
|
@ -115,6 +116,7 @@ describe('AppVersionRepository Integration Tests', () => {
|
|||
fileSize: FileSize.create(20971520n),
|
||||
fileSha256: FileSha256.create('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||
changelog: Changelog.create('Version 2.0.0 with new features'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'test-user',
|
||||
});
|
||||
|
||||
|
|
@ -180,6 +182,7 @@ describe('AppVersionRepository Integration Tests', () => {
|
|||
fileSize: FileSize.create(20971520n),
|
||||
fileSha256: FileSha256.create('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||
changelog: Changelog.create('Version 2.0.0'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'test-user',
|
||||
});
|
||||
v2.disable('test-user');
|
||||
|
|
@ -204,6 +207,7 @@ describe('AppVersionRepository Integration Tests', () => {
|
|||
fileSize: FileSize.create(20971520n),
|
||||
fileSha256: FileSha256.create('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||
changelog: Changelog.create('Version 2.0.0'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'test-user',
|
||||
});
|
||||
v2.disable('test-user');
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ describe('AppVersion Entity', () => {
|
|||
fileSize: FileSize.create(10485760n), // 10 MB
|
||||
fileSha256: FileSha256.create('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'),
|
||||
changelog: Changelog.create('Initial release with basic features'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'admin',
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
|||
import { AppVersionMapper } from '../../../../src/infrastructure/persistence/mappers/app-version.mapper';
|
||||
import { AppVersion } from '../../../../src/domain/entities/app-version.entity';
|
||||
import { Platform } from '../../../../src/domain/enums/platform.enum';
|
||||
import { Platform as PrismaPlatform } from '@prisma/client';
|
||||
import { VersionCode } from '../../../../src/domain/value-objects/version-code.vo';
|
||||
import { VersionName } from '../../../../src/domain/value-objects/version-name.vo';
|
||||
import { BuildNumber } from '../../../../src/domain/value-objects/build-number.vo';
|
||||
|
|
@ -31,13 +32,14 @@ describe('AppVersionMapper', () => {
|
|||
fileSize: FileSize.create(10485760n),
|
||||
fileSha256: FileSha256.create('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'),
|
||||
changelog: Changelog.create('Initial release'),
|
||||
isForceUpdate: false,
|
||||
createdBy: 'admin',
|
||||
});
|
||||
};
|
||||
|
||||
const createPrismaVersion = () => ({
|
||||
id: 'test-id',
|
||||
platform: 'android',
|
||||
platform: PrismaPlatform.ANDROID,
|
||||
versionCode: 100,
|
||||
versionName: '1.0.0',
|
||||
buildNumber: '100',
|
||||
|
|
@ -75,7 +77,7 @@ describe('AppVersionMapper', () => {
|
|||
});
|
||||
|
||||
it('should map iOS platform correctly', () => {
|
||||
const prismaVersion = { ...createPrismaVersion(), platform: 'ios' };
|
||||
const prismaVersion = { ...createPrismaVersion(), platform: PrismaPlatform.IOS };
|
||||
const domainVersion = mapper.toDomain(prismaVersion);
|
||||
|
||||
expect(domainVersion.platform).toBe(Platform.IOS);
|
||||
|
|
@ -102,7 +104,7 @@ describe('AppVersionMapper', () => {
|
|||
const persistenceModel = mapper.toPersistence(domainVersion);
|
||||
|
||||
expect(persistenceModel.id).toBe(domainVersion.id);
|
||||
expect(persistenceModel.platform).toBe('android');
|
||||
expect(persistenceModel.platform).toBe(Platform.ANDROID);
|
||||
expect(persistenceModel.versionCode).toBe(100);
|
||||
expect(persistenceModel.versionName).toBe('1.0.0');
|
||||
expect(persistenceModel.buildNumber).toBe('100');
|
||||
|
|
|
|||
Loading…
Reference in New Issue