package com.zt.plat.module.qms.resource.record.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.resource.record.controller.admin.recordpermission.vo.RecordPermissionPageReqVO;
import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 记录权限 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface RecordPermissionMapper extends BaseMapperX<RecordPermissionDO> {

    default PageResult<RecordPermissionDO> selectPage(RecordPermissionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecordPermissionDO>()
                .eqIfPresent(RecordPermissionDO::getParentId, reqVO.getParentId())
//                .eqIfPresent(RecordPermissionDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(RecordPermissionDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(RecordPermissionDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(RecordPermissionDO::getTargetType, reqVO.getTargetType())
                .eqIfPresent(RecordPermissionDO::getTargetId, reqVO.getTargetId())
                .eqIfPresent(RecordPermissionDO::getPermission, reqVO.getPermission())
                .eqIfPresent(RecordPermissionDO::getConfidentialLevel, reqVO.getConfidentialLevel())
                .eqIfPresent(RecordPermissionDO::getPermanently, reqVO.getPermanently())
                .betweenIfPresent(RecordPermissionDO::getExpirationDate, reqVO.getExpirationDate())
                .eqIfPresent(RecordPermissionDO::getExpirationStatus, reqVO.getExpirationStatus())
                .eqIfPresent(RecordPermissionDO::getCancelFlag, reqVO.getCancelFlag())
                .eqIfPresent(RecordPermissionDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(RecordPermissionDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(RecordPermissionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecordPermissionDO::getId));
    }

}