package com.its.op.service.its.wcam;

import com.its.op.dao.repository.its.wcam.TbWcamCtlrSttsRepository;
import com.its.op.entity.its.wcam.TbWcamCtlrStts;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.NoSuchElementException;
import java.util.Optional;

@Slf4j
@RequiredArgsConstructor
@Service
public class TbWcamCtlrSttsService {

    private final TbWcamCtlrSttsRepository repo;

    // 데이터 1건 조회, 없으면 exception
    private TbWcamCtlrStts requireOne(Long wcamCtlrNmbr) throws NoSuchElementException {
        Optional<TbWcamCtlrStts> info = this.repo.findById(wcamCtlrNmbr);
        if (info.isPresent()) {
            return info.get();
        }
        else {
            throw new NoSuchElementException("데이터가 존재하지 않습니다: " + wcamCtlrNmbr);
        }
    }

}
