fix: 归档删除改为软删除
This commit is contained in:
@@ -74,7 +74,7 @@ export class AttendanceDevicesController {
|
||||
userId: req.user?.id,
|
||||
username: req.user?.username,
|
||||
module: '考勤机',
|
||||
action: '删除考勤机绑定',
|
||||
action: '停用考勤机绑定',
|
||||
targetId: id,
|
||||
targetType: 'attendanceDevice',
|
||||
ipAddress,
|
||||
|
||||
@@ -74,8 +74,11 @@ export class AttendanceDevicesService {
|
||||
async remove(id: number) {
|
||||
const device = await this.repo.findOne({ where: { id } });
|
||||
if (!device) throw new NotFoundException('考勤机不存在');
|
||||
await this.repo.delete(id);
|
||||
return { message: '已删除' };
|
||||
if (device.status === AttendanceDeviceStatus.DISABLED) {
|
||||
throw new BadRequestException('考勤机已停用');
|
||||
}
|
||||
await this.repo.update(id, { status: AttendanceDeviceStatus.DISABLED });
|
||||
return { message: '已停用(绑定数据已保留)' };
|
||||
}
|
||||
|
||||
async findActiveBySn(deviceSns: string[]) {
|
||||
|
||||
Reference in New Issue
Block a user