package org.cs.mgr.user.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.user.service.IMgmUserDeptService;
import org.cs.mgr.user.dao.IMgmUserDeptDao;
import org.cs.mgr.user.model.MgmUserDept;

/**
 * 
 * @ClassName: IMgmUserDeptService
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:28:57
 */
@Service("mgmUserDeptService")
public class MgmUserDeptService extends BaseService<MgmUserDept> implements IMgmUserDeptService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private IMgmUserDeptDao mgmUserDeptDao;
	
	@Override
	@Transactional(readOnly = true)
	public Pager getMgmUserDepts(Pager page){
		return this.mgmUserDeptDao.queryMgmUserDepts(page);
	}
	
	/**
	 * 自动生成
	 * @Title: delMgmUserDept 
	 * @Description: TODO
	 * @param id						主键id
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean delMgmUserDept(Integer id){
	
		MgmUserDept mgmUserDept = this.mgmUserDeptDao.findById(id);
		if(mgmUserDept != null){
			mgmUserDept.setIsDelete(true);				
			this.mgmUserDeptDao.update(mgmUserDept);
		}
		return true;
	}
	
	
	/**
	 * 自动生成
	 * @Title: addMgmUserDept 
	 * @Description: TODO
	 * @param mgmUserDept						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean addMgmUserDept(MgmUserDept mgmUserDept){
	
		if(mgmUserDept != null){
			this.mgmUserDeptDao.insert(mgmUserDept);
		}
		return true;
	}
	
	
	/**
	 *  自动生成
	 * @Title: updateMgmUserDept 
	 * @Description: TODO
	 * @param mgmUserDept						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean updateMgmUserDept(MgmUserDept mgmUserDept){
	
		MgmUserDept mgmUserDept2 = this.mgmUserDeptDao.findById(mgmUserDept.getId());
		if(mgmUserDept2 != null){
			mgmUserDept.mergeTo(mgmUserDept2);
			this.mgmUserDeptDao.update(mgmUserDept2);
		}
		
		return true;
	}
	
	
	
	
}
