class CategoryServiceImpl implements CategoryService {

    @Override
    public Category save(CategoryDto dto) {
        log.info(LogMessage.IN_SAVE);

        Category byName = categoryRepo.findByName(dto.getName());

        if (byName != null) {
            throw new BadCategoryRequestException(
                ErrorMessage.CATEGORY_ALREADY_EXISTS_BY_THIS_NAME);
        }
        return categoryRepo.save(Category.builder().name(dto.getName()).build());
    }

}