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; }