package cn.iocoder.lyzsys.module.tjt.dal.mysql.planningguidedetail;

import cn.iocoder.lyzsys.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.lyzsys.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planningguidedetail.ProjectPlanningGuideDetailDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

@Mapper
public interface ProjectPlanningGuideDetailMapper extends BaseMapperX<ProjectPlanningGuideDetailDO> {

    default List<ProjectPlanningGuideDetailDO> selectListByPlanningId(Long planningId) {
        return selectList(new LambdaQueryWrapperX<ProjectPlanningGuideDetailDO>()
                .eq(ProjectPlanningGuideDetailDO::getPlanningId, planningId)
                .orderByAsc(ProjectPlanningGuideDetailDO::getSortNo)
                .orderByAsc(ProjectPlanningGuideDetailDO::getId));
    }

    default List<ProjectPlanningGuideDetailDO> selectListByPlanningIds(Collection<Long> planningIds) {
        if (planningIds == null || planningIds.isEmpty()) {
            return Collections.emptyList();
        }
        return selectList(new LambdaQueryWrapperX<ProjectPlanningGuideDetailDO>()
                .in(ProjectPlanningGuideDetailDO::getPlanningId, planningIds)
                .orderByAsc(ProjectPlanningGuideDetailDO::getPlanningId)
                .orderByAsc(ProjectPlanningGuideDetailDO::getSortNo)
                .orderByAsc(ProjectPlanningGuideDetailDO::getId));
    }

}
