package com.yhy.module.core.dal.mysql.workbench;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.yhy.module.core.dal.dataobject.workbench.WbResourceSummaryDO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 工料机汇总 Mapper
 *
 * @author yhy
 */
@Mapper
public interface WbResourceSummaryMapper extends BaseMapperX<WbResourceSummaryDO> {

    /**
     * 根据项目ID和资源唯一键查询
     */
    default WbResourceSummaryDO selectByProjectIdAndResourceKey(Long projectId, String resourceKey) {
        return selectOne(WbResourceSummaryDO::getProjectId, projectId,
                WbResourceSummaryDO::getResourceKey, resourceKey);
    }

    /**
     * 根据项目ID查询所有汇总记录
     */
    default List<WbResourceSummaryDO> selectListByProjectId(Long projectId) {
        return selectList(WbResourceSummaryDO::getProjectId, projectId);
    }

    /**
     * 根据项目ID查询评标指定材料
     */
    default List<WbResourceSummaryDO> selectBidMaterialsByProjectId(Long projectId) {
        return selectList(WbResourceSummaryDO::getProjectId, projectId,
                WbResourceSummaryDO::getIsBidMaterial, 1);
    }
}
