package kr.co.jinwoosi.clfd.conts.menu.service.impl;

import javax.annotation.Resource;

import kr.co.jinwoosi.clfd.conts.menu.mapper.MenuPopupMapper;
import kr.co.jinwoosi.clfd.conts.menu.model.MenuPopup;
import kr.co.jinwoosi.clfd.conts.menu.model.MenuPopupSearch;
import kr.co.jinwoosi.clfd.conts.menu.service.MenuPopupService;
import kr.co.jinwoosi.clfd.framework.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

@Service(value="cmsMenuPopupService")
public class MenuPopupServiceImpl extends BaseServiceImpl<MenuPopup, MenuPopupSearch, MenuPopupMapper> implements MenuPopupService {

	@Override
	@Resource (name="cmsMenuPopupMapper")
	protected void setMapper (MenuPopupMapper mapper) {
		super.setMapper (mapper);
	}

	@Override
	public void insert(long menuId, long[] popupIdList) {
		MenuPopup menuPopup = new MenuPopup();
		menuPopup.setMenuId(menuId);
		super.delete(menuPopup);
		if(popupIdList != null) {
			for(long popupId : popupIdList) {
				menuPopup.setPopupId(popupId);
				super.insert(menuPopup);
			}
		}
	}
	
}
