Replies: 1 comment 1 reply
-
for the automapper to automap Enums, I think you need to change the decorator like this as for the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
iam using the auto mapper like bellow , but the automap doesnt work , only ovjects in the custom mapping returned!
import type { RegionDto, UserDto } from "@/backend/auth";
import type { ServantDto, ServiceDto, TaskStatusEnum } from "@/backend/transport";
import { toUtc } from "@/composables/dateTimeFormat";
import { AutoMap, classes } from "@automapper/classes";
import { createMap, createMapper, forMember, mapFrom } from "@automapper/core";
const mapper = createMapper({ strategyInitializer: classes() });
export class TaskFilterData {
id?: number;
randomId?: number;
regionId?: number;
serviceId?: number;
servantId?: number;
clientUserId?: string;
startAt?: string;
endAt?: string;
@AutoMap()
status?: TaskStatusEnum;
@AutoMap()
page?: number;
}
export class TaskFilterDataDto {
id?: number;
randomId?: number;
region?: RegionDto;
service?: ServiceDto;
servant?: ServantDto;
user?: UserDto;
startAt!: Date;
endAt!: Date;
@AutoMap()
status?: TaskStatusEnum;
page?: number;
}
createMap(
mapper,
TaskFilterDataDto,
TaskFilterData,
forMember(d => d.regionId, mapFrom(s => s.region?.id)),
forMember(d => d.serviceId, mapFrom(s => s.service?.id)),
forMember(d => d.servantId, mapFrom(s => s.servant?.id)),
forMember(d => d.clientUserId, mapFrom(s => s.user?.uid)),
forMember(d => d.startAt, mapFrom(s => toUtc(s.startAt))),
forMember(d => d.endAt, mapFrom(s => toUtc(s.endAt))),
)
export function createMapTaskFilterDtoToTaskFilter(data: TaskFilterDataDto): TaskFilterData {
return mapper.map(data, TaskFilterDataDto, TaskFilterData);
}
usnig with vue 3
Beta Was this translation helpful? Give feedback.
All reactions