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.IMgmInviteRecordService;
import org.cs.mgr.user.dao.IMgmInviteRecordDao;
import org.cs.mgr.user.model.MgmInviteRecord;

/**
 * 
 * @ClassName: IMgmInviteRecordService
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:28:56
 */
@Service("mgmInviteRecordService")
public class MgmInviteRecordService extends BaseService<MgmInviteRecord> implements IMgmInviteRecordService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private IMgmInviteRecordDao mgmInviteRecordDao;
	
	@Override
	@Transactional(readOnly = true)
	public Pager getMgmInviteRecords(Pager page){
		return this.mgmInviteRecordDao.queryMgmInviteRecords(page);
	}
	
	/**
	 * 自动生成
	 * @Title: delMgmInviteRecord 
	 * @Description: TODO
	 * @param id						主键id
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean delMgmInviteRecord(Integer id){
	
		MgmInviteRecord mgmInviteRecord = this.mgmInviteRecordDao.findById(id);
		if(mgmInviteRecord != null){
			mgmInviteRecord.setIsDelete(true);				
			this.mgmInviteRecordDao.update(mgmInviteRecord);
		}
		return true;
	}
	
	
	/**
	 * 自动生成
	 * @Title: addMgmInviteRecord 
	 * @Description: TODO
	 * @param mgmInviteRecord						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean addMgmInviteRecord(MgmInviteRecord mgmInviteRecord){
	
		if(mgmInviteRecord != null){
			this.mgmInviteRecordDao.insert(mgmInviteRecord);
		}
		return true;
	}
	
	
	/**
	 *  自动生成
	 * @Title: updateMgmInviteRecord 
	 * @Description: TODO
	 * @param mgmInviteRecord						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean updateMgmInviteRecord(MgmInviteRecord mgmInviteRecord){
	
		MgmInviteRecord mgmInviteRecord2 = this.mgmInviteRecordDao.findById(mgmInviteRecord.getId());
		if(mgmInviteRecord2 != null){
			mgmInviteRecord.mergeTo(mgmInviteRecord2);
			this.mgmInviteRecordDao.update(mgmInviteRecord2);
		}
		
		return true;
	} 
	/**
	 * 
	 * @Title: getMgmInviteRecordsList   
	 * @Description: 邀请记录
	 * @param: @param map
	 * @param: @return         
	 * @see org.cs.mgr.user.service.IMgmInviteRecordService#getMgmInviteRecordsList(java.util.Map)
	 */
	@Override
	public Pager getMgmInviteRecordsList(Map<String,String> map){
		String code=map.get("code");
		Integer page = Integer.valueOf(map.get("page"));
		return this.mgmInviteRecordDao.queryMgmInviteRecordsByCode(new Pager(page),code);
	}
	
	/**
	 * 
	 * @Title: getMgmInviteRecordsList   
	 * @Description: 邀请记录
	 * @param: @param map
	 * @param: @return         
	 * @see org.cs.mgr.user.service.IMgmInviteRecordService#getMgmInviteRecordsList(java.util.Map)
	 */
	@Override
	public List<MgmInviteRecord> getMgmInviteRecordsList(String code){
		return this.mgmInviteRecordDao.queryMgmInviteRecordsByCode(code);
	}
}
