package cn.newfeifan.mall.module.sale.dal.mysql.merchant;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.module.sale.controller.app.merchant.vo.MerchantPageReqVO;
import cn.newfeifan.mall.module.sale.dal.dataobject.merchant.MerchantDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 商户 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface MerchantMapper extends BaseMapperX<MerchantDO> {

    default PageResult<MerchantDO> selectPage(MerchantPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MerchantDO>()
                .likeIfPresent(MerchantDO::getName, reqVO.getName())
                .eqIfPresent(MerchantDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MerchantDO::getDescription, reqVO.getDescription())
                .eqIfPresent(MerchantDO::getAddress, reqVO.getAddress())
                .eqIfPresent(MerchantDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(MerchantDO::getWebsite, reqVO.getWebsite())
                .eqIfPresent(MerchantDO::getComplaintsHotline, reqVO.getComplaintsHotline())
                .eqIfPresent(MerchantDO::getCustomerServiceHotline, reqVO.getCustomerServiceHotline())
                .eqIfPresent(MerchantDO::getEmail, reqVO.getEmail())
                .eqIfPresent(MerchantDO::getBusinessLicensePicture, reqVO.getBusinessLicensePicture())
                .betweenIfPresent(MerchantDO::getExpireTime, reqVO.getExpireTime())
                .betweenIfPresent(MerchantDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(MerchantDO::getLogoUrl, reqVO.getLogoUrl())
                .eqIfPresent(MerchantDO::getContact, reqVO.getContact())

                .eqIfPresent(MerchantDO::getPackageId, reqVO.getPackageId())
                .eqIfPresent(MerchantDO::getShopCount, reqVO.getShopCount())
                .eqIfPresent(MerchantDO::getAreaId, reqVO.getAreaId())
                .orderByDesc(MerchantDO::getId));
    }

}