package cn.iocoder.yudao.module.pms.dal.mysql.iotattachment;

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.iotattachment.vo.IotAttachmentPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotattachment.IotAttachmentDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 附件 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotAttachmentMapper extends BaseMapperX<IotAttachmentDO> {

    default PageResult<IotAttachmentDO> selectPage(IotAttachmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotAttachmentDO>()
                .eqIfPresent(IotAttachmentDO::getCategory, reqVO.getCategory())
                .eqIfPresent(IotAttachmentDO::getBizId, reqVO.getBizId())
                .eqIfPresent(IotAttachmentDO::getType, reqVO.getType())
                .likeIfPresent(IotAttachmentDO::getFilename, reqVO.getFilename())
                .eqIfPresent(IotAttachmentDO::getFileType, reqVO.getFileType())
                .eqIfPresent(IotAttachmentDO::getFilePath, reqVO.getFilePath())
                .eqIfPresent(IotAttachmentDO::getFileSize, reqVO.getFileSize())
                .eqIfPresent(IotAttachmentDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotAttachmentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotAttachmentDO::getId));
    }

    default List<IotAttachmentDO> attachments(IotAttachmentPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotAttachmentDO>()
                .eqIfPresent(IotAttachmentDO::getCategory, reqVO.getCategory())
                .eqIfPresent(IotAttachmentDO::getBizId, reqVO.getBizId())
                .inIfPresent(IotAttachmentDO::getBizId, reqVO.getBizIds())
                .eqIfPresent(IotAttachmentDO::getType, reqVO.getType())
                .likeIfPresent(IotAttachmentDO::getFilename, reqVO.getFilename())
                .eqIfPresent(IotAttachmentDO::getFileType, reqVO.getFileType())
                .inIfPresent(IotAttachmentDO::getType, reqVO.getTypes())
                .eqIfPresent(IotAttachmentDO::getFilePath, reqVO.getFilePath())
                .eqIfPresent(IotAttachmentDO::getFileSize, reqVO.getFileSize())
                .eqIfPresent(IotAttachmentDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotAttachmentDO::getCreateTime, reqVO.getCreateTime()));
    }

}