package cn.ey.biz.module.system.dal.mapper.field;

import java.util.*;

import cn.ey.biz.common.pojo.PageResult;
import cn.ey.biz.framework.mybatis.core.mapper.BaseMapperX;
import cn.ey.biz.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ey.biz.module.system.controller.admin.field.vo.FieldItemExportReqVO;
import cn.ey.biz.module.system.controller.admin.field.vo.FieldItemPageReqVO;
import cn.ey.biz.module.system.dal.dataobject.field.FieldItemDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 字段条目 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface FieldItemMapper extends BaseMapperX<FieldItemDO> {

    default PageResult<FieldItemDO> selectPage(FieldItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FieldItemDO>()
                .eqIfPresent(FieldItemDO::getFieldCode, reqVO.getFieldCode())
                .eqIfPresent(FieldItemDO::getBelongTo, reqVO.getBelongTo())
                .betweenIfPresent(FieldItemDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(FieldItemDO::getConfigId, reqVO.getConfigId())
                .orderByDesc(FieldItemDO::getId));
    }

    default List<FieldItemDO> selectList(FieldItemExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FieldItemDO>()
                .eqIfPresent(FieldItemDO::getFieldCode, reqVO.getFieldCode())
                .eqIfPresent(FieldItemDO::getBelongTo, reqVO.getBelongTo())
                .betweenIfPresent(FieldItemDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(FieldItemDO::getConfigId, reqVO.getConfigId())
                .orderByDesc(FieldItemDO::getId));
    }

}
