package com.unis.base.server.domain;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.TyLskcxxHisVO;
import com.unis.base.server.dao.TyLskcxxHisDao;
import com.unis.base.server.entity.TyLskcxxHisDO;
import com.unis.common.utils.LsBeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author huangxing
 * @version 1.0
 * @Title TyLskcxxDomain
 * @ProjectName 持久化
 * @Description
 * @date 2019/07/22 17点26分
 */
@Component
public class TyLskcxxHisDomain extends BaseDomain {

	@Autowired
	private TyLskcxxHisDao hisDao;

	public Map<String, Object> getTyLskcxxHisList(Integer pageNum, Integer pageSize) {

		PageHelper.startPage(pageNum,pageSize);
		List<TyLskcxxHisDO> hisDOList = hisDao.getTyLskcxxHisList();
		PageInfo<TyLskcxxHisDO> pageInfo = new PageInfo<>(hisDOList);

		List<TyLskcxxHisVO> tyLskcxxHisVOS = new ArrayList<>();

		if (hisDOList != null && !hisDOList.isEmpty()){
			for (TyLskcxxHisDO hisDO: hisDOList){
				TyLskcxxHisVO hisVO = new TyLskcxxHisVO();
				LsBeanUtils.copyAllProperties(hisDO,hisVO);
				tyLskcxxHisVOS.add(hisVO);
			}
		}

		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("total",pageInfo.getTotal());
		resultMap.put("tyLskcxxHisVOS",tyLskcxxHisVOS);
		return resultMap;
	}
}
