package com.unis.base.server.domain;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.NatureTransVo;
import com.unis.base.common.vo.ProfitVO;
import com.unis.base.server.dao.NatureTransDao;
import com.unis.base.server.entity.DCxxsjDo;
import com.unis.base.server.entity.XZzbDo;
import com.unis.common.utils.LsBeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import tk.mybatis.mapper.util.StringUtil;

import java.util.List;

/**
 * @author ceshi
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${}
 * @date 2019/10/3121:05
 */
@Component
public class NatureTransDomain extends BaseDomain{
    @Autowired
    private NatureTransDao natureTransDao;


    public PageInfo<NatureTransVo> getPageList(NatureTransVo natureTransVo, Integer pageNum, Integer pageSize) {
        PageInfo<NatureTransVo> pageInfoVO = new PageInfo<NatureTransVo>();
        PageHelper.startPage(pageNum, pageSize);
        List<XZzbDo> profitDOs =  natureTransDao.findPageList(natureTransVo);
        PageInfo<XZzbDo> PageInfoDO = new PageInfo<XZzbDo>(profitDOs);
        LsBeanUtils.copyAllProperties(PageInfoDO,pageInfoVO);
        return pageInfoVO ;
    }

    public int deleteNatureTrans(String xzzbdbh) {
        return natureTransDao.deleteByPrimaryKey(xzzbdbh);
    }

    public int infoNatureTrans(NatureTransVo natureTransVo) {
        XZzbDo s0 = new XZzbDo();
        LsBeanUtils.copyAllProperties(natureTransVo,s0);
        int pro = 0;
        if(StringUtil.isEmpty(s0.getXzzbdbh())) {
            pro = natureTransDao.insertSelective(s0);
        }else {
            pro =  natureTransDao.updateByPrimaryKey(s0);
        }
        return pro;
    }
}
