package com.hzs.system.sys.service.impl;

import java.util.HashSet;
import java.util.Set;

import com.hzs.common.domain.system.sys.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hzs.system.sys.service.ISysMenuService;
import com.hzs.system.sys.service.ISysPermissionService;

@Service
public class SysPermissionServiceImpl implements ISysPermissionService {

    @Autowired
    private ISysMenuService iSysMenuService;

    /**
     * 根据用户ID查询按钮权限
     *
     * @param userId 用户Id
     * @return 菜单权限信息
     */
    @Override
    public Set<String> getButtonPermission(Long userId) {
        Set<String> perms = new HashSet<>();
        // 管理员拥有所有权限
        if (SysUser.isAdmin(userId)) {
            perms.add("*");
        } else {
            perms.addAll(iSysMenuService.selectButtonPermsByUserId(userId));
        }
        return perms;
    }

}
