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

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.office.vo.OfficePageReqVO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.office.OfficeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface OfficeMapper extends BaseMapperX<OfficeDO> {

    default PageResult<OfficeDO> selectPage(OfficePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OfficeDO>()
                .likeIfPresent(OfficeDO::getOfficeName, reqVO.getOfficeName())
                .eqIfPresent(OfficeDO::getEnabledFlag, reqVO.getEnabledFlag())
                .orderByAsc(OfficeDO::getSortNo)
                .orderByAsc(OfficeDO::getId));
    }

    default List<OfficeDO> selectSimpleList() {
        return selectList(new LambdaQueryWrapperX<OfficeDO>()
                .eq(OfficeDO::getEnabledFlag, Boolean.TRUE)
                .orderByAsc(OfficeDO::getSortNo)
                .orderByAsc(OfficeDO::getId));
    }

}
