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.TyLqxxVO;
import com.unis.base.server.domain.TyLqxxDomain;
import com.unis.base.server.service.TyLqxxService;
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 TyLqxxServiceImpl implements TyLqxxService {

	@Autowired
	private TyLqxxDomain tyLqxxDomain;

	/**
	 * 获取信息
	 */
	@Override
	public List<TyLqxxVO> getTyLqxxList(TyLqxxVO tyLqxxVO) {
		return tyLqxxDomain.getTyLqxxList(tyLqxxVO);
	}

	/**
	 * 分页展示
	 */
	@Override
	public List<TyLqxxVO> getTyLqxxPage(TyLqxxVO tyLqxxVO, Integer pageNum, Integer pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		return tyLqxxDomain.getTyLqxxList(tyLqxxVO);
	}

	/**
	 * 添加
	 */
	@Override
	public int insert(TyLqxxVO tyLqxxVO) {
		String date = DateUtil.getCurrentDateTime16Str();
		tyLqxxVO.setLqid("LQ"+date);
		return tyLqxxDomain.insert(tyLqxxVO);
	}

	/**
	 * 更新信息
	 */
	@Override
	public int update(TyLqxxVO tyLqxxVO) {
		return tyLqxxDomain.update(tyLqxxVO);
	}

	/**
	 * 删除
	 */
	@Override
	public int delete(String lqid) {
		TyLqxxVO tyLqxxVO = tyLqxxDomain.getTyLqxxById(lqid);
		if (tyLqxxVO == null) {
			return -1;
		}
		tyLqxxVO.setStatus(0);
		return tyLqxxDomain.update(tyLqxxVO);
	}

	/**
	 * 根据编号获取信息
	 */
	@Override
	public TyLqxxVO getLqxxByLqxxid(String lqid) {
		return tyLqxxDomain.getTyLqxxById(lqid);
	}


}
