package com.yc.ship.module.otc.dal.mysql.store;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.otc.controller.admin.store.machineproduct.StoreMachineProductPageReqVO;
import com.yc.ship.module.otc.dal.dataobject.store.StoreMachineProductDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 门店设备关联 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface StoreMachineProductMapper extends BaseMapperX<StoreMachineProductDO> {

    default PageResult<StoreMachineProductDO> selectPage(StoreMachineProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StoreMachineProductDO>()
                .eqIfPresent(StoreMachineProductDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(StoreMachineProductDO::getProductId, reqVO.getProductId())
                .eqIfPresent(StoreMachineProductDO::getMachineId, reqVO.getMachineId())
                .betweenIfPresent(StoreMachineProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreMachineProductDO::getId));
    }

    default int deleteByStoreId(Long storeId) {
        return delete(StoreMachineProductDO::getStoreId, storeId);
    }

}
