package org.agt.module.license.dal.mysql.license;

import java.util.*;

import org.agt.framework.common.pojo.PageResult;
import org.agt.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.agt.framework.mybatis.core.mapper.BaseMapperX;
import org.agt.module.license.dal.dataobject.license.LicenseDO;
import org.apache.ibatis.annotations.Mapper;
import org.agt.module.license.controller.admin.license.vo.*;

/**
 * License Mapper
 *
 * @author 管理员
 */
@Mapper
public interface LicenseMapper extends BaseMapperX<LicenseDO> {

    default PageResult<LicenseDO> selectPage(LicensePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LicenseDO>()
                .eqIfPresent(LicenseDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(LicenseDO::getProjectId, reqVO.getProjectId())
                .likeIfPresent(LicenseDO::getSn, reqVO.getSn())
                .betweenIfPresent(LicenseDO::getExpirationTime, reqVO.getExpirationTime())
                .eqIfPresent(LicenseDO::getNeSwitch, reqVO.getNeSwitch())
                .eqIfPresent(LicenseDO::getUserNum, reqVO.getUserNum())
                .eqIfPresent(LicenseDO::getBaseStationNum, reqVO.getBaseStationNum())
                .eqIfPresent(LicenseDO::getActivationCode, reqVO.getActivationCode())
                .eqIfPresent(LicenseDO::getLicenseContent, reqVO.getLicenseContent())
                .eqIfPresent(LicenseDO::getApplicant, reqVO.getApplicant())
                .eqIfPresent(LicenseDO::getApprover, reqVO.getApprover())
                .eqIfPresent(LicenseDO::getStatus, reqVO.getStatus())
                .eqIfPresent(LicenseDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(LicenseDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(LicenseDO::getId));
    }

}