get album response

This commit is contained in:
Alex Tran 2023-08-10 21:00:36 -05:00
parent 70cf100407
commit 51ffac5d15
3 changed files with 37 additions and 1 deletions

View file

@ -4858,6 +4858,12 @@
"ownerId": {
"type": "string"
},
"rules": {
"items": {
"$ref": "#/components/schemas/RuleResponseDto"
},
"type": "array"
},
"shared": {
"type": "boolean"
},
@ -4884,7 +4890,8 @@
"shared",
"sharedUsers",
"assets",
"owner"
"owner",
"rules"
],
"type": "object"
},
@ -6210,6 +6217,25 @@
],
"type": "string"
},
"RuleResponseDto": {
"properties": {
"key": {
"$ref": "#/components/schemas/RuleKey"
},
"ownerId": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value",
"ownerId"
],
"type": "object"
},
"SearchAlbumResponseDto": {
"properties": {
"count": {

View file

@ -2,6 +2,7 @@ import { AlbumEntity } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import { AssetResponseDto, mapAsset } from '../asset';
import { mapUser, UserResponseDto } from '../user';
import { RuleResponseDto } from './dto/rule.dto';
export class AlbumResponseDto {
id!: string;
@ -18,6 +19,7 @@ export class AlbumResponseDto {
@ApiProperty({ type: 'integer' })
assetCount!: number;
lastModifiedAssetTimestamp?: Date;
rules!: RuleResponseDto[];
}
const _map = (entity: AlbumEntity, withAssets: boolean): AlbumResponseDto => {
@ -41,6 +43,7 @@ const _map = (entity: AlbumEntity, withAssets: boolean): AlbumResponseDto => {
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
assets: withAssets ? entity.assets?.map((asset) => mapAsset(asset)) || [] : [],
assetCount: entity.assets?.length || 0,
rules: entity.rules?.map((rule) => ({ key: rule.key, value: rule.value, ownerId: rule.ownerId })) || [],
};
};

View file

@ -10,3 +10,10 @@ export class CreateRuleDto {
@IsNotEmpty()
value!: string;
}
export class RuleResponseDto {
@ApiProperty({ enumName: 'RuleKey', enum: RuleKey })
key!: RuleKey;
value!: string;
ownerId!: string;
}