修复解绑卡没有iccid的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m56s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m56s
This commit is contained in:
@@ -421,6 +421,24 @@ func (s *Service) UnbindCard(ctx context.Context, deviceID uint, cardID uint) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cardAudit map[string]any
|
||||
if card, cardErr := s.iotCardStore.GetByID(ctx, binding.IotCardID); cardErr == nil {
|
||||
cardAudit = map[string]any{
|
||||
"id": card.ID,
|
||||
"iccid": card.ICCID,
|
||||
"status": card.Status,
|
||||
}
|
||||
}
|
||||
|
||||
beforeAuditData := map[string]any{
|
||||
"device": deviceSnapshot(device),
|
||||
"binding_id": binding.ID,
|
||||
"iot_card_id": binding.IotCardID,
|
||||
}
|
||||
if cardAudit != nil {
|
||||
beforeAuditData["card"] = cardAudit
|
||||
}
|
||||
|
||||
if err := s.deviceSimBindingStore.Unbind(ctx, binding.ID); err != nil {
|
||||
s.logDeviceOperation(
|
||||
ctx,
|
||||
@@ -428,11 +446,7 @@ func (s *Service) UnbindCard(ctx context.Context, deviceID uint, cardID uint) (*
|
||||
"设备解绑卡失败",
|
||||
constants.AssetAuditResultFailed,
|
||||
device,
|
||||
map[string]any{
|
||||
"device": deviceSnapshot(device),
|
||||
"binding_id": binding.ID,
|
||||
"iot_card_id": binding.IotCardID,
|
||||
},
|
||||
beforeAuditData,
|
||||
nil,
|
||||
0,
|
||||
0,
|
||||
@@ -451,21 +465,22 @@ func (s *Service) UnbindCard(ctx context.Context, deviceID uint, cardID uint) (*
|
||||
)
|
||||
}
|
||||
|
||||
afterAuditData := map[string]any{
|
||||
"iot_card_id": cardID,
|
||||
"unbind": true,
|
||||
}
|
||||
if cardAudit != nil {
|
||||
afterAuditData["card"] = cardAudit
|
||||
}
|
||||
|
||||
s.logDeviceOperation(
|
||||
ctx,
|
||||
constants.AssetAuditOpDeviceUnbindCard,
|
||||
"设备解绑卡",
|
||||
constants.AssetAuditResultSuccess,
|
||||
device,
|
||||
map[string]any{
|
||||
"device": deviceSnapshot(device),
|
||||
"binding_id": binding.ID,
|
||||
"iot_card_id": binding.IotCardID,
|
||||
},
|
||||
map[string]any{
|
||||
"iot_card_id": cardID,
|
||||
"unbind": true,
|
||||
},
|
||||
beforeAuditData,
|
||||
afterAuditData,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user