package com.palmnest.service.notice.impl;

import com.palmnest.dao.notice.WxtemplateConfigParaDao;
import com.palmnest.model.notice.WxtemplateConfigPara;
import com.palmnest.service.impl.GenericManagerImpl;
import com.palmnest.service.notice.WxtemplateConfigParaManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("wxtemplateConfigParaManager")
public class WxtemplateConfigParaManagerImpl extends GenericManagerImpl<WxtemplateConfigPara, Integer> implements WxtemplateConfigParaManager {

	private WxtemplateConfigParaDao wxtemplateConfigParaDao;

	@Autowired
	public void setRoomInfoDao(WxtemplateConfigParaDao wxtemplateConfigParaDao) {
		this.wxtemplateConfigParaDao = wxtemplateConfigParaDao;
		this.dao = wxtemplateConfigParaDao;
	}


	@Override
	public String saveOrUpdate(WxtemplateConfigPara wxtemplateConfigPara) {

		String isSuccess = "fail";
		if (wxtemplateConfigPara.getId() == null) {
			WxtemplateConfigPara model = wxtemplateConfigParaDao.save(wxtemplateConfigPara);
			if (model != null) {
				isSuccess = "success";
			}
		} else {
			try {
				wxtemplateConfigParaDao.updateObj(wxtemplateConfigPara);
				isSuccess = "success";
			} catch (Exception e) {

				isSuccess = "fail";
			}
		}
		return isSuccess;
	}


	@Override
	public List<WxtemplateConfigPara> getWxTemplConfigByTypeId(
			int msgId) throws Exception {
		return wxtemplateConfigParaDao.getWxTemplConfigByTypeId(msgId);
	}

	@Override
	public void deleteByMsgId(int id) {
		wxtemplateConfigParaDao.deleteByMsgId(id);
	}

}
