package org.cs.mgr.order.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import org.cs.core.service.impl.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.cs.util.Pager;
import org.cs.mgr.order.service.IMgmOrderProductService;
import org.cs.mgr.order.dao.IMgmOrderProductDao;
import org.cs.mgr.order.model.MgmOrderProduct;

/**
 * 
 * @ClassName: IMgmOrderProductService
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:03
 */
@Service("mgmOrderProductService")
public class MgmOrderProductService extends BaseService<MgmOrderProduct> implements IMgmOrderProductService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private IMgmOrderProductDao mgmOrderProductDao;
	
	@Override
	@Transactional(readOnly = true)
	public Pager getMgmOrderProducts(Pager page){
		return this.mgmOrderProductDao.queryMgmOrderProducts(page);
	}
	
	/**
	 * 自动生成
	 * @Title: delMgmOrderProduct 
	 * @Description: TODO
	 * @param id						主键id
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean delMgmOrderProduct(Integer id){
	
		MgmOrderProduct mgmOrderProduct = this.mgmOrderProductDao.findById(id);
		if(mgmOrderProduct != null){
			mgmOrderProduct.setIsDelete(true);				
			this.mgmOrderProductDao.update(mgmOrderProduct);
		}
		return true;
	}
	
	
	/**
	 * 自动生成
	 * @Title: addMgmOrderProduct 
	 * @Description: TODO
	 * @param mgmOrderProduct						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean addMgmOrderProduct(MgmOrderProduct mgmOrderProduct){
	
		if(mgmOrderProduct != null){
			this.mgmOrderProductDao.insert(mgmOrderProduct);
		}
		return true;
	}
	
	
	/**
	 *  自动生成
	 * @Title: updateMgmOrderProduct 
	 * @Description: TODO
	 * @param mgmOrderProduct						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean updateMgmOrderProduct(MgmOrderProduct mgmOrderProduct){
	
		MgmOrderProduct mgmOrderProduct2 = this.mgmOrderProductDao.findById(mgmOrderProduct.getId());
		if(mgmOrderProduct2 != null){
			mgmOrderProduct.mergeTo(mgmOrderProduct2);
			this.mgmOrderProductDao.update(mgmOrderProduct2);
		}
		
		return true;
	}
	
	
	
	
}
