package cn.iocoder.yudao.module.pms.dal.mysql.yanfan.sip.config;

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.sip.config.vo.IotYfSipConfigPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.sip.config.IotSipConfigDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * yf-sip系统配置 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotSipConfigMapper extends BaseMapperX<IotSipConfigDO> {
    List<IotSipConfigDO> selectSipConfigList(IotSipConfigDO sipConfig);
    default PageResult<IotSipConfigDO> selectPage(IotYfSipConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotSipConfigDO>()
                .eqIfPresent(IotSipConfigDO::getProductId, reqVO.getProductId())
                .likeIfPresent(IotSipConfigDO::getProductName, reqVO.getProductName())
                .eqIfPresent(IotSipConfigDO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(IotSipConfigDO::getIsdefault, reqVO.getIsdefault())
//                .eqIfPresent(IotSipConfigDO::getSeniorSdp, reqVO.getSeniorSdp())
                .eqIfPresent(IotSipConfigDO::getDomain, reqVO.getDomain())
                .eqIfPresent(IotSipConfigDO::getServerSipid, reqVO.getServerSipid())
                .eqIfPresent(IotSipConfigDO::getPassword, reqVO.getPassword())
                .eqIfPresent(IotSipConfigDO::getIp, reqVO.getIp())
                .eqIfPresent(IotSipConfigDO::getPort, reqVO.getPort())
                .eqIfPresent(IotSipConfigDO::getDelFlag, reqVO.getDelFlag())
                .eqIfPresent(IotSipConfigDO::getCreateBy, reqVO.getCreateBy())
                .eqIfPresent(IotSipConfigDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(IotSipConfigDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotSipConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotSipConfigDO::getId));
    }

    int deleteSipConfigByProductId(Long[] productIds);
    int resetDefaultSipConfig();
}
