package com.jeelowcode.service.system.mapper;

import com.jeelowcode.tool.framework.common.pojo.PageResult;
import com.jeelowcode.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.jeelowcode.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jeelowcode.service.system.controller.vo.dept.duty.DutyPageReqVO;
import com.jeelowcode.service.system.entity.DutyDO;
import org.apache.ibatis.annotations.Mapper;

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

@Mapper
public interface DutyMapper extends BaseMapperX<DutyDO> {

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

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

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



}
