package co.yixiang.yshop.module.shop.dal.mysql.shopassistant;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.module.shop.controller.admin.shopassistant.vo.ShopAssistantExportReqVO;
import co.yixiang.yshop.module.shop.controller.admin.shopassistant.vo.ShopAssistantPageReqVO;
import co.yixiang.yshop.module.shop.dal.dataobject.shopassistant.ShopAssistantDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 门店店员 Mapper
 *
 * @author admin
 */
@Mapper
public interface ShopAssistantMapper extends BaseMapperX<ShopAssistantDO> {

    default PageResult<ShopAssistantDO> selectPage(ShopAssistantPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopAssistantDO>()
                .eqIfPresent(ShopAssistantDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(ShopAssistantDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ShopAssistantDO::getName, reqVO.getName())
                .eqIfPresent(ShopAssistantDO::getPhoneNo, reqVO.getPhoneNo())
                .eqIfPresent(ShopAssistantDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShopAssistantDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopAssistantDO::getId));
    }

    default List<ShopAssistantDO> selectList(ShopAssistantExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopAssistantDO>()
                .eqIfPresent(ShopAssistantDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(ShopAssistantDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ShopAssistantDO::getName, reqVO.getName())
                .eqIfPresent(ShopAssistantDO::getPhoneNo, reqVO.getPhoneNo())
                .eqIfPresent(ShopAssistantDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShopAssistantDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopAssistantDO::getId));
    }

}
