package cn.iocoder.lyzsys.module.demo.dal.mysql.project;

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.demo.controller.admin.project.vo.ProjectPageReqVO;
import cn.iocoder.lyzsys.module.demo.dal.dataobject.project.ProjectDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 项目管理 Mapper
 *
 * @author lyzsys
 */
@Mapper
public interface ProjectMapper extends BaseMapperX<ProjectDO> {

    default PageResult<ProjectDO> selectPage(ProjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProjectDO>()
                .likeIfPresent(ProjectDO::getProjectName, reqVO.getProjectName())
                .likeIfPresent(ProjectDO::getProjectCode, reqVO.getProjectCode())
                .betweenIfPresent(ProjectDO::getEstablishDate, reqVO.getEstablishDate())
                .orderByDesc(ProjectDO::getId));
    }

    default ProjectDO selectByProjectCode(String projectCode) {
        return selectOne(ProjectDO::getProjectCode, projectCode);
    }

}
