feat: 合同的逻辑删除
This commit is contained in:
parent
481dd8456e
commit
fab8618bb2
|
@ -28,6 +28,7 @@ export abstract class CommonEntity extends BaseEntity {
|
|||
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
|
||||
}
|
||||
|
||||
export abstract class CompleteEntity extends CommonEntity {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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<ContractEntity>(queryBuilder, {
|
||||
page,
|
||||
|
@ -87,7 +88,8 @@ export class ContractService {
|
|||
* 删除
|
||||
*/
|
||||
async delete(id: number): Promise<void> {
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue