Created
November 20, 2015 10:48
-
-
Save codingtim/737ca0f5b3bec43d68b7 to your computer and use it in GitHub Desktop.
start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EntityServiceImp implements EntityService { | |
private EntityRepository repository; | |
private ImageService imageService; | |
@Override | |
public void update(String id, UpdateData updateData) { | |
Entity entity = repository.find(id); | |
entity.setDescription(updateData.getDescription()); | |
entity.setTitle(updateData.getTitle()); | |
imageService.updateImage(entity, updateData); | |
repository.save(entity); | |
} | |
} | |
public class ImageServiceImpl implements ImageService { | |
private ImageStoreGateway imageStoreGateway; | |
@Override | |
public void updateImage(Entity entity, UpdateData updateData) { | |
if (updateData.getImageUrl() != null) { | |
ImageEntity imageEntity = new ImageEntity(); | |
imageEntity.setImageUrl(updateData.getImageUrl()); | |
imageStoreGateway.postImage(imageEntity); | |
ImageEntity previous = entity.getImage(); | |
imageStoreGateway.deleteImage(previous); | |
entity.setImage(imageEntity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment