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

import java.util.*;

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

/**
 * 店铺 Mapper
 *
 * @author 非繁人
 * add by Ben 20240315
 */
@Mapper
public interface ShopMapper extends BaseMapperX<ShopDO> {

    default List<ShopDO> selectListById(Collection<Long> shopIds) {
        return selectList(ShopDO::getId, shopIds);
    }

    default PageResult<ShopDO> selectPage(ShopPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopDO>()
                .likeIfPresent(ShopDO::getName, reqVO.getName())
                .eqIfPresent(ShopDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ShopDO::getMerchantId, reqVO.getMerchantId())
                .betweenIfPresent(ShopDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ShopDO::getLogoUrl, reqVO.getLogoUrl())
                .orderByDesc(ShopDO::getId));
    }

}