liyong
8 天以前 be153de6203cf3c1f3b8bb3a38d8d23baea797fb
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,84 @@
package cn.iocoder.yudao.module.mdm.dal.mysql.item;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemPageReqVO;
import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
/**
 * MDM ç‰©æ–™ä¸»æ•°æ® Mapper
 *
 * @author èŠ‹é“æºç 
 */
@Mapper
public interface MdmItemMapper extends BaseMapperX<MdmItemDO> {
    default PageResult<MdmItemDO> selectPage(MdmItemPageReqVO reqVO, Collection<Long> categoryIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MdmItemDO>()
                .likeIfPresent(MdmItemDO::getCode, reqVO.getCode())
                .likeIfPresent(MdmItemDO::getName, reqVO.getName())
                .likeIfPresent(MdmItemDO::getBarCode, reqVO.getBarCode())
                .inIfPresent(MdmItemDO::getCategoryId, categoryIds)
                .eqIfPresent(MdmItemDO::getItemType, reqVO.getItemType())
                .eqIfPresent(MdmItemDO::getBrandId, reqVO.getBrandId())
                .eqIfPresent(MdmItemDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MdmItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MdmItemDO::getId));
    }
    default List<MdmItemDO> selectList(MdmItemPageReqVO reqVO, Collection<Long> categoryIds) {
        return selectList(new LambdaQueryWrapperX<MdmItemDO>()
                .likeIfPresent(MdmItemDO::getCode, reqVO.getCode())
                .likeIfPresent(MdmItemDO::getName, reqVO.getName())
                .inIfPresent(MdmItemDO::getCategoryId, categoryIds)
                .eqIfPresent(MdmItemDO::getItemType, reqVO.getItemType())
                .eqIfPresent(MdmItemDO::getStatus, reqVO.getStatus())
                .orderByDesc(MdmItemDO::getId));
    }
    default MdmItemDO selectByCode(String code) {
        return selectOne(MdmItemDO::getCode, code);
    }
    /**
     * æ ¹æ®ç¼–码和删除状态查询物料(用于解决软删除唯一键冲突)
     */
    default MdmItemDO selectByCodeAndDeleted(String code, Boolean deleted) {
        return selectOne(new LambdaQueryWrapperX<MdmItemDO>()
                .eq(MdmItemDO::getCode, code)
                .eq(MdmItemDO::getDeleted, deleted));
    }
    /**
     * ç‰©ç†åˆ é™¤ï¼ˆç”¨äºŽæ¸…理已软删除的重复记录)
     * æ³¨æ„ï¼šç”±äºŽ BaseDO æœ‰ @TableLogic,deleteById æ˜¯è½¯åˆ é™¤ï¼Œéœ€è¦ä½¿ç”¨åŽŸç”Ÿ SQL
     */
    @org.apache.ibatis.annotations.Delete("DELETE FROM mdm_item WHERE id = #{id}")
    void physicalDeleteById(Long id);
    default MdmItemDO selectByBarCode(String barCode) {
        return selectOne(MdmItemDO::getBarCode, barCode);
    }
    default Long selectCountByCategoryId(Long categoryId) {
        return selectCount(MdmItemDO::getCategoryId, categoryId);
    }
    default Long selectCountByUnitMeasureId(Long unitMeasureId) {
        return selectCount(MdmItemDO::getUnitMeasureId, unitMeasureId);
    }
    default Long selectCountByBrandId(Long brandId) {
        return selectCount(MdmItemDO::getBrandId, brandId);
    }
    default List<MdmItemDO> selectListByIds(Collection<Long> ids) {
        return selectList(MdmItemDO::getId, ids);
    }
}