package com.unis.base.server.service.impl;
import java.util.List;

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

import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.TyCrkxxPageVO;
import com.unis.base.common.vo.TyCrkxxVO;
import com.unis.base.server.domain.TyCrkxxDomain;
import com.unis.base.server.service.TyCrkxxService;
import com.unis.common.utils.DateUtil;
/**
 * @author huangxing
 * @version 1.0
 * @Title TyCrkjsxxServiceImpl
 * @ProjectName TyCrkjsxxServiceImpl
 * @Description
 * @date 2019/07/22 17点26分
 */
@Service
public class TyCrkxxServiceImpl implements TyCrkxxService {

	@Autowired
	private TyCrkxxDomain tyCrkxxDomain;

	/**
	 * 获取信息列表
	 * @param dKdxxsjyVO
	 * @return
	 */
	@Override
	public List<TyCrkxxVO> getTyCrkxxList(TyCrkxxVO tyCrkxxVO) {
		return tyCrkxxDomain.getTyCrkxxList(tyCrkxxVO);
	}

	/**
	 * 分页展示
	 * @param tyCrkxxVO
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@Override
	public PageInfo<TyCrkxxVO> getTyCrkxxPage(TyCrkxxVO tyCrkxxVO, Integer pageNum, Integer pageSize) {
		return tyCrkxxDomain.getTyCrkxxListPage(tyCrkxxVO,pageNum,pageSize);
	}

	/**
	 * 新增信息
	 * @param TyCrkxxVO
	 * @return
	 */
	@Override
	public int insert(TyCrkxxVO tyCrkxxVO) {
		String date = DateUtil.getCurrentDateTime16Str();
		String currentStringTimestamp = DateUtil.getCurrentStringTimestamp();
		tyCrkxxVO.setCrkid("CR"+date);
		tyCrkxxVO.setCrkdh(currentStringTimestamp);
		return tyCrkxxDomain.insert(tyCrkxxVO);
	}

	/**
	 * 更新信息
	 * @param dAjxxsjyVO
	 * @return
	 */
	@Override
	public int update(TyCrkxxVO tyCrkxxVO) {
		return tyCrkxxDomain.update(tyCrkxxVO);
	}

	/**
	 * 删除信息
	 * @author huangxing
	 * @param dAjxxsjyVO
	 * @return
	 */
	@Override
	public int delete(String crkid) {
		//根据编号获取廒间信息
		TyCrkxxVO tyCrkjsxxVO = tyCrkxxDomain.getTyCrkxxById(crkid);
		if(tyCrkjsxxVO == null) {
			return -1;
		}
		tyCrkjsxxVO.setStatus(0);
		return tyCrkxxDomain.update(tyCrkjsxxVO);
	}

	/**
	 * 根据编号获取信息
	 * @param ajbh
	 * @return 廒间信息
	 */
	@Override
	public TyCrkxxVO getTyCrkxxByCrkid(String crkid) {
		return tyCrkxxDomain.getTyCrkxxById(crkid);
	}


	/**
	 * 分页展示
	 * @param tyCrkxxVO
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@Override
	public PageInfo<TyCrkxxPageVO> getTyCrkxxPageExtend(TyCrkxxPageVO tyCrkxxVO, Integer pageNum, Integer pageSize) {
		return tyCrkxxDomain.getTyCrkxxListPageExtend(tyCrkxxVO, pageNum, pageSize);
	}
}
