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

import java.util.Date;

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

import com.ym.mec.biz.dal.dao.ChargeTypeDao;
import com.ym.mec.biz.dal.dao.ChargeTypeSubjectMapperDao;
import com.ym.mec.biz.dal.entity.ChargeType;
import com.ym.mec.biz.service.ChargeTypeService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.service.impl.BaseServiceImpl;

@Service
public class ChargeTypeServiceImpl extends BaseServiceImpl<Integer, ChargeType>  implements ChargeTypeService {
	
	@Autowired
	private ChargeTypeDao chargeTypeDao;
	@Autowired
	private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;

	@Override
	public BaseDAO<Integer, ChargeType> getDAO() {
		return chargeTypeDao;
	}


	@Override
	@Transactional(rollbackFor = Exception.class)
	public void upSet(ChargeType chargeType) {
		if(chargeType.getId() != null){
			//修改
			chargeType.setUpdateTime(new Date());
			chargeTypeDao.update(chargeType);
		}else {
			//新增
			chargeTypeDao.insert(chargeType);
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void del(Integer chargeTypeId) {
		chargeTypeDao.delete(chargeTypeId);
	}
}