package cn.iocoder.yudao.module.pms.dal.mysql.yanfan.product;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pms.controller.admin.yanfan.product.vo.IotYfProductPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.product.IotYfProductDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 产品 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotYfProductMapper extends BaseMapperX<IotYfProductDO> {
    IotYfProductDO getProductBySerialNumber(String serialNumber);
    default PageResult<IotYfProductDO> selectPage(IotYfProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotYfProductDO>()
                .likeIfPresent(IotYfProductDO::getProductName, reqVO.getProductName())
                .eqIfPresent(IotYfProductDO::getProtocolCode, reqVO.getProtocolCode())
                .eqIfPresent(IotYfProductDO::getCategoryId, reqVO.getCategoryId())
                .likeIfPresent(IotYfProductDO::getCategoryName, reqVO.getCategoryName())
                .likeIfPresent(IotYfProductDO::getTenantName, reqVO.getTenantName())
                .eqIfPresent(IotYfProductDO::getIsSys, reqVO.getIsSys())
                .eqIfPresent(IotYfProductDO::getIsAuthorize, reqVO.getIsAuthorize())
                .eqIfPresent(IotYfProductDO::getMqttAccount, reqVO.getMqttAccount())
                .eqIfPresent(IotYfProductDO::getMqttPassword, reqVO.getMqttPassword())
                .eqIfPresent(IotYfProductDO::getMqttSecret, reqVO.getMqttSecret())
                .eqIfPresent(IotYfProductDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotYfProductDO::getThingsModelsJson, reqVO.getThingsModelsJson())
                .eqIfPresent(IotYfProductDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(IotYfProductDO::getNetworkMethod, reqVO.getNetworkMethod())
                .eqIfPresent(IotYfProductDO::getVertificateMethod, reqVO.getVertificateMethod())
                .eqIfPresent(IotYfProductDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(IotYfProductDO::getDelFlag, reqVO.getDelFlag())
                .eqIfPresent(IotYfProductDO::getCreateBy, reqVO.getCreateBy())
                .betweenIfPresent(IotYfProductDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(IotYfProductDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(IotYfProductDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotYfProductDO::getTransport, reqVO.getTransport())
                .eqIfPresent(IotYfProductDO::getLocationWay, reqVO.getLocationWay())
                .eqIfPresent(IotYfProductDO::getGuid, reqVO.getGuid())
                .eqIfPresent(IotYfProductDO::getUrl, reqVO.getUrl())
                .eqIfPresent(IotYfProductDO::getMethodType, reqVO.getMethodType())
                .eqIfPresent(IotYfProductDO::getParamsData, reqVO.getParamsData())
                .eqIfPresent(IotYfProductDO::getHeaders, reqVO.getHeaders())
                .eqIfPresent(IotYfProductDO::getData, reqVO.getData())
                .eqIfPresent(IotYfProductDO::getContentType, reqVO.getContentType())
                .eqIfPresent(IotYfProductDO::getCronExpression, reqVO.getCronExpression())
                .eqIfPresent(IotYfProductDO::getRequestType, reqVO.getRequestType())
                .eqIfPresent(IotYfProductDO::getContentTypeNumber, reqVO.getContentTypeNumber())
                .eqIfPresent(IotYfProductDO::getResponseKey, reqVO.getResponseKey())
                .eqIfPresent(IotYfProductDO::getIpAddress, reqVO.getIpAddress())
                .likeIfPresent(IotYfProductDO::getEquipmentName, reqVO.getEquipmentName())
                .eqIfPresent(IotYfProductDO::getCommunity, reqVO.getCommunity())
                .eqIfPresent(IotYfProductDO::getOidListStr, reqVO.getOidListStr())
                .likeIfPresent(IotYfProductDO::getUsername, reqVO.getUsername())
                .eqIfPresent(IotYfProductDO::getUserpassword, reqVO.getUserpassword())
                .eqIfPresent(IotYfProductDO::getHttptype, reqVO.getHttptype())
                .eqIfPresent(IotYfProductDO::getUserkey, reqVO.getUserkey())
                .eqIfPresent(IotYfProductDO::getHttpurl, reqVO.getHttpurl())
                .eqIfPresent(IotYfProductDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(IotYfProductDO::getProductId));
    }

    int deleteProductThingsModelByProductIds(Long[] productIds);
}
