package cn.iocoder.yudao.module.asset.dal.mysql.customer;

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.asset.controller.admin.customer.vo.CustomerPageReqVO;
import cn.iocoder.yudao.module.asset.dal.dataobject.customer.CustomerDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 客户信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CustomerMapper extends BaseMapperX<CustomerDO> {

    default PageResult<CustomerDO> selectPage(CustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerDO>()
                .eqIfPresent(CustomerDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(CustomerDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(CustomerDO::getCoopStatus, reqVO.getCoopStatus())
                .eqIfPresent(CustomerDO::getRegion, reqVO.getRegion())
                .eqIfPresent(CustomerDO::getProvince, reqVO.getProvince())
                .eqIfPresent(CustomerDO::getCity, reqVO.getCity())
                .likeIfPresent(CustomerDO::getContactMobile, reqVO.getContactMobile())
                .orderByDesc(CustomerDO::getId));
    }

}
