package io.delphiplatform.api.v3.rdb.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import io.delphiplatform.api.v3.model.Label;
import io.delphiplatform.api.v3.rdb.entity.LabelEntity;
import io.delphiplatform.api.v3.rdb.repository.LabelRepository;

@Service
@Transactional(readOnly = true)
public class LabelService extends EntityService<LabelEntity> {

    private final LabelRepository labelRepository;

    @Autowired
    public LabelService(LabelRepository labelRepository) {
        super(labelRepository);
        this.labelRepository = labelRepository;
    }

    public Label findOne(String labelId) {
        return Label.from(labelRepository.findById(labelId).orElseThrow(NOT_FOUND));
    }

}
