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

import java.util.List;

/**
 * 定额调整设置 Mapper
 */
@Mapper
public interface QuotaAdjustmentMapper extends BaseMapperX<QuotaAdjustmentDO> {

    default List<QuotaAdjustmentDO> selectListByQuotaItemId(Long quotaItemId) {
        return selectList(new LambdaQueryWrapperX<QuotaAdjustmentDO>()
                .eq(QuotaAdjustmentDO::getQuotaItemId, quotaItemId)
                .orderByAsc(QuotaAdjustmentDO::getSortOrder));
    }

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