From fab8618bb2942f683a6d1bd1005fc40eb3ebee7d Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Fri, 1 Mar 2024 15:31:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=90=8C=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/entity/common.entity.ts | 1 + src/modules/contract/contract.entity.ts | 4 ++++ src/modules/contract/contract.service.ts | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/entity/common.entity.ts b/src/common/entity/common.entity.ts index f8c190e..1c9ad3f 100644 --- a/src/common/entity/common.entity.ts +++ b/src/common/entity/common.entity.ts @@ -28,6 +28,7 @@ export abstract class CommonEntity extends BaseEntity { @UpdateDateColumn({ name: 'updated_at' }) updatedAt: Date; + } export abstract class CompleteEntity extends CommonEntity { diff --git a/src/modules/contract/contract.entity.ts b/src/modules/contract/contract.entity.ts index afdb5cf..d75b05a 100644 --- a/src/modules/contract/contract.entity.ts +++ b/src/modules/contract/contract.entity.ts @@ -43,6 +43,10 @@ export class ContractEntity extends CommonEntity { @ApiProperty({ description: '审核状态:0待审核,1同意,2.不同意(字典)' }) status: number; + @Column({ name: 'is_delete', type: 'tinyint', default: 0, comment: '是否删除' }) + @ApiProperty({ description: '删除状态:0未删除,1已删除' }) + isDelete: number; + @ManyToMany(() => Storage, storage => storage.contracts) @JoinTable({ name: 'contract_storage', diff --git a/src/modules/contract/contract.service.ts b/src/modules/contract/contract.service.ts index b28eae9..59bcb22 100644 --- a/src/modules/contract/contract.service.ts +++ b/src/modules/contract/contract.service.ts @@ -39,7 +39,8 @@ export class ContractService { ...(title ? { title: Like(`%${title}%`) } : null), ...(isNumber(type) ? { type } : null), ...(isNumber(status) ? { status } : null) - }); + }) + .andWhere('contract.isDelete = 0'); return paginate(queryBuilder, { page, @@ -87,7 +88,8 @@ export class ContractService { * 删除 */ async delete(id: number): Promise { - await this.contractRepository.softDelete(id); + // 合同比较重要,做逻辑删除 + await this.contractRepository.update(id, { isDelete: 1 }); } /** @@ -99,6 +101,7 @@ export class ContractService { .where({ id }) + .andWhere('contract.isDelete = 0') .getOne(); return info; }