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

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.quota.QuotaAdjustmentSettingDO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;

/**
 * 定额调整设置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface QuotaAdjustmentSettingMapper extends BaseMapperX<QuotaAdjustmentSettingDO> {

    default List<QuotaAdjustmentSettingDO> selectListByQuotaItemId(Long quotaItemId) {
        return selectList(new LambdaQueryWrapperX<QuotaAdjustmentSettingDO>()
                .eq(QuotaAdjustmentSettingDO::getQuotaItemId, quotaItemId)
                .orderByAsc(QuotaAdjustmentSettingDO::getSortOrder)
                .orderByAsc(QuotaAdjustmentSettingDO::getId)); // 次要排序：按ID（创建顺序）
    }

    default QuotaAdjustmentSettingDO selectByIdForUpdate(Long id) {
        return selectOne(new LambdaQueryWrapperX<QuotaAdjustmentSettingDO>()
                .eq(QuotaAdjustmentSettingDO::getId, id)
                .last("FOR UPDATE"));
    }

}
