package com.lightinit.hsdataplatformresdir.impl.admin;

import com.lightinit.hsdataplatformresdir.common.SysContants;
import com.lightinit.hsdataplatformresdir.entity.SentryRoleAction;
import com.lightinit.hsdataplatformresdir.mapper.SentryRoleActionMapper;
import com.lightinit.hsdataplatformresdir.service.admin.IRolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WangYao
 * @date 2018/12/13 14:09
 * @description 基于角色的权限业务实现
 */
@Service
public class RolePermissionServiceImpl implements IRolePermissionService {

    @Autowired
    private SentryRoleActionMapper sentryRoleActionMapper;

    /**
     * @return 获取全部基于角色的权限，带缓存
     */
    @Cacheable(value = SysContants.CacheName.ROLE_PERMISSION_CACHE)
    public List<SentryRoleAction> getAllRolePermissions(){
//        DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
        return sentryRoleActionMapper.selectSentryRoleAction(null);
    }

    /**
     * 清除基于角色的权限缓存
     */
    @CacheEvict(value = SysContants.CacheName.ROLE_PERMISSION_CACHE, allEntries = true)
    public void clearRolePermissionCache(){
    }
}
