package cn.iocoder.yudao.module.system.dal.mysql.worklog;

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.system.controller.admin.worklog.vo.form.LogFormPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface LogFormMapper extends BaseMapperX<LogFormDO> {

    default PageResult<LogFormDO> selectPage(LogFormPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LogFormDO>()
                .likeIfPresent(LogFormDO::getName, reqVO.getName())
                .eqIfPresent(LogFormDO::getStatus, reqVO.getStatus())
                .orderByDesc(LogFormDO::getId));
    }

    default PageResult<LogFormDO> selectPageByRule(LogFormPageReqVO reqVO, List<Long> formIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LogFormDO>()
                .eq(LogFormDO::getStatus, 0)
                .in(LogFormDO::getId, formIds)
                .orderByDesc(LogFormDO::getId));
    }
}
