package com.zt.plat.module.qms.business.config.dal.mapper;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigPermissionPageReqVO;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigPermissionDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 权限配置,通用权限配置 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ConfigPermissionMapper extends BaseMapperX<ConfigPermissionDO> {

    default PageResult<ConfigPermissionDO> selectPage(ConfigPermissionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfigPermissionDO>()
                .eqIfPresent(ConfigPermissionDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(ConfigPermissionDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(ConfigPermissionDO::getTargetId, reqVO.getTargetId())
                .eqIfPresent(ConfigPermissionDO::getTargetType, reqVO.getTargetType())
                .eqIfPresent(ConfigPermissionDO::getPermissionType, reqVO.getPermissionType())
                .eqIfPresent(ConfigPermissionDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ConfigPermissionDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConfigPermissionDO::getRemark, reqVO.getRemark())
                .orderByDesc(ConfigPermissionDO::getId));
    }

}