Exemplo n.º 1
0
  @Override
  public CableInfo getCableInfoById(Integer id) {
    CableInfo temp = cableInfoDao.selectCableInfoById(id);
    if (temp != null) {
      BoxInfo backBoxInfo = temp.getBackBoxInfo();
      if (backBoxInfo != null && backBoxInfo.getLocalePhoto() != null) {
        String name = "box_" + backBoxInfo.getLocalePhoto().getLocalePhotoId() + ".jpg";
        byte[] data = backBoxInfo.getLocalePhoto().getLocalePhoto();
        saveImageToFile(name, data);
        backBoxInfo.getLocalePhoto().setLocalePhoto(null);
        backBoxInfo.getLocalePhoto().setLocalePhotoUrl("/images/" + name);
      }
      BoxInfo froBoxInfo = temp.getFroBoxInfo();
      if (froBoxInfo != null && froBoxInfo.getLocalePhoto() != null) {
        String name = "box_" + froBoxInfo.getLocalePhoto().getLocalePhotoId() + ".jpg";
        byte[] data = froBoxInfo.getLocalePhoto().getLocalePhoto();
        saveImageToFile(name, data);
        froBoxInfo.getLocalePhoto().setLocalePhoto(null);
        froBoxInfo.getLocalePhoto().setLocalePhotoUrl("/images/" + name);
      }
    }

    return temp;
  }