| 
					
				 | 
			
			
				@@ -0,0 +1,114 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.its.op.service.its.database; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.op.dao.repository.its.database.TbStrmIceSvrInfoRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.op.dto.its.database.TbStrmIceSvrInfoDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.op.entity.its.database.TbStrmIceSvrInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.RequiredArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.NoSuchElementException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Optional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RequiredArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class TbStrmIceSvrInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final TbStrmIceSvrInfoRepository repo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 데이터 1건 조회, 없으면 exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TbStrmIceSvrInfo requireOne(String svrIp) throws NoSuchElementException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Optional<TbStrmIceSvrInfo> info = this.repo.findById(svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (info.isPresent()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return info.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new NoSuchElementException("데이터가 존재하지 않습니다: " + svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 전체 데이터 조회 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(readOnly = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TbStrmIceSvrInfoDto> findAll() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfoDto> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfo> data = this.repo.findAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (TbStrmIceSvrInfo entity : data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.add(entity.toDto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 전체 데이터 조회 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(readOnly = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TbStrmIceSvrInfoDto> findAllList() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfoDto> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfo> data = this.repo.findAllList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (TbStrmIceSvrInfo entity : data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.add(entity.toDto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 데이터 1건 조회(기존 데이터가 반드시 존재해야 함) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(readOnly = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TbStrmIceSvrInfoDto findById(String svrIp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TbStrmIceSvrInfo entity = requireOne(svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return entity.toDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 데이터 변경 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TbStrmIceSvrInfoDto updateById(String svrIp, TbStrmIceSvrInfoDto.TbStrmIceSvrInfoUpdReq req) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TbStrmIceSvrInfo entity = requireOne(svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        entity.updateInfo(req); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.repo.save(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return entity.toDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 데이터 변경 또는 생성-목록(데이터가 존재하면 업데이트 없으면 신규로 생성) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TbStrmIceSvrInfoDto> mergeInfoList(List<TbStrmIceSvrInfoDto.TbStrmIceSvrInfoUpdReq> reqList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfoDto> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (TbStrmIceSvrInfoDto.TbStrmIceSvrInfoUpdReq req : reqList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            TbStrmIceSvrInfo obj = req.toEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.repo.save(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.add(obj.toDto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 데이터 변경 또는 생성-개별(데이터가 존재하면 업데이트 없으면 신규로 생성) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TbStrmIceSvrInfoDto mergeInfo(TbStrmIceSvrInfoDto.TbStrmIceSvrInfoUpdReq req) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TbStrmIceSvrInfo obj = req.toEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.repo.save(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return obj.toDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 정보 삭제-개별, 데이터 존재하지 않으면 Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TbStrmIceSvrInfoDto deleteById(String svrIp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TbStrmIceSvrInfo entity = requireOne(svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.repo.deleteById(svrIp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return entity.toDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 정보 삭제-목록, 존재하는 데이터 만 삭제 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TbStrmIceSvrInfoDto> deleteByIds(List<String> ids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TbStrmIceSvrInfoDto> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (String id : ids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Optional<TbStrmIceSvrInfo> obj = this.repo.findById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (obj.isPresent()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.repo.deleteById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result.add(obj.get().toDto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |