package cn.iocoder.yudao.module.supplier.dal.mysql.product;

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.supplier.controller.admin.product.vo.ConnectRecordPageReqVO;
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.ConnectRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 供应商联系记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ConnectRecordMapper extends BaseMapperX<ConnectRecordDO> {

    default PageResult<ConnectRecordDO> selectPage(ConnectRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConnectRecordDO>()
                .eqIfPresent(ConnectRecordDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(ConnectRecordDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(ConnectRecordDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ConnectRecordDO::getUsername, reqVO.getUsername())
                .eqIfPresent(ConnectRecordDO::getContactId, reqVO.getContactId())
                .likeIfPresent(ConnectRecordDO::getContactName, reqVO.getContactName())
                .eqIfPresent(ConnectRecordDO::getReason, reqVO.getReason())
                .eqIfPresent(ConnectRecordDO::getContent, reqVO.getContent())
                .eqIfPresent(ConnectRecordDO::getUrls, reqVO.getUrls())
                .betweenIfPresent(ConnectRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ConnectRecordDO::getId));
    }

    default List<ConnectRecordDO> selectListBySupplierId(Long supplierId) {
        return selectList(new LambdaQueryWrapperX<ConnectRecordDO>()
                .eq(ConnectRecordDO::getSupplierId, supplierId)
                .orderByDesc(ConnectRecordDO::getId));

    }

}
