package jnpf.dmsMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import jnpf.dmsEntity.permission.entity.DmsAccessExclusionEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.util.Date; import java.util.List; import java.util.UUID; @Mapper public interface DmsAccessExclusionMapper extends BaseMapper { String COLUMNS = "id, tenant_id, resource_type, resource_id, user_id, action_code, source_type, " + "source_id, valid_from, valid_to, exclude_reason, excluded_by_type, excluded_by_id, " + "revoked_at, revoked_by_type, revoked_by_id, revoke_reason, revision, created_at, updated_at"; @Select("SELECT 1 FROM (SELECT pg_advisory_xact_lock(hashtextextended(#{tenantId} || ':' " + "|| #{sourceType} || ':' || #{sourceId}, 0))) advisory_lock") Integer lockSource(@Param("tenantId") String tenantId, @Param("sourceType") String sourceType, @Param("sourceId") String sourceId); @Select("SELECT " + COLUMNS + " FROM public.dms_access_exclusions " + "WHERE tenant_id = #{tenantId} AND source_type = #{sourceType} " + "AND source_id = #{sourceId} ORDER BY id") List selectBySource(@Param("tenantId") String tenantId, @Param("sourceType") String sourceType, @Param("sourceId") String sourceId); @Insert({""}) int insertBatch(@Param("items") List items); @Select({""}) List selectByTenantAndIdsForUpdate(@Param("tenantId") String tenantId, @Param("ids") List ids); @Select({""}) List selectByTenantAndIds(@Param("tenantId") String tenantId, @Param("ids") List ids); @Update({""}) int revokeBatch(@Param("tenantId") String tenantId, @Param("ids") List ids, @Param("actorType") String actorType, @Param("actorId") String actorId, @Param("reason") String reason); @Select({""}) List selectPage(@Param("tenantId") String tenantId, @Param("resourceId") UUID resourceId, @Param("userId") String userId, @Param("cursorTime") Date cursorTime, @Param("cursorId") UUID cursorId, @Param("limit") int limit); @Select({""}) List selectActiveForResourceIds(@Param("tenantId") String tenantId, @Param("userId") String userId, @Param("resourceIds") List resourceIds); }