package com.zt.plat.module.base.dal.dao.quantityUnitRelation;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationPageReqVO;
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationSimplePageReqVO;
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 计量单位量与单位关联 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface QuantityUnitRelationMapper extends BaseMapperX<QuantityUnitRelationDO> {

    default PageResult<QuantityUnitRelationDO> selectPage(QuantityUnitRelationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<QuantityUnitRelationDO>()
                .eqIfPresent(QuantityUnitRelationDO::getUntQtyId, reqVO.getUntQtyId())
                .eqIfPresent(QuantityUnitRelationDO::getIsBse, reqVO.getIsBse())
                .orderByDesc(QuantityUnitRelationDO::getUntQtyId));
    }

    default PageResult<QuantityUnitRelationDO> selectSimplePage(QuantityUnitRelationSimplePageReqVO reqVO, LambdaQueryWrapperX<QuantityUnitRelationDO> wrapper) {
        return BaseMapperX.super.selectPage(reqVO, wrapper);
    }

    /**
     * 根据量纲ID查询所有关联关系
     *
     * @param untQtyId 量纲ID
     * @return 关联关系列表
     */
    default List<QuantityUnitRelationDO> selectListByUntQtyId(Long untQtyId) {
        return selectList(new LambdaQueryWrapperX<QuantityUnitRelationDO>()
                .eq(QuantityUnitRelationDO::getUntQtyId, untQtyId));
    }

}