if (photo.getOwnerId() == userId) {
Activity oldActivity = photo.getActivity();
if (oldActivity == Activity.NORMAL) {// 只能删除普通相册
Long albumId = photo.getAlbumId();
String file = photo.getSmallFile();
Album album = albumDao.queryAlbumById(albumId);
if (album.getOwnerId() != userId) {
throw new NoOperatePermissionException("ID为" + userId + "的用户没有修改ID为" + albumId
+ "相册的权限");
}
String cover = album.getCover();
if (cover.equals(file)) {
albumDao.updateRandomCoverAndPhotoCount(userId, albumId, photoId, this.cover,
this.ext, -1);
} else {
albumDao.updatePhotoCount(userId, albumId, -1);
}
photoDao.updatePhotoActivity(album.getId(), photoId, Activity.DELETED);
return album.getId();
} else {
throw new NoOperatePermissionException("Id为" + photoId + "的相册状态为" + oldActivity
+ ",不能删除");
}
} else {