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.ForwardMainVO;
import com.unis.detectionnum.common.vo.ForwardPeopleVO;
import com.unis.detectionnum.server.dao.TcForwardMainDao;
import com.unis.detectionnum.server.dao.TcForwardPeopleDao;
import com.unis.detectionnum.server.entity.TcForwardMainDO;
import com.unis.detectionnum.server.entity.TcForwardPeopleDO;

/** 
 * @ClassName: ForwardDomain 
 * @Description: TODO 
 * @author LiuFeng 
 * @date 2019年10月9日 下午4:09:42  
 */
@Component
public class ForwardDomain extends BaseDomain {

	@Autowired
	private TcForwardMainDao forwardMainDao;
	
	@Autowired
	private TcForwardPeopleDao forwardPeopleDao;

	/** 
	 * @Title: saveForwardMain 
	 * @Description: 前传规则信息新增
	 * @param forwardMainVO
	 * @return String
	 * @throws 
	 */
	public String saveForwardMain(ForwardMainVO forwardMainVO) {
		TcForwardMainDO forwardMainDO = new TcForwardMainDO();
		LsBeanUtils.copyAllProperties(forwardMainVO, forwardMainDO);
		forwardMainDao.insertSelective(forwardMainDO);
		return forwardMainDO.getForwardNo();
	}

	/** 
	 * @Title: updateForwardMain 
	 * @Description: 前传规则修改
	 * @param forwardMainVO
	 * @return void
	 * @throws 
	 */
	public void updateForwardMain(ForwardMainVO forwardMainVO) {
		
		TcForwardMainDO forwardMainDO = new TcForwardMainDO();
		LsBeanUtils.copyAllProperties(forwardMainVO, forwardMainDO);
		forwardMainDao.updateByPrimaryKeySelective(forwardMainDO);
		
	}

	/** 
	 * @Title: deleteForwardMain 
	 * @Description: 根据前传规则编号删除数据记录
	 * @param forwardNo
	 * @return void
	 * @throws 
	 */
	public void deleteForwardMain(String forwardNo) {
		
		forwardMainDao.deleteByPrimaryKey(forwardNo);
	}

	/** 
	 * @Title: forwardMainPageList 
	 * @Description: 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @param forwardMainVO
	 * @return PageInfo<ForwardMainVO>
	 * @throws 
	 */
	public PageInfo<ForwardMainVO> forwardMainPageList(Integer pageNum, Integer pageSize, ForwardMainVO forwardMainVO) {

		PageInfo<ForwardMainVO> voPageInfo = new PageInfo<>();
		
		PageHelper.startPage(pageNum, pageSize);
		List<TcForwardMainDO> doList = forwardMainDao.selectFofwardList(forwardMainVO);
		PageInfo<TcForwardMainDO> doPageInfo = new PageInfo<>(doList);
		
		LsBeanUtils.copyAllProperties(doPageInfo, voPageInfo);
		return voPageInfo;
	}

	/** 
	 * @Title: saveForwardPeople 
	 * @Description: 前传人员信息新增
	 * @param forwardPeopleVO
	 * @return String
	 * @throws 
	 */
	public String saveForwardPeople(ForwardPeopleVO forwardPeopleVO) {
		
		TcForwardPeopleDO forwardPeopleDO = new TcForwardPeopleDO();
		LsBeanUtils.copyAllProperties(forwardPeopleVO, forwardPeopleDO);
		forwardPeopleDao.insertSelective(forwardPeopleDO);
		return forwardPeopleDO.getForwardPeopleNo();
	}

	/** 
	 * @Title: updateForwardPeople 
	 * @Description: 前传人员信息修改
	 * @param forwardPeopleVO
	 * @return void
	 * @throws 
	 */
	public void updateForwardPeople(ForwardPeopleVO forwardPeopleVO) {
		
		TcForwardPeopleDO forwardPeopleDO = new TcForwardPeopleDO();
		LsBeanUtils.copyAllProperties(forwardPeopleVO, forwardPeopleDO);
		forwardPeopleDao.updateByPrimaryKeySelective(forwardPeopleDO);
	}
}
