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.PageHelper;
import com.unis.base.common.vo.TyLhtzdVO;
import com.unis.base.server.domain.TyLhtzdDomain;
import com.unis.base.server.service.TyLhtzdService;
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 TyLhtzdServiceImpl implements TyLhtzdService {

	@Autowired
	private TyLhtzdDomain tyLhtzdDomain;

	/**
	 * 获取信息
	 */
	@Override
	public List<TyLhtzdVO> getTyLhtzdList(TyLhtzdVO tyLhtzdVO) {
		return tyLhtzdDomain.getTyLhtzdList(tyLhtzdVO);
	}

	/**
	 * 分页展示
	 */
	@Override
	public List<TyLhtzdVO> getTyLhtzdPage(TyLhtzdVO tyLhtzdVO, Integer pageNum, Integer pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		return tyLhtzdDomain.getTyLhtzdList(tyLhtzdVO);
	}

	/**
	 * 添加
	 */
	@Override
	public int insert(TyLhtzdVO tyLhtzdVO) {
		String date = DateUtil.getCurrentDateTime16Str();
		String currentStringTimestamp = DateUtil.getCurrentStringTimestamp();
		tyLhtzdVO.setTzdid("TZ"+date);
		tyLhtzdVO.setTzdh(currentStringTimestamp);
		return tyLhtzdDomain.insert(tyLhtzdVO);
	}

	/**
	 * 更新信息
	 */
	@Override
	public int update(TyLhtzdVO tyLhtzdVO) {
		return tyLhtzdDomain.update(tyLhtzdVO);
	}

	/**
	 * 删除
	 */
	@Override
	public int delete(String tzdid) {
		TyLhtzdVO tyLhtzdVO = tyLhtzdDomain.getTyLhtzdById(tzdid);
		if (tyLhtzdVO == null ) {
			return -1;
		}
		return tyLhtzdDomain.update(tyLhtzdVO);
	}

	/**
	 * 根据编号获取信息
	 */
	@Override
	public TyLhtzdVO getLhtzdByLhtzdid(String tzdid) {
		return tyLhtzdDomain.getTyLhtzdById(tzdid);
	}


}
