package com.hai.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

import java.util.Map;

/**
 * mapper扩展类
 */
public interface SecPermissionMapperExt {
    @Delete({"<script>" +
            "  DELETE a FROM sec_role_permission_rel a INNER JOIN (SELECT" +
            " srpr.id" +
            " FROM" +
            " sec_role_permission_rel srpr" +
            " WHERE" +
            " srpr.role_id IN (" +
            " SELECT" +
            " sr.id role_id" +
            " FROM" +
            " sec_role sr" +
            " WHERE" +
            " EXISTS (" +
            " SELECT" +
            " su.company_id" +
            " FROM" +
            " sec_user_role_rel surr," +
            " sec_user su" +
            " WHERE" +
            " surr.role_id = #{map.roleId}" +
            " AND surr.user_id = su.id" +
            " AND su.company_id = sr.company_id" +
            " )" +
            " )" +
            " AND srpr.permission_id = #{map.permissionId}) b ON a.id = b.id" +
            "</script>"})
    void deleteTemplatePermission(@Param("map") Map<String, String> map);
}
