liyong
8 天以前 1ab2b329a40decba8ff7eefbeb158ff259aceb6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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);
    }
 
}