package com.njzscloud.supervisory.auth.service;

import com.njzscloud.common.security.support.*;
import com.njzscloud.supervisory.resource.service.SysResourceService;
import com.njzscloud.supervisory.role.service.SysRoleService;
import com.njzscloud.supervisory.user.service.SysUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Set;

@Slf4j
@Service
@RequiredArgsConstructor
public class SecurityService implements IUserService, IResourceService, IRoleService {

    private final SysUserService sysUserService;
    private final SysRoleService sysRoleService;
    private final SysResourceService sysResourceService;

    @Override
    public UserDetail selectUserByAccount(String account) {
        return sysUserService.getUserInfo(account);
    }

    @Override
    public Resource selectResourceByUserId(Long userId) {
        return sysResourceService.selectResourceByUserId(userId);
    }

    @Override
    public Set<String> selectRoleByUserId(Long userId) {
        return sysRoleService.listUserRole(userId);
    }
}
