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

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

/**
 * 同步库工料机 Mapper
 *
 * @author yhy
 */
@Mapper
public interface SyncLibraryResourceMapper extends BaseMapperX<SyncLibraryResourceDO> {

    /**
     * 根据同步库分部分项ID查询工料机列表
     */
    default List<SyncLibraryResourceDO> selectListBySyncDivisionId(Long syncDivisionId) {
        return selectList(new LambdaQueryWrapperX<SyncLibraryResourceDO>()
                .eq(SyncLibraryResourceDO::getSyncDivisionId, syncDivisionId)
                .orderByAsc(SyncLibraryResourceDO::getSortOrder));
    }

    /**
     * 根据同步库分部分项ID列表批量查询
     */
    default List<SyncLibraryResourceDO> selectListBySyncDivisionIds(List<Long> syncDivisionIds) {
        return selectList(new LambdaQueryWrapperX<SyncLibraryResourceDO>()
                .in(SyncLibraryResourceDO::getSyncDivisionId, syncDivisionIds)
                .orderByAsc(SyncLibraryResourceDO::getSortOrder));
    }

    /**
     * 根据同步库分部分项ID删除
     */
    default int deleteBySyncDivisionId(Long syncDivisionId) {
        return delete(new LambdaQueryWrapperX<SyncLibraryResourceDO>()
                .eq(SyncLibraryResourceDO::getSyncDivisionId, syncDivisionId));
    }

    /**
     * 根据同步库分部分项ID列表批量删除
     */
    default int deleteBySyncDivisionIds(List<Long> syncDivisionIds) {
        return delete(new LambdaQueryWrapperX<SyncLibraryResourceDO>()
                .in(SyncLibraryResourceDO::getSyncDivisionId, syncDivisionIds));
    }
}
