package com.hys.app.mapper.erp;

import com.hys.app.framework.database.mybatisplus.base.BaseMapperX;
import com.hys.app.model.erp.dos.WarehouseEntryProductDO;
import com.hys.app.model.erp.dto.WarehouseEntryProductQueryParams;
import com.hys.app.framework.database.WebPage;
import com.hys.app.model.erp.dto.WarehouseInQueryParams;
import com.hys.app.model.erp.vo.WarehouseEntryItemV1;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 入库单商品明细的Mapper
 *
 * @author 张崧
 * @since 2023-12-05 15:30:10
 */
public interface WarehouseEntryProductMapper extends BaseMapperX<WarehouseEntryProductDO> {

    default WebPage<WarehouseEntryProductDO> selectPage(WarehouseEntryProductQueryParams params) {
        return lambdaQuery()
                .eqIfPresent(WarehouseEntryProductDO::getWarehouseEntryId, params.getWarehouseEntryId())
                .likeIfPresent(WarehouseEntryProductDO::getSn, params.getSn())
                .likeIfPresent(WarehouseEntryProductDO::getName, params.getName())
                .likeIfPresent(WarehouseEntryProductDO::getSpecification, params.getSpecification())
                .likeIfPresent(WarehouseEntryProductDO::getBrand, params.getBrand())
                .likeIfPresent(WarehouseEntryProductDO::getUnit, params.getUnit())
                .eqIfPresent(WarehouseEntryProductDO::getContractNum, params.getContractNum())
                .eqIfPresent(WarehouseEntryProductDO::getNum, params.getNum())
                .orderByDesc(WarehouseEntryProductDO::getId)
                .page(params);
    }



    List<WarehouseEntryItemV1> queryList(@Param("request") WarehouseInQueryParams request);

    Long selectCount(@Param("request") WarehouseInQueryParams request);

}

