Merge pull request 'adding update fileds for olt on usecase' (#37) from feature/responses-v2 into dev

Reviewed-on: winter-access/backend_nam#37
This commit is contained in:
areeqakbr 2025-07-02 02:48:44 +00:00
commit b8e66957c7
1 changed files with 15 additions and 0 deletions

View File

@ -555,6 +555,21 @@ func (u *deviceDetailsUseCase) UpdateDeviceDetails(id uuid.UUID, deviceDTO req.U
updates["tower_id"] = *deviceDTO.TowerID updates["tower_id"] = *deviceDTO.TowerID
} }
if deviceDTO.OLTID != nil {
// Validate OLT exists
oltExists, err := u.ValidateOLTExists(*deviceDTO.OLTID)
if err != nil {
return fmt.Errorf("failed to validate OLT: %w", err)
}
if !oltExists {
return fmt.Errorf("OLT with ID %s not found", deviceDTO.OLTID.String())
}
updates["olt_id"] = *deviceDTO.OLTID
}
log.Printf("Updating device %s with fields: %+v", id, updates)
if len(updates) == 0 { if len(updates) == 0 {
return errors.New("no fields to update") return errors.New("no fields to update")
} }