package com.interplug.qcast.biz.canvasSetting;

import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo;

import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class CanvasSettingService {
	private final CanvasSettingMapper canvasSettingMapper;

	// Canvas Setting 조회(objectNo)
	public CanvasSettingInfo selectCanvasSetting(String objectNo) {
		return canvasSettingMapper.selectCanvasSetting(objectNo);
	}

	// Canvas Setting 등록
	public Map<String, String> insertCanvasSetting(CanvasSettingInfo csi) {
		
		Map<String, String> response = new HashMap<>();

		try { 
			canvasSettingMapper.insertCanvasSetting(csi);
			
			response.put("objectNo", csi.getObjectNo());
			response.put("returnMessage", "common.message.confirm.mark");
			
		} catch (Exception e) {
			response.put("objectNo", csi.getObjectNo());
			response.put("returnMessage", "common.message.save.error");
		}

		// 생성된 objectNo 반환
		return response;

	}

	// Canvas Setting 수정
	public void updateCanvasSetting(CanvasSettingInfo csi) {
		canvasSettingMapper.updateCanvasSetting(csi);
	}

}
