package com.yc.ship.module.resource.dal.mysql.drivergroup;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.resource.controller.admin.drivergroup.vo.DriverGroupPageReqVO;
import com.yc.ship.module.resource.controller.admin.vo.SimpleListReqVO;
import com.yc.ship.module.resource.dal.dataobject.drivergroup.DriverGroupDO;
import com.yc.ship.module.resource.enums.CommonStatusEnum;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 驾驶员分组 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface DriverGroupMapper extends BaseMapperX<DriverGroupDO> {

    default PageResult<DriverGroupDO> selectPage(DriverGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DriverGroupDO>()
                .likeIfPresent(DriverGroupDO::getName, reqVO.getName())
                .eqIfPresent(DriverGroupDO::getParentId, reqVO.getParentId())
                .eqIfPresent(DriverGroupDO::getGroupCode, reqVO.getGroupCode())
                .eqIfPresent(DriverGroupDO::getSort, reqVO.getSort())
                .betweenIfPresent(DriverGroupDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DriverGroupDO::getId));
    }

    default List<DriverGroupDO> selectList(SimpleListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DriverGroupDO>()
                .likeIfPresent(DriverGroupDO::getName, reqVO.getName())
                .eqIfPresent(DriverGroupDO::getDeleted, CommonStatusEnum.ENABLE.getStatus())
                .eqIfPresent(DriverGroupDO::getTenantId, reqVO.getTenantId())
                .orderByAsc(DriverGroupDO::getSort));
    }

}