fix(c3): 异常列表 visitLat/visitLng Decimal 转字符串
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
169b4e2c51
commit
ab09210d28
@ -176,8 +176,11 @@ describe('AbnormalService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('list 按 abnormal_type/notify_status/handle_status/老人 筛选', async () => {
|
it('list 按 abnormal_type/notify_status/handle_status/老人 筛选', async () => {
|
||||||
const recordAbnormalFindMany = vi.fn().mockResolvedValue([{ id: 'a1' }]);
|
const recordAbnormalFindMany = vi.fn().mockResolvedValue([
|
||||||
const recordAbnormalCount = vi.fn().mockResolvedValue(1);
|
{ id: 'a1', visitLat: { toString: () => '25.010000' }, visitLng: { toString: () => '102.700000' } },
|
||||||
|
{ id: 'a2', visitLat: null, visitLng: null },
|
||||||
|
]);
|
||||||
|
const recordAbnormalCount = vi.fn().mockResolvedValue(2);
|
||||||
const { service } = makeService({ recordAbnormalFindMany, recordAbnormalCount });
|
const { service } = makeService({ recordAbnormalFindMany, recordAbnormalCount });
|
||||||
|
|
||||||
const res = await runWithRequestContext(ctx, () =>
|
const res = await runWithRequestContext(ctx, () =>
|
||||||
@ -199,6 +202,15 @@ describe('AbnormalService', () => {
|
|||||||
take: 20,
|
take: 20,
|
||||||
});
|
});
|
||||||
expect(recordAbnormalCount).toHaveBeenCalledWith({ where });
|
expect(recordAbnormalCount).toHaveBeenCalledWith({ where });
|
||||||
expect(res).toEqual({ list: [{ id: 'a1' }], total: 1, page: 1, pageSize: 20 });
|
// Decimal → string(null 保持 null)。
|
||||||
|
expect(res).toEqual({
|
||||||
|
list: [
|
||||||
|
{ id: 'a1', visitLat: '25.010000', visitLng: '102.700000' },
|
||||||
|
{ id: 'a2', visitLat: null, visitLng: null },
|
||||||
|
],
|
||||||
|
total: 2,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -87,7 +87,17 @@ export class AbnormalService {
|
|||||||
}),
|
}),
|
||||||
this.prisma.client.recordAbnormal.count({ where }),
|
this.prisma.client.recordAbnormal.count({ where }),
|
||||||
]);
|
]);
|
||||||
return { list, total, page: q.page, pageSize: q.pageSize };
|
// Prisma Decimal(visit_lat/visit_lng)经 TransformInterceptor 不会转字符串,会泄漏为 {s,e,d};显式序列化。
|
||||||
|
return {
|
||||||
|
list: list.map((r) => ({
|
||||||
|
...r,
|
||||||
|
visitLat: r.visitLat != null ? r.visitLat.toString() : null,
|
||||||
|
visitLng: r.visitLng != null ? r.visitLng.toString() : null,
|
||||||
|
})),
|
||||||
|
total,
|
||||||
|
page: q.page,
|
||||||
|
pageSize: q.pageSize,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 扑空证据必留:到访时间、定位(经纬)、原因、关联工单(3003)。 */
|
/** 扑空证据必留:到访时间、定位(经纬)、原因、关联工单(3003)。 */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user