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.ISysVersionService;
import org.cs.mgr.setting.dao.ISysVersionDao;
import org.cs.mgr.setting.model.SysVersion;

/**
 * 
 * @ClassName: ISysVersionService
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:14
 */
@Service("sysVersionService")
public class SysVersionService extends BaseService<SysVersion> implements ISysVersionService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private ISysVersionDao sysVersionDao;
	
	@Override
	@Transactional(readOnly = true)
	public Pager getSysVersions(Pager page){
		return this.sysVersionDao.querySysVersions(page);
	}
	
	/**
	 * 自动生成
	 * @Title: delSysVersion 
	 * @Description: TODO
	 * @param id						主键id
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean delSysVersion(Integer id){
	
		SysVersion sysVersion = this.sysVersionDao.findById(id);
		if(sysVersion != null){
			sysVersion.setIsDelete(true);				
			this.sysVersionDao.update(sysVersion);
		}
		return true;
	}
	
	
	/**
	 * 自动生成
	 * @Title: addSysVersion 
	 * @Description: TODO
	 * @param sysVersion						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean addSysVersion(SysVersion sysVersion){
	
		if(sysVersion != null){
			this.sysVersionDao.insert(sysVersion);
		}
		return true;
	}
	
	
	/**
	 *  自动生成
	 * @Title: updateSysVersion 
	 * @Description: TODO
	 * @param sysVersion						对象
	 * @return
	 * @return: boolean
	 */
	@Override
	@Transactional(readOnly = false)
	public boolean updateSysVersion(SysVersion sysVersion){
	
		SysVersion sysVersion2 = this.sysVersionDao.findById(sysVersion.getId());
		if(sysVersion2 != null){
			sysVersion.mergeTo(sysVersion2);
			this.sysVersionDao.update(sysVersion2);
		}
		
		return true;
	}
	
	
	
	
}
