}
@Override
public Photo getPhotoDetailById(long photoId, long viewerId, boolean addVisit) {
if (photoId == 0) {
throw new NoResourceException("Id为0的图片不存在");
}
Photo photo = photoDao.queryPhotoDetailById(photoId);
if (photo == null) {
throw new NoResourceException("Id为" + photoId + "的图片不存在");
}
Activity act = photo.getActivity();
if (act == Activity.DELETED || act == Activity.FREEZED) {
throw new NoResourceException("Id为" + photoId + "的照片已删除或者已被屏蔽");
}
if (addVisit && photo.getOwnerId() != viewerId) {
photoDao.updateVisitCount(photo.getAlbumId(), photoId, 1);
}
return photo;