package com.lideeyunji.service.system.mapper;

import com.lideeyunji.tool.framework.common.pojo.PageResult;
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.lideeyunji.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.lideeyunji.service.system.controller.vo.dept.rank.RankPageReqVO;
import com.lideeyunji.service.system.entity.RankDO;
import org.apache.ibatis.annotations.Mapper;

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

@Mapper
public interface RankMapper extends BaseMapperX<RankDO> {

    default List<RankDO> selectList(Collection<Long> ids, Collection<Integer> statuses) {
        return selectList(new LambdaQueryWrapperX<RankDO>()
                .inIfPresent(RankDO::getId, ids)
                .inIfPresent(RankDO::getStatus, statuses));
    }

    default PageResult<RankDO> selectPage(RankPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RankDO>()
                .likeIfPresent(RankDO::getName, reqVO.getName())
                .eqIfPresent(RankDO::getStatus, reqVO.getStatus())
                .orderByDesc(RankDO::getId));
    }

    default RankDO selectByName(String name) {
        return selectOne(RankDO::getName, name);
    }



}
