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

import cn.iocoder.lyzsys.framework.common.pojo.PageResult;
import cn.iocoder.lyzsys.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.lyzsys.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.lyzsys.module.tjt.controller.admin.planning.vo.ProjectPlanningPageReqVO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.planning.ProjectPlanningDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 合约规划 Mapper
 *
 * @author Codex
 */
@Mapper
public interface ProjectPlanningMapper extends BaseMapperX<ProjectPlanningDO> {

    default PageResult<ProjectPlanningDO> selectPage(ProjectPlanningPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProjectPlanningDO>()
                .eqIfPresent(ProjectPlanningDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(ProjectPlanningDO::getOwnershipType, reqVO.getOwnershipType())
                .eqIfPresent(ProjectPlanningDO::getCalculationMethod, reqVO.getCalculationMethod())
                .likeIfPresent(ProjectPlanningDO::getPlanningContent, reqVO.getPlanningContent())
                .eqIfPresent(ProjectPlanningDO::getPlanningStartYear, reqVO.getPlanningStartYear())
                .betweenIfPresent(ProjectPlanningDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(ProjectPlanningDO::getSortNo)
                .orderByAsc(ProjectPlanningDO::getId));
    }

    default List<ProjectPlanningDO> selectListByProjectId(Long projectId) {
        return selectList(new LambdaQueryWrapperX<ProjectPlanningDO>()
                .eq(ProjectPlanningDO::getProjectId, projectId)
                .orderByDesc(ProjectPlanningDO::getId));
    }

    default List<ProjectPlanningDO> selectDisplayListByProjectId(Long projectId) {
        return selectList(new LambdaQueryWrapperX<ProjectPlanningDO>()
                .eq(ProjectPlanningDO::getProjectId, projectId)
                .orderByAsc(ProjectPlanningDO::getSortNo)
                .orderByAsc(ProjectPlanningDO::getId));
    }

}
