fix(c2): 个人项目库允许保存空库(清空)
- R12: PutElderSvcDto.svcIds 移除 @ArrayNotEmpty,空数组=清空 - 补测 put 空 svcIds 清空项目库 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
00c8fa4d4c
commit
8791ca494b
@ -1,5 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ArrayNotEmpty, IsArray, IsIn, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsArray, IsIn, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
/** 老人个人项目库整表覆盖入参:care_mode 为整库统一护理方式,svc_ids 落本机构 L4。 */
|
||||
export class PutElderSvcDto {
|
||||
@ -12,9 +12,8 @@ export class PutElderSvcDto {
|
||||
@IsIn(['inst_medical', 'inst_nursing', 'home_org', 'home_individual'])
|
||||
careMode!: string;
|
||||
|
||||
@ApiProperty({ description: '本机构 L4 项目库 svc_org.id 列表', type: [String] })
|
||||
@ApiProperty({ description: '本机构 L4 项目库 svc_org.id 列表(可空,空数组=清空项目库)', type: [String] })
|
||||
@IsArray()
|
||||
@ArrayNotEmpty()
|
||||
@IsString({ each: true })
|
||||
svcIds!: string[];
|
||||
}
|
||||
|
||||
@ -101,6 +101,23 @@ describe('ElderSvcService', () => {
|
||||
expect(res).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('put 空 svcIds 清空项目库:软删旧行、不写新行、返回空', async () => {
|
||||
const elderSvcUpdateMany = vi.fn().mockResolvedValue({ count: 2 });
|
||||
const elderSvcCreate = vi.fn();
|
||||
const { service } = makeService({ elderSvcUpdateMany, elderSvcCreate });
|
||||
|
||||
const res = await runWithRequestContext(ctx, () =>
|
||||
service.put('e1', { careMode: 'inst_medical', svcIds: [] }),
|
||||
);
|
||||
|
||||
expect(elderSvcUpdateMany).toHaveBeenCalledWith({
|
||||
where: { elderId: 'e1' },
|
||||
data: { deletedAt: expect.any(Date) },
|
||||
});
|
||||
expect(elderSvcCreate).not.toHaveBeenCalled();
|
||||
expect(res).toEqual([]);
|
||||
});
|
||||
|
||||
it('put 老人不存在 → ELDER_NOT_FOUND', async () => {
|
||||
const elderFindFirst = vi.fn().mockResolvedValue(null);
|
||||
const { service, elderSvcUpdateMany, elderSvcCreate } = makeService({ elderFindFirst });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user