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.position.PositionPageReqVO;
import com.lideeyunji.service.system.entity.PositionDO;
import org.apache.ibatis.annotations.Mapper;

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

@Mapper
public interface PositionMapper extends BaseMapperX<PositionDO> {

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

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

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



}
