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.unis.base.common.vo.TzQylxVO;
import com.unis.base.server.dao.TzQylxDao;
import com.unis.base.server.entity.TzQylxDO;
import com.unis.common.utils.LsBeanUtils;

/**
 * @author zhengbodang
 * @version 1.0
 * @Title TzQylxDomain
 * @ProjectName 持久化
 * @Description
 * @date 2019/08/12 17点26分
 */
@Component
public class TzQylxDomain extends BaseDomain {

	@Autowired
	private TzQylxDao tzQylxMapper;

	/**
	 *
	 * @param TyZjxxzbVO
	 * @return
	 */
	public List<TzQylxVO> getTzQylxList(TzQylxVO tzQylxVO) {
		TzQylxDO qylxDO = new TzQylxDO();
		//进行传递参数copy
		LsBeanUtils.copyAllProperties(tzQylxVO, qylxDO);
		List<TzQylxVO> tzQylxDOList = new ArrayList<TzQylxVO>();

		for (TzQylxDO tzQylxDO : tzQylxMapper.select(qylxDO)) {
			LsBeanUtils.copyAllProperties(tzQylxDO, tzQylxVO);
			tzQylxDOList.add(tzQylxVO);
		}
		return tzQylxDOList;
	}

	/**
	 *
	 * @param TyZjxxzbVO
	 * @return
	 */
	public int insert(TzQylxVO tzQylxVO) {
		//进行传递参数copy
		TzQylxDO tzQylxDO = new TzQylxDO();
		LsBeanUtils.copyAllProperties(tzQylxVO, tzQylxDO);
		Integer integer = tzQylxMapper.selectMaxId();
		tzQylxDO.setId(integer);
		return tzQylxMapper.insert(tzQylxDO);
	}

	/**
	 *
	 * @param zjxxid
	 * @return
	 */
	public TzQylxVO getTzQylxById(String qylxid) {
		TzQylxVO tzQylxVO = new TzQylxVO();
		LsBeanUtils.copyAllProperties(tzQylxMapper.selectByPrimaryKey(qylxid), tzQylxVO);
		return tzQylxVO;
	}

	/**
	 *
	 * @param TyZjxxzbVO
	 * @return
	 */
	public int update(TzQylxVO tzQylxVO) {
		//进行传递参数copy
		TzQylxDO TzQylxDO = new TzQylxDO();
		LsBeanUtils.copyAllProperties(tzQylxVO, TzQylxDO);
		return tzQylxMapper.updateByPrimaryKey(TzQylxDO);
	}
}
