package cn.iocoder.yudao.module.cus.dal.mysql.management;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.cus.dal.dataobject.management.ManagementDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.cus.controller.admin.management.vo.*;

/**
 * 客户管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ManagementMapper extends BaseMapperX<ManagementDO> {

    default PageResult<ManagementDO> selectPage(ManagementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ManagementDO>()
                .eqIfPresent(ManagementDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(ManagementDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(ManagementDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ManagementDO::getAfterSalesManager, reqVO.getAfterSalesManager())
                .eqIfPresent(ManagementDO::getCountryCode, reqVO.getCountryCode())
                .likeIfPresent(ManagementDO::getCountryName, reqVO.getCountryName())
                .eqIfPresent(ManagementDO::getProvinceCode, reqVO.getProvinceCode())
                .likeIfPresent(ManagementDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(ManagementDO::getCityCode, reqVO.getCityCode())
                .likeIfPresent(ManagementDO::getCityName, reqVO.getCityName())
                .eqIfPresent(ManagementDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ManagementDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(ManagementDO::getLatitude, reqVO.getLatitude())
                .eqIfPresent(ManagementDO::getDbIp, reqVO.getDbIp())
                .eqIfPresent(ManagementDO::getDbPort, reqVO.getDbPort())
                .likeIfPresent(ManagementDO::getDbUsername, reqVO.getDbUsername())
                .eqIfPresent(ManagementDO::getDbPassword, reqVO.getDbPassword())
                .betweenIfPresent(ManagementDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ManagementDO::getId));
    }

}