feat: 合同的逻辑删除

This commit is contained in:
louis 2024-03-01 15:31:33 +08:00
parent 481dd8456e
commit fab8618bb2
3 changed files with 10 additions and 2 deletions

View File

@ -28,6 +28,7 @@ export abstract class CommonEntity extends BaseEntity {
@UpdateDateColumn({ name: 'updated_at' }) @UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date; updatedAt: Date;
} }
export abstract class CompleteEntity extends CommonEntity { export abstract class CompleteEntity extends CommonEntity {

View File

@ -43,6 +43,10 @@ export class ContractEntity extends CommonEntity {
@ApiProperty({ description: '审核状态0待审核1同意2.不同意(字典)' }) @ApiProperty({ description: '审核状态0待审核1同意2.不同意(字典)' })
status: number; status: number;
@Column({ name: 'is_delete', type: 'tinyint', default: 0, comment: '是否删除' })
@ApiProperty({ description: '删除状态0未删除1已删除' })
isDelete: number;
@ManyToMany(() => Storage, storage => storage.contracts) @ManyToMany(() => Storage, storage => storage.contracts)
@JoinTable({ @JoinTable({
name: 'contract_storage', name: 'contract_storage',

View File

@ -39,7 +39,8 @@ export class ContractService {
...(title ? { title: Like(`%${title}%`) } : null), ...(title ? { title: Like(`%${title}%`) } : null),
...(isNumber(type) ? { type } : null), ...(isNumber(type) ? { type } : null),
...(isNumber(status) ? { status } : null) ...(isNumber(status) ? { status } : null)
}); })
.andWhere('contract.isDelete = 0');
return paginate<ContractEntity>(queryBuilder, { return paginate<ContractEntity>(queryBuilder, {
page, page,
@ -87,7 +88,8 @@ export class ContractService {
* *
*/ */
async delete(id: number): Promise<void> { 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({ .where({
id id
}) })
.andWhere('contract.isDelete = 0')
.getOne(); .getOne();
return info; return info;
} }