예제 #1
0
  /**
   * Function: 根据用户ID,获得圈子相册下拉菜单
   *
   * <p>Produce describe:
   *
   * @param userId
   * @return
   * @throws DBException
   * @author: JT 2008-4-22
   */
  public List getPhotoAlbumList(long userId) throws DBException {

    // 得到圈子ID
    long circleId = circleUserBo.getCircleIdByUserId(userId);

    // 得到圈子相册列表
    List list = photoAlbumBo.getPhotoAlbumListByCircleId(circleId);

    return list;
  }
예제 #2
0
  /**
   * Function: 添加一个圈子相册
   *
   * <p>Produce describe:
   *
   * @param circleId
   * @param photoAlbumName
   * @throws DBException
   * @throws LogicException
   * @author: JT 2008-4-22
   */
  public List addPhotoAlbum(long circleId, String photoAlbumName)
      throws DBException, LogicException {

    if (StringUtils.isEmpty(photoAlbumName)) {
      throw new LogicException("相册名不能为空");
    }

    if (circleId == 0) {
      throw new LogicException("圈子不存在");
    }

    if (photoAlbumDao.getPhotoAlbumByName(circleId, photoAlbumName) == null) {

      PhotoAlbum photoAlbumPo = new PhotoAlbum();

      // 初始化相册对象
      photoAlbumBo.initPhotoAlbum(photoAlbumPo);

      // 对象_ID
      photoAlbumPo.setObjectId(circleId);

      // 对象表名称
      photoAlbumPo.setObjectTableName(SystemConstant.KG_CIRCLE_INFO_TABLE_NAME);

      // 相册名字
      photoAlbumPo.setPhotoAlbumName(photoAlbumName);

      photoAlbumBo.save(photoAlbumPo);

      List list = photoAlbumBo.getPhotoAlbumListByCircleId(circleId);

      return list;

    } else {
      throw new LogicException("该相册名已存在");
    }
  }
예제 #3
0
  /**
   * Function: 添加或更新相片
   *
   * <p>Produce describe:
   *
   * @param fr
   * @throws LogicException
   * @throws SysException
   * @author: JT 2008-4-22
   */
  public void saveOrUpdatePhoto(EditPhotoForm fr) throws LogicException, SysException {

    PhotoAlbum photoAlbumPo = photoAlbumBo.load(fr.getPhotoAlbumId());

    // 初始化保存路径
    fileUploadBo.initSavePath();
    if (photoAlbumPo != null) { // 相册存在

      Photo photoPo = null;

      if (fr.getSeq() == 0) { // 上传新相片

        photoPo = new Photo();

        // 保存路径
        String dir = SystemConstant.FILE_UPLOAD_IMAGES_CIRCLE_LOCATION + fr.getPhotoAlbumId();

        // 图片
        String fileName =
            fileUploadBo.uploadFile(
                dir,
                fr.getUploadPhotoLink(),
                fr.getUploadPhotoLinkFileName(),
                SystemConstant.FILEUPLOAD_IMAGE_TYPE);

        // 相片链接地址
        if (StringUtils.isNotEmpty(fileName)) photoPo.setPhotoLink(fileName);

        // 初始化相片对象的数据
        initPhoto(photoPo);

        // 相片名称
        photoPo.setPhotoName(fr.getPhotoName());

        // 所属相册
        photoPo.setPhotoAlbumId(fr.getPhotoAlbumId());

        // 描述
        photoPo.setDescription(fr.getDescription());

        // 查看权限
        photoPo.setReadPopedom(fr.getReadPopedom());

        // 关键字
        photoPo.setKeyWord(fr.getKeyWord());

        photoDao.save(photoPo);

        // 相片所在相册中的相片数量加1
        photoAlbumBo.addPhotoCount(photoAlbumPo.getId());

      } else { // 更新相片信息

        photoPo = photoDao.load(fr.getSeq());

        if (photoPo != null) {

          // 相片名称
          photoPo.setPhotoName(fr.getPhotoName());

          // 更新相片所属相册的相片数量
          photoAlbumBo.deletePhotoCount(photoPo.getPhotoAlbumId());

          photoAlbumBo.addPhotoCount(fr.getPhotoAlbumId());

          // 根据相片ID判断此相片是否是其所在相册的封面
          if (photoBo.isCoverPhotoId(photoPo.getId())) {

            // 要移动相片为其所在相册的封面时
            // 相册的封面清空
            photoAlbumBo.load(photoPo.getPhotoAlbumId()).setCoverPhotoId(null);
          }

          // 所属相册
          photoPo.setPhotoAlbumId(fr.getPhotoAlbumId());

          // 描述
          photoPo.setDescription(fr.getDescription());

          // 查看权限
          photoPo.setReadPopedom(fr.getReadPopedom());

          // 修改时间
          photoPo.setModifyTime(new Date());

          // 关键字
          photoPo.setKeyWord(fr.getKeyWord());
        }
      }

      // 更新相册的最后更新时间
      photoAlbumPo.setModifyTime(new Date());

      // 更新相片所在相册
      photoAlbumBo.update(photoAlbumPo);
    }
  }