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.FieldConfigExportReqVO;
import cn.ey.biz.module.system.controller.admin.field.vo.FieldConfigPageReqVO;
import cn.ey.biz.module.system.dal.dataobject.field.FieldConfigDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 字段权限配置 Mapper
 *
 */
@Mapper
public interface FieldConfigMapper extends BaseMapperX<FieldConfigDO> {

    default PageResult<FieldConfigDO> selectPage(FieldConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FieldConfigDO>()
                .eqIfPresent(FieldConfigDO::getConfigCode, reqVO.getConfigCode())
                .eqIfPresent(FieldConfigDO::getApp, reqVO.getApp())
                .eqIfPresent(FieldConfigDO::getEnable, reqVO.getEnable())
                .eqIfPresent(FieldConfigDO::getVersion, reqVO.getVersion())
                .likeIfPresent(FieldConfigDO::getCreatorName, reqVO.getCreatorName())
                .likeIfPresent(FieldConfigDO::getUpdaterName, reqVO.getUpdaterName())
                .betweenIfPresent(FieldConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(FieldConfigDO::getId));
    }

    default List<FieldConfigDO> selectList(FieldConfigExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FieldConfigDO>()
                .eqIfPresent(FieldConfigDO::getConfigCode, reqVO.getConfigCode())
                .eqIfPresent(FieldConfigDO::getApp, reqVO.getApp())
                .eqIfPresent(FieldConfigDO::getEnable, reqVO.getEnable())
                .eqIfPresent(FieldConfigDO::getVersion, reqVO.getVersion())
                .likeIfPresent(FieldConfigDO::getCreatorName, reqVO.getCreatorName())
                .likeIfPresent(FieldConfigDO::getUpdaterName, reqVO.getUpdaterName())
                .betweenIfPresent(FieldConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FieldConfigDO::getId));
    }

}
