package cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourcePageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * SOC卡分析数据源 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotSocSourceMapper extends BaseMapperX<IotSocSourceDO> {
    default List<IotSocSourceDO> selectListByParentId(Collection<Long> parentIds) {
        return selectList(IotSocSourceDO::getParentId, parentIds);
    }
    default PageResult<IotSocSourceDO> selectPage(IotSocSourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotSocSourceDO>()
                .eqIfPresent(IotSocSourceDO::getParentId, reqVO.getParentId())
                .likeIfPresent(IotSocSourceDO::getName, reqVO.getName())
                .eqIfPresent(IotSocSourceDO::getCode, reqVO.getCode())
                .eqIfPresent(IotSocSourceDO::getSort, reqVO.getSort())
                .eqIfPresent(IotSocSourceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(IotSocSourceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(IotSocSourceDO::getRemark, reqVO.getRemark())
                .orderByDesc(IotSocSourceDO::getId));
    }
    default IotSocSourceDO selectByParentIdAndName(Long parentId, String name) {
        return selectOne(IotSocSourceDO::getParentId, parentId, IotSocSourceDO::getName, name);
    }
    default Long selectCountByParentId(Long parentId) {
        return selectCount(IotSocSourceDO::getParentId, parentId);
    }
    default List<IotSocSourceDO> selectList(IotSocSourcePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotSocSourceDO>()
                .likeIfPresent(IotSocSourceDO::getName, reqVO.getName())
                .likeIfPresent(IotSocSourceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotSocSourceDO::getStatus, reqVO.getStatus()));
    }
}