package com.unis.base.server.domain;


import java.util.ArrayList;
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.base.common.vo.TyCrkxxPageVO;
import com.unis.base.common.vo.TyCrkxxVO;
import com.unis.base.server.dao.TyCrkxxDao;
import com.unis.base.server.entity.TyCrkxxDO;
import com.unis.common.utils.LsBeanUtils;

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

	@Autowired
	private TyCrkxxDao tyCrkxxMapper;

	/**
	 *
	 * @param tyCrkxxVO
	 * @return
	 */
	public List<TyCrkxxVO> getTyCrkxxList(TyCrkxxVO tyCrkxxVO) {
		TyCrkxxDO tyCrkxxDO = new TyCrkxxDO();
		//进行传递参数copy
		LsBeanUtils.copyAllProperties(tyCrkxxVO, tyCrkxxDO);
		List<TyCrkxxVO> tyCrkxxVOs = new ArrayList<TyCrkxxVO>();

		for (TyCrkxxDO TyCrkxxDO : tyCrkxxMapper.select(tyCrkxxDO)) {
			LsBeanUtils.copyAllProperties(TyCrkxxDO,tyCrkxxVO);
			tyCrkxxVOs.add(tyCrkxxVO);
		}
		return tyCrkxxVOs;
	}

	/**
	 *
	 * @param tyCrkxxVO
	 * @return
	 */
	public int insert(TyCrkxxVO tyCrkxxVO) {
		//进行传递参数copy
		TyCrkxxDO tyCrkxxDO = new TyCrkxxDO();
		LsBeanUtils.copyAllProperties(tyCrkxxVO,tyCrkxxDO);
		return tyCrkxxMapper.insert(tyCrkxxDO);
	}

	/**
	 *
	 * @param crkid
	 * @return
	 */
	public TyCrkxxVO getTyCrkxxById(String crkid) {
		TyCrkxxVO tyCrkxxVO = new TyCrkxxVO();
		LsBeanUtils.copyAllProperties(tyCrkxxMapper.selectByKey(crkid), tyCrkxxVO);
		return tyCrkxxVO;
	}

	/**
	 *
	 * @param tyCrkxxVO
	 * @return
	 */
	public int update(TyCrkxxVO tyCrkxxVO) {
		//进行传递参数copy
		TyCrkxxDO tyCrkxxDO = new TyCrkxxDO();
		LsBeanUtils.copyAllProperties(tyCrkxxVO,tyCrkxxDO);
		return tyCrkxxMapper.updateByPrimaryKey(tyCrkxxDO);
	}

	/**
	 * 分页
	 * @param tyCrkxxVO
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	public PageInfo<TyCrkxxVO> getTyCrkxxListPage(TyCrkxxVO tyCrkxxVO, Integer pageNum, Integer pageSize) {
		PageInfo<TyCrkxxVO> pageInfoVO = new PageInfo<TyCrkxxVO>();
		PageHelper.startPage(pageNum, pageSize);
		TyCrkxxDO tyCrkxxDO = new TyCrkxxDO();
		//进行传递参数copy
		LsBeanUtils.copyAllProperties(tyCrkxxVO, tyCrkxxDO);
		List<TyCrkxxDO> tDOs =   tyCrkxxMapper.select(tyCrkxxDO);
		PageInfo<TyCrkxxDO> PageInfoDO = new PageInfo<TyCrkxxDO>(tDOs);
		LsBeanUtils.copyAllProperties(PageInfoDO,pageInfoVO);
		return pageInfoVO;
	}

	/**
	 * 分页
	 * @param tyCrkxxVO
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	public PageInfo<TyCrkxxPageVO> getTyCrkxxListPageExtend(TyCrkxxPageVO tyCrkxxVO, Integer pageNum, Integer pageSize) {
		PageInfo<TyCrkxxPageVO> pageInfoVO = new PageInfo<TyCrkxxPageVO>();
		PageHelper.startPage(pageNum, pageSize);
		//进行传递参数copy
		List<TyCrkxxPageVO> tDOs =   tyCrkxxMapper.selectPageList(tyCrkxxVO);
		PageInfo<TyCrkxxPageVO> PageInfoDO = new PageInfo<TyCrkxxPageVO>(tDOs);
		LsBeanUtils.copyAllProperties(PageInfoDO,pageInfoVO);
		return pageInfoVO;
	}


}
