feat: 合同的逻辑删除
This commit is contained in:
parent
481dd8456e
commit
fab8618bb2
|
@ -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 {
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue