package com.ym.mec.biz.service.impl;

import com.ym.mec.biz.dal.dao.ChargeTypeOrganizationFeeDao;
import com.ym.mec.biz.dal.entity.ChargeTypeOrganizationFee;
import com.ym.mec.biz.service.ChargeTypeOrganizationFeeService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.exception.BizException;
import com.ym.mec.common.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ChargeTypeOrganizationFeeServiceImpl extends BaseServiceImpl<Integer, ChargeTypeOrganizationFee>  implements ChargeTypeOrganizationFeeService {
	
	@Autowired
	private ChargeTypeOrganizationFeeDao chargeTypeOrganizationFeeDao;

	@Override
	public BaseDAO<Integer, ChargeTypeOrganizationFee> getDAO() {
		return chargeTypeOrganizationFeeDao;
	}

	@Override
	public ChargeTypeOrganizationFee findByOrganId(Integer chargeTypeId, Integer organId) {
		return chargeTypeOrganizationFeeDao.findByOrganId(chargeTypeId,organId);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void add(ChargeTypeOrganizationFee chargeTypeOrganizationFee) {
		try {
			chargeTypeOrganizationFeeDao.insert(chargeTypeOrganizationFee);
		}catch (Exception e){
			throw new BizException("数据已存在");
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateFee(ChargeTypeOrganizationFee chargeTypeOrganizationFee) {
		try {
			chargeTypeOrganizationFeeDao.update(chargeTypeOrganizationFee);
		}catch (Exception e){
			throw new BizException("数据已存在");
		}
	}
}
