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

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

/**
 * 工程费率设定 Mapper
 */
@Mapper
public interface WbUnitRateSettingMapper extends BaseMapperX<WbUnitRateSettingDO> {

    /**
     * 根据单位工程ID查询费率设定列表
     */
    default List<WbUnitRateSettingDO> selectByUnitId(Long unitId) {
        return selectList(new LambdaQueryWrapperX<WbUnitRateSettingDO>()
                .eq(WbUnitRateSettingDO::getUnitId, unitId));
    }

    /**
     * 根据单位工程ID和费率项ID查询费率设定
     */
    default WbUnitRateSettingDO selectByUnitIdAndRateItemId(Long unitId, Long rateItemId) {
        return selectOne(new LambdaQueryWrapperX<WbUnitRateSettingDO>()
                .eq(WbUnitRateSettingDO::getUnitId, unitId)
                .eq(WbUnitRateSettingDO::getRateItemId, rateItemId));
    }

    /**
     * 删除单位工程的所有费率设定
     */
    default int deleteByUnitId(Long unitId) {
        return delete(new LambdaQueryWrapperX<WbUnitRateSettingDO>()
                .eq(WbUnitRateSettingDO::getUnitId, unitId));
    }
}
