package cn.iocoder.yudao.module.system.dal.mysql.assets;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.assets.vo.DeptAssetsInOutStockPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.assets.vo.DeptAssetsInOutStockRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.assets.DeptAssetsInOutStockDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 部门资产出入库 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface DeptAssetsInOutStockMapper extends BaseMapperX<DeptAssetsInOutStockDO> {

    default PageResult<DeptAssetsInOutStockDO> selectPage(DeptAssetsInOutStockPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeptAssetsInOutStockDO>()
                .eqIfPresent(DeptAssetsInOutStockDO::getInDeptId, reqVO.getInDeptId())
                .eqIfPresent(DeptAssetsInOutStockDO::getOutDeptId, reqVO.getOutDeptId())
                .eqIfPresent(DeptAssetsInOutStockDO::getAssetsId, reqVO.getAssetsId())
                .eqIfPresent(DeptAssetsInOutStockDO::getNum, reqVO.getNum())
                .eqIfPresent(DeptAssetsInOutStockDO::getInOutNo, reqVO.getInOutNo())
                .betweenIfPresent(DeptAssetsInOutStockDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeptAssetsInOutStockDO::getId));
    }

    /**
     * 合并部门资产出库入库
     *
     * @param deptId
     * @param assetsId
     * @return
     */
    List<DeptAssetsInOutStockDO> unionAllInOutStockByAssetsId(@Param("deptId") Long deptId, @Param("assetsId") Long assetsId);


    IPage<DeptAssetsInOutStockRespVO> getDeptAssetsInOutStockPage(@Param("vo") DeptAssetsInOutStockPageReqVO pageReqVO, @Param("page") Page page);
}