package com.palmnest.service.estateserve.impl;

import java.util.List;

import org.directwebremoting.util.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.palmnest.dao.estateserve.PushModelDao;
import com.palmnest.model.PushModel;
import com.palmnest.service.estateserve.PushModelManger;
import com.palmnest.service.impl.GenericManagerImpl;

@Service("pushModelManger")
public class PushModelManagerImpl extends GenericManagerImpl<PushModel, Integer> implements PushModelManger {

	private Logger LOG = Logger.getLogger(PushModelManagerImpl.class);

	private PushModelDao pushModelDao;

	@Autowired
	public void setPushModelDao(PushModelDao pushModelDao) {
		this.pushModelDao = pushModelDao;
		this.dao = pushModelDao;
	}


	@Transactional
	@Override
	public String addPushModel(PushModel pushModel) {
		String retFlag = "success";
		try {
			if (pushModel.getId() == null) {
				pushModelDao.saveObj(pushModel);
			} else {
				pushModelDao.updateObj(pushModel);
			}
			LOG.info("addPushModel:" + retFlag);
		} catch (Exception e) {
			retFlag = "error";
			LOG.info("addPushModel:" + retFlag + "------Exception:" + e.getMessage());
		}
		return retFlag;
	}


	@Override
	public PushModel getPushModel(int billType, int pushWay, String orgId) throws Exception {
		return pushModelDao.getPushModel(billType, pushWay, orgId);
	}


	@Transactional
	@Override
	public List<PushModel> getPushModel(String orgId)
			throws Exception {
		return pushModelDao.getPushModel(orgId);
	}

}
