package com.unis.detectionnum.server.domain;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.common.utils.LsBeanUtils;
import com.unis.detectionnum.common.vo.LogVO;
import com.unis.detectionnum.server.dao.LogDao;
import com.unis.detectionnum.server.entity.LogDO;

@Component
public class LogDomain extends BaseDomain{

	@Autowired
    private LogDao logDao;

	/** 
	 * @Title: save 
	 * @Description: TODO
	 * @param logVO
	 * @return void
	 * @throws 
	 */
	public int save(LogVO logVO) {
		// TODO Auto-generated method stub
		LogDO logDO = new LogDO();
		LsBeanUtils.copyAllProperties(logVO, logDO);
		return logDao.insertSelective(logDO);
	}

	/** 
	 * @Title: getLogsPageList 
	 * @Description: 分页查询日志信息
	 * @param userName
	 * @param pageNum
	 * @param pageSize
	 * @return PageInfo<LogVO>
	 * @throws 
	 */
	public PageInfo<LogVO> getLogsPageList(String userName, Integer pageNum, Integer pageSize) {
		PageInfo<LogVO> voPageInfo = new PageInfo<>();
		
		PageHelper.startPage(pageNum, pageSize);
		List<LogDO> logDOList = logDao.selectByUserName(userName);
		PageInfo<LogDO> doPageInfo = new PageInfo<>(logDOList);
		
		LsBeanUtils.copyAllProperties(doPageInfo, voPageInfo);
		return voPageInfo;
	} 
	
	
	
}
