package org.cs.mgr.setting.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.setting.service.ISysAdvService;
import org.cs.mgr.setting.dao.ISysAdvDao;
import org.cs.mgr.setting.model.SysAdv;

/**
 * 
 * @ClassName: ISysAdvService
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:15
 */
@Service("sysAdvService")
public class SysAdvService extends BaseService<SysAdv> implements ISysAdvService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private ISysAdvDao sysAdvDao;
	
	@Override
	@Transactional(readOnly = true)
	public Pager getSysAdvs(Pager page){
		return this.sysAdvDao.querySysAdvs(page);
	}
	
	/**
	 * 自动生成
	 * @Title: delSysAdv 
	 * @Description: TODO
	 * @param id						主键id
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean delSysAdv(Integer id){
	
		SysAdv sysAdv = this.sysAdvDao.findById(id);
		if(sysAdv != null){
			sysAdv.setIsDelete(true);				
			this.sysAdvDao.update(sysAdv);
		}
		return true;
	}
	
	
	/**
	 * 自动生成
	 * @Title: addSysAdv 
	 * @Description: TODO
	 * @param sysAdv						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean addSysAdv(SysAdv sysAdv){
	
		if(sysAdv != null){
			this.sysAdvDao.insert(sysAdv);
		}
		return true;
	}
	
	
	/**
	 *  自动生成
	 * @Title: updateSysAdv 
	 * @Description: TODO
	 * @param sysAdv						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean updateSysAdv(SysAdv sysAdv){
	
		SysAdv sysAdv2 = this.sysAdvDao.findById(sysAdv.getId());
		if(sysAdv2 != null){
			sysAdv.mergeTo(sysAdv2);
			this.sysAdvDao.update(sysAdv2);
		}
		
		return true;
	}
	
	
	
	
}
