content: package com.example.demo.service.impl;
  
  import com.example.demo.domain.Region;
  import com.example.demo.repository.RegionRepository;
  import com.example.demo.service.RegionService;
  import java.util.List;
  import java.util.Optional;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  /**
   * Service Implementation for managing {@link Region}.
   */
  @Service
  @Transactional
  public class RegionServiceImpl implements RegionService {
  
      private final Logger log = LoggerFactory.getLogger(RegionServiceImpl.class);
  
      private final RegionRepository regionRepository;
  
      public RegionServiceImpl(RegionRepository regionRepository) {
          this.regionRepository = regionRepository;
      }
  
      @Override
      public Region save(Region region) {
          log.debug("Request to save Region : {}", region);
          return regionRepository.save(region);
      }
  
      @Override
      public Optional<Region> partialUpdate(Region region) {
          log.debug("Request to partially update Region : {}", region);
  
          return regionRepository
              .findById(region.getId())
              .map(existingRegion -> {
                  if (region.getRegionName() != null) {
                      existingRegion.setRegionName(region.getRegionName());
                  }
  
                  return existingRegion;
              })
              .map(regionRepository::save);
      }
  
      @Override
      @Transactional(readOnly = true)
      public List<Region> findAll() {
          log.debug("Request to get all Regions");
          return regionRepository.findAll();
      }
  
      @Override
      @Transactional(readOnly = true)
      public Optional<Region> findOne(Long id) {
          log.debug("Request to get Region : {}", id);
          return regionRepository.findById(id);
      }
  
      @Override
      public void delete(Long id) {
          log.debug("Request to delete Region : {}", id);
          regionRepository.deleteById(id);
      }
  }
  