package cn.iocoder.yudao.module.infra.dal.mysql.file;

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.infra.controller.admin.file.vo.file.FilePageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BpmFileDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BusinessFileDO;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.apache.ibatis.annotations.Mapper;

/**
 * business文件操作 Mapper
 *

 */
@Mapper
public interface BusinessFileMapper extends BaseMapperX<BusinessFileDO> {

    default BusinessFileDO selectOneByUrl(String url) {
        //url地址是唯一的。
        return selectOne(new LambdaQueryWrapperX<BusinessFileDO>()
                .eq(BusinessFileDO:: getUrl, url));
    }
    default BusinessFileDO selectOneByBusinessInstanceId(Long businessType, String businessInstanceId) {
        return selectOne(new LambdaQueryWrapperX<BusinessFileDO>()
                .eq(BusinessFileDO:: getBusinessType, businessType)
                .eq(BusinessFileDO:: getBusinessInstanceId, businessInstanceId));
    }

    default PageResult<BusinessFileDO> selectPage(FilePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessFileDO>()
                .likeIfPresent(BusinessFileDO::getPath, reqVO.getPath())
                .likeIfPresent(BusinessFileDO::getType, reqVO.getType())
                .betweenIfPresent(BusinessFileDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BusinessFileDO::getId));
    }
}
