package cn.iocoder.yudao.module.smartfactory.dal.mysql.staff;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffPageReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 员工 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface StaffMapper extends BaseMapperX<StaffDO> {

    default PageResult<StaffDO> selectPage(StaffPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StaffDO>()
                .eqIfPresent(StaffDO::getStaffNo, reqVO.getStaffNo())
                .eqIfPresent(StaffDO::getAge, reqVO.getAge())
                .eqIfPresent(StaffDO::getPostId, reqVO.getPostId())
                .eqIfPresent(StaffDO::getWorkTypeId, reqVO.getWorkTypeId())
                .eqIfPresent(StaffDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(StaffDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StaffDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StaffDO::getId));
    }

    /**
     * 通过工厂id获取员工信息
     *
     * @param factoryId
     * @return
     */
    List<StaffDO> getStaffData(@Param("factoryId") Long factoryId);
}