package com.zt.plat.module.base.dal.mysql.base;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.base.controller.admin.base.vo.ContactPageReqVO;
import com.zt.plat.module.base.dal.dataobject.base.ContactDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 联系人信息 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ContactMapper extends BaseMapperX<ContactDO> {

    default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>()
                .eqIfPresent(ContactDO::getType, reqVO.getType())
                .likeIfPresent(ContactDO::getContact, reqVO.getContact())
                .likeIfPresent(ContactDO::getTel, reqVO.getTel())
                .likeIfPresent(ContactDO::getCustomerName, reqVO.getCustomerName())
                .likeIfPresent(ContactDO::getCustomerNumber, reqVO.getCustomerNumber())
                .eqIfPresent(ContactDO::getIsEnable, reqVO.getIsEnable())
                .likeIfPresent(ContactDO::getEmail, reqVO.getEmail())
                .likeIfPresent(ContactDO::getFax, reqVO.getFax())
                .likeIfPresent(ContactDO::getAddress, reqVO.getAddress())
                .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ContactDO::getId));
    }

}