feat: api wrapping

This commit is contained in:
2025-11-17 15:23:36 +09:00
parent c081892ae7
commit 57943ebed4
6 changed files with 40 additions and 6 deletions

View File

@@ -34,12 +34,13 @@ public class AnimalCoreService
@Transactional
public AnimalDto.Basic create(AnimalDto.AddReq req) {
ZooEntity zoo = null;
if (req.getZooId() != null) {
if (req.getZooUuid() != null) {
zoo =
zooRepository
.getZooByUid(req.getZooId())
.getZooByUuid(req.getZooUuid())
.orElseThrow(
() -> new EntityNotFoundException(" not found with id: " + req.getZooId()));
() ->
new EntityNotFoundException("Zoo not found with uuid: " + req.getZooUuid()));
}
AnimalEntity entity = new AnimalEntity(req.getCategory(), req.getSpecies(), req.getName(), zoo);
AnimalEntity saved = animalRepository.save(entity);