package com.unis.base.server.domain;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.ProfitVO;
import com.unis.base.common.vo.ReversePositionVo;
import com.unis.base.server.dao.ReversePositionDao;
import com.unis.base.server.entity.DCxxsjDo;
import com.unis.base.server.entity.SYdsjDO;
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/3119:55
 */
@Component
public class ReversePositionDomain extends BaseDomain{
    @Autowired
    private ReversePositionDao reversePositionDao;

    public PageInfo<ReversePositionVo> getPageList(ReversePositionVo reversePositionVo, Integer pageNum, Integer pageSize) {
        PageInfo<ReversePositionVo> pageInfoVO = new PageInfo<ReversePositionVo>();
        PageHelper.startPage(pageNum, pageSize);
        List<DCxxsjDo> profitDOs =  reversePositionDao.findPageList(reversePositionVo);
        PageInfo<DCxxsjDo> PageInfoDO = new PageInfo<DCxxsjDo>(profitDOs);
        LsBeanUtils.copyAllProperties(PageInfoDO,pageInfoVO);
        return pageInfoVO ;
    }
    /**
     * @Title: deleteProfit
     * @Description:方法描述:(通过编号删除)
     * @param @param sybh
     * @param @return    设定文件
     * @return int    返回类型
     * @throws
     */
    public int deleteProfit(String dcdbm) {
        return reversePositionDao.deleteByPrimaryKey(dcdbm);
    }
    /**
     * @Title: infoProfit
     * @Description:ror方法描述:(数据录入)
     * @param @param profitVO
     * @param @return    设定文件
     * @return int    返回类型
     * @throws
     */
    public int infoProfit(ReversePositionVo reversePositionVo) {
        DCxxsjDo s0 = new DCxxsjDo();
        LsBeanUtils.copyAllProperties(reversePositionVo,s0);
        int pro = 0;
        if(StringUtil.isEmpty(s0.getDcdbm())) {
            pro = reversePositionDao.insertSelective(s0);
        }else {
            pro =  reversePositionDao.updateByPrimaryKey(s0);
        }
        return pro;
    }
}
