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.WbRateFieldLabelDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工作台费率字段标签快照 Mapper
 *
 * @author yhy
 */
@Mapper
public interface WbRateFieldLabelMapper extends BaseMapperX<WbRateFieldLabelDO> {

    /**
     * 根据单位工程ID查询字段标签
     */
    default List<WbRateFieldLabelDO> selectByCompileTreeId(Long compileTreeId) {
        return selectList(new LambdaQueryWrapperX<WbRateFieldLabelDO>()
                .eq(WbRateFieldLabelDO::getCompileTreeId, compileTreeId)
                .orderByAsc(WbRateFieldLabelDO::getSortOrder));
    }

    /**
     * 根据单位工程ID和费率模式ID查询字段标签
     */
    default List<WbRateFieldLabelDO> selectByCompileTreeIdAndCatalogItemId(Long compileTreeId, Long catalogItemId) {
        return selectList(new LambdaQueryWrapperX<WbRateFieldLabelDO>()
                .eq(WbRateFieldLabelDO::getCompileTreeId, compileTreeId)
                .eq(WbRateFieldLabelDO::getCatalogItemId, catalogItemId)
                .orderByAsc(WbRateFieldLabelDO::getSortOrder));
    }

    /**
     * 根据单位工程ID删除
     */
    default int deleteByCompileTreeId(Long compileTreeId) {
        return delete(new LambdaQueryWrapperX<WbRateFieldLabelDO>()
                .eq(WbRateFieldLabelDO::getCompileTreeId, compileTreeId));
    }

    /**
     * 根据单位工程ID和费率模式ID删除
     */
    default int deleteByCompileTreeIdAndCatalogItemId(Long compileTreeId, Long catalogItemId) {
        return delete(new LambdaQueryWrapperX<WbRateFieldLabelDO>()
                .eq(WbRateFieldLabelDO::getCompileTreeId, compileTreeId)
                .eq(WbRateFieldLabelDO::getCatalogItemId, catalogItemId));
    }
}
